This post is an update to a previous post on using multiple interfaces(Ethernet cards) on the LAN, – utilizing RedHat’s popular virtualization tools – QEMU, KVM, libvirt, and virt-manager. In this article I will demonstrate with Fedora 21, but this roughly applies to CentOS 7 as well.
I’ve resisted upgrading to recent versions of Fedora/CentOS for a long time. The main reason is that I hate NetworkManager. It does to much automatically; I much preferred the old ‘network’ daemon that could easily be manually set. For instance if I create a Bridge(call it bridge1) interface assigned to my second Ethernet card(eth1) NetworkManager will automatically create a profile for each with automatic startup and DHCP enabled! I don’t need or want a DHCP lease on either side of a bridged interface! Among other issues are the creation of duplicate profiles when libvirt restarts. So NetworkManger reports ‘bridge1’ & ‘bridge1’ in the NM start menu applet.
Ideally libvirt and NetworkManager would work hand in hand because Redhat sponsors both projects…
In this article we will describe the steps to allow you to connect two seperate NIC’s to a switch; assigning one of the NIC’s specifically to guest VM’s.
Goals of this post:
- Set NetworkManager to ignore bridge and Ethernet device
- enable systemd version of rc.local boot script to create bridge at boot
- assign host to specific bridged Ethernet device
Step 1: Decide which Ethernet card will be used for host
We will be creating a bridge to allow our VM’s access to the local network. Run the ‘ifconfig’ command to locate and choose the dedicated Ethernet card we will assign to ‘bridge1’.
I’m using Ethernet device enp6s3 for my bridge(call it bridge1).
Step 2: Disable NetworkManager on specific Ethernet device
Navigate to the ‘/etc/NetworkManager’ directory. Open up NetworkManager.conf with your favorite text editor. The keyfile plugin allows us to exclude the devices a number of ways. I put the MAC address of enp6s3(00:02:b3:3d:50:ff) and also exluded the bridge I intend to create(bridge1) and also the virtual bridge(virbr0, created automatically by libvirt at boot for VM’s private network).
Step 3: Systemd and rc.local
If you’re super annoyed by Sytemd, NetworkManger and Gnome 3 so am I, but we got to get over it. Fedora 21 has a rc.local implantation installed by default, you just got to create the file, ‘/etc/rc.d/rc.local’. Add the following commands, being sure to put your Ethernet interface in place of mine below.
Reboot. On the next login use the ‘brctl’ command to make sure the bridge was set up properly. STP should be enabled and is necessary if two NIC’s are connected to the same switch.
This is how it should look:
Step 4: Assign Virtual Machine to interface
Open Virtual Machine Manager, select the VM to be assigned and ‘right click’ to select “open”. From the “View” option select “Details”. Next Select “NIC” from side pane and set it to ‘bridge1’
When you boot your VM it should now be able to get DHCP and communicate like a regular device on the local network! If anyone has instructions on Ubuntu/Debian please post!