<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2013/9/2 Jiaan Zeng <span dir="ltr"><<a href="mailto:l.allen09@gmail.com" target="_blank">l.allen09@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Hi All,<br>
<br>
I am new to libvirt and encounter a strange problem to set up network<br>
filter in a NAT network.<br>
<br>
I launched VMs in a single host using NAT, i.e. interface<br>
type='network'. Now I want to control the outbound traffic from VM<br>
instance - only allow the VM to asses a set of ip addresses. My<br>
network filter xml is as follows. The problem is once I change the VM<br>
xml, shutdown and start VM, VM cannot get ip address.<br>
/var/log/libvirt/libvirt.log shows " error : virNetDevGetIndex:656 :<br>
Unable to get index for interface vnet2: No such device" error.<br>
<br>
But when I remove the drop rule in the filter xml, VM can get IP<br>
address. I even tried the clean-traffic filter shipped with libvirt.<br>
VM throws the same error above.<br>
<br>
Any idea why this happens? How can I implement outbound traffic<br>
control in libvirt? Thanks a lot.<br>
<br>
<filter name='filter-test'><br>
  <rule action='accept' direction='in' priority='500'><br>
    <tcp dstportstart='22'/><br>
  </rule><br>
  <rule action='accept' direction='out' priority='500'><br>
    <ip dstipaddr='IP1'/><br>
  </rule><br>
  <rule action='accept' direction='out' priority='500'><br>
    <ip dstipaddr='IP2'/><br>
  </rule><br>
  <rule action='drop' direction='out' priority='500'><br>
    <all/><br>
  </rule><br>
</filter><br>
<br>
The VM network section XML looks like this<br>
<br>
 <interface type='network'><br>
      <mac address='52:54:00:0d:f1:ce'/><br>
      <source network='default'/><br>
      <filterref filter='filter-test'/><br>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03'<br>
function='0x0'/><br>
    </interface><br></blockquote><div>hello,perhaps this blog post will help you :-).</div></div></div></div>