Persistent Network Configuration using KVM and libvirt
Our environment will have a KVM host setup dynamically using kickstart (easy enough).
The hard part is dealing with network configuration and keeping VLAN configuration (and possibly bridge/host config) persistent across reboot.
We have a dynamic environment in which I would like to be able to configure virtual switch ports as you would with a typical switch where the configuration persists after reboot (maybe adds automatically to configuration file)
aka:
cisco: switchport mode access; switchport access vlan 4
brocade: vlan 4; untagged e 0/1/2
I'm not really sure what the 'right' decision is here, whether openvswitch is what i'm looking for of it can just be done using linux bridges and libvirt. I'm pretty lost and having a hard time finding what is available. I know OpenStack can do this, for me though it would be more interesting to know how OpenStack does it so we can implement its parts
So my question: what is the best/easiest way to persist vlan/network configurations on KVM?
Solution 1:
This is very simple to do. Normally, you would use bridging on the host, the bridge acting as a virtual switch for the VMs and the physical NICs to plug into:
network -> Host NIC -> BRIDGE <- VM
With VLANs this gets a bit more complicated:
network (trunk port) -> Host NIC -> Tagged IF -> BRIDGE <- VM
All of this is managed in ifcfg
scripts on a RHEL host, e.g. ifcfg-eth0 (host NIC); ifcfg-eth0.100 (Tagged IF); ifcfg-br100 (bridge interface working on top of the tagged interface, transmitting tagged traffic).
If you need multiple VLANs, simply add more ifcfg-eth0.tagNumber interfaces, and build a bridge on top of each, for VMs who need to be on the tagged network to plug into.
Hope it makes sense, it's really quite simple.
EDIT:
- if there's only one tag that you want to set on the switch that's also fine, just tag the traffic on the port, and use a bridge. Since everything arriving at the NIC will be tagged, the bridge will relay the traffic to the VMs as is
- for every VLAN you simply create a bridge and plug the VM into that bridge for tagged traffic access. If you have a small set of VLANs you will be using, just create all those VLAN IFs and bridges and plug VMs into whatever bridge+VLAN you need dynamically, without touching the host configuration