<font size=2 face="sans-serif">I have the need to modify the behavior
of the virtual network driver's behavior and how it deals with routed networks.
 I'm running libvirt-0.8.3-2.fc14.</font>
<br>
<br><font size=2 face="sans-serif">According to </font><a href=http://libvirt.org/firewall.html><font size=2 face="sans-serif">http://libvirt.org/firewall.html</font></a><font size=2 face="sans-serif">,
the following is automatically added to the FORWARD chain of iptables when
a network type of "routed" is started up:</font>
<br>
<br><font size=2 face="sans-serif">"Allow inbound, but only to our
expected subnet. Allow outbound, but only from our expected subnet. Allow
traffic between guests. Deny all other inbound. Deny all other outbound.
"</font>
<br>
<br><font size=2 face="sans-serif">The part of this that I need to adjust
is the fact that only IPs on my subnet will be allowed in and out.  I
have IP addresses assigned to my guests that have static routes configured
on the hypervisor to route to the local bridged interface.  I have
to do this due to the way the surrounding routers and switches on the network
are configured to handle public IP addresses and MAC address filtering.
  Here is an example of my config where the public IP address on the
guest machine is 1.1.2.2:</font>
<br>
<br><font size=2 face="sans-serif">My network to do the routing mode:</font>
<br><font size=2 face="sans-serif"><network></font>
<br><font size=2 face="sans-serif">  <name>local</name></font>
<br><font size=2 face="sans-serif">  <forward dev='eth0' mode='route'/></font>
<br><font size=2 face="sans-serif">  <bridge name='virbr_local'
stp='on' delay='0' /></font>
<br><font size=2 face="sans-serif">  <ip address='192.168.122.1'
netmask='255.255.255.0'/></font>
<br><font size=2 face="sans-serif"></network></font>
<br>
<br><font size=2 face="sans-serif">The network portion of the domain:</font>
<br><font size=2 face="sans-serif">    <interface type='network'></font>
<br><font size=2 face="sans-serif">      <mac address='xx:xx:xx:cc:xx:xx'/></font>
<br><font size=2 face="sans-serif">      <source network='local'/></font>
<br><font size=2 face="sans-serif">      <target dev='vnet0'/></font>
<br><font size=2 face="sans-serif">      <address type='pci'
domain='0x0000' bus='0x00' slot='0x02' function='0x0'/></font>
<br><font size=2 face="sans-serif">    </interface></font>
<br>
<br><font size=2 face="sans-serif">And finally the static route configured
on the hypervisor to get the routed traffic from eth0 on the hypervisor
down to the virbr_local device:</font>
<br><font size=2 face="sans-serif"># ip route add 1.1.2.2 dev virbr_local</font>
<br>
<br><font size=2 face="sans-serif">This will setup the iptables filters
just as the documentation defines, but the problem is that all traffic
from the guest will get REJECTED by iptables due to the source and destination
IP not falling within 192.168.122.0/24.  </font>
<br>
<br><font size=2 face="sans-serif">I've tried adding a custom filter into
the network filter driver, but haven't had much luck. Here are some of
the things that I've tried.</font>
<br>
<br><font size=2 face="sans-serif">The custom network filter.   Notice
that I'm using tcp, udp, and icmp specifically.  I'm doing this so
it will force inclusion into the iptables filtering rules rather than ebtables.
 </font>
<br><font size=2 face="sans-serif"><filter name='my-static-ip' chain='root'></font>
<br><font size=2 face="sans-serif">  <rule action='accept' direction='out'
priority='500'></font>
<br><font size=2 face="sans-serif">    <tcp srcipaddr='$MYIP'/></font>
<br><font size=2 face="sans-serif">  </rule></font>
<br><font size=2 face="sans-serif">  <rule action='accept' direction='out'
priority='500'></font>
<br><font size=2 face="sans-serif">    <udp srcipaddr='$MYIP'/></font>
<br><font size=2 face="sans-serif">  </rule></font>
<br><font size=2 face="sans-serif">  <rule action='accept' direction='out'
priority='500'></font>
<br><font size=2 face="sans-serif">    <icmp srcipaddr='$MYIP'/></font>
<br><font size=2 face="sans-serif">  </rule></font>
<br><font size=2 face="sans-serif">  <rule action='accept' direction='in'
priority='500'></font>
<br><font size=2 face="sans-serif">    <tcp dstipaddr='$MYIP'/></font>
<br><font size=2 face="sans-serif">  </rule></font>
<br><font size=2 face="sans-serif">  <rule action='accept' direction='in'
priority='500'></font>
<br><font size=2 face="sans-serif">    <udp dstipaddr='$MYIP'/></font>
<br><font size=2 face="sans-serif">  </rule></font>
<br><font size=2 face="sans-serif">  <rule action='accept' direction='in'
priority='500'></font>
<br><font size=2 face="sans-serif">    <icmp dstipaddr='$MYIP'/></font>
<br><font size=2 face="sans-serif">  </rule></font>
<br><font size=2 face="sans-serif"></filter></font>
<br>
<br><font size=2 face="sans-serif">And the modifications made to the domain's
network interface definition:</font>
<br><font size=2 face="sans-serif">    <interface type='network'></font>
<br><font size=2 face="sans-serif">      <mac address='xx:xx:xx:xx'/></font>
<br><font size=2 face="sans-serif">      <source network='local'/></font>
<br><font size=2 face="sans-serif">      <target dev='vnet0'/></font>
<br><font size=2 face="sans-serif">      <filterref filter='my-static-ip'></font>
<br><font size=2 face="sans-serif">        <parameter
name='MYIP' value=1.1.2.2'/></font>
<br><font size=2 face="sans-serif">      </filterref></font>
<br><font size=2 face="sans-serif">      <address type='pci'
domain='0x0000' bus='0x00' slot='0x02' function='0x0'/></font>
<br><font size=2 face="sans-serif">    </interface></font>
<br>
<br><font size=2 face="sans-serif">With the exception of simply manually
adding iptables rules in place after I start the network using virsh, does
anyone know how to accomplish what I'm trying to do? </font>
<br><font size=2 face="sans-serif"><br>
Ryan Sumner</font>