Wednesday, November 05, 2008

F10-beta Network Bridge

With a little direction from a fellow Fedora'r, I've finally got the last piece of the F10-beta virtualization suite working.

By default, KVM (I hate that name... a KVM is a type of switch) creates a bridge process between the physical NICs and the virtual machines. The bridge process handles DHCP on an internal subnet and NATs the VMs to the physical world. In other words, virbr0 emulated a Linksys or D-Link home router. This works fine for outbound communications, but does not lend itself to connecting to virtual servers.

What is needed is the ability to route from an external address to a VM. This means slaving an ethernet to a bridge, assigning them to the same network, and establishing a route between the physical card and the bridge. To accomplish this, I created the following script:
[root@adama network-scripts]# pwd
[root@adama network-scripts]# cat ifcfg-virbr1


brctl addbr $BR
ifconfig $IF
brctl addif $BR $IF
ifconfig $BR $NET.$HOST netmask up
route add -net $NET.0 netmask $BR
route add default gw $NET.1 $BR

exit 0
First the script location. By placing it in network-scripts, it is sourced at boot and service network restart. The name is not relevant except for the minor detail that the ifcfg's are executed alphabetically, so the filename has to start with letter FOX or higher.

Second, the script uses variables for portability. Notice that $NET.$HOST form an IP address. This will end up being the primary interface on the system, as the last command will switch the server's default route to the bridged interface.

Fianlly, I would suspect there is a way to embed this into the virtlibd subsystem. At this time that is not a priority and I think this may provide more flexibility. I say that because adding this script to a kickstart is simply the addition of a cat >> x << EOFcommand in post.

No comments:

Post a Comment