Friday, December 4, 2009

KVM virtual network forward options

If you are using KVM and virsh to net-create a virtual network and want to know what forward options there are, the answer is: "none", "nat", "route".

Details:

If you're editing a virtual network xml definition file that might be contained in /etc/libvirt/qemu/networks on RHEL 5.4:

# cat dev.xml 
<network>
  <name>dev</name>
  <uuid>fa07c9c6-e755-71f0-4312-4db325355c24</uuid>
  <forward mode='nat'/>
  <bridge name='virbr1' stp='on' forwardDelay='0' />
  <ip address='123.456.7.89' netmask='255.255.255.0'>
  </ip>
</network>
# 
and want to know what forward modes there are besides the default nat as shown above, it doesn't seem to be found in the documentation. I was able to get it by looking at the source.

 yum provides "*/virsh"
the above returned libvirt. Which do I have?
# rpm -qa | grep libvirt
libvirt-0.6.3-20.1.el5_4
libvirt-python-0.6.3-20.1.el5_4
libvirt-0.6.3-20.1.el5_4
# 
Note the first result. Downloaded the src.rpm from RHN:
* rpm -iv libvirt-0.6.3-20.1.el5_4.src.rpm
* cd /usr/src/redhat/SOURCES/
* tar xzf libvirt-0.6.3.tar.gz
* cd libvirt-0.6.3/src
* grep -i forward *
Eventually I found the following on line 51 of network_conf.c:
VIR_ENUM_IMPL(virNetworkForward,
              VIR_NETWORK_FORWARD_LAST,
              "none", "nat", "route" )
So, I'm pretty sure the answer is: "none", "nat", "route"

No comments: