A bridged networking setup is typically used in KVM(Kernel-based virtual machine) to allow the virtual machines to access the LAN/WAN over the IP address on the physical host. This guide is focused on a CentOS or similar derivative configuration setup. This is the second part of a multi-part series in setting up KVM services on a server. If you havent already please view our guide on KVM installation on CentOS
First Install the bridged networking package:
yum -y install bridge-utils
The package bridge-utils contains the utilities for configuring Ethernet bridges.
Next Reconfigure the network interface:
In this example we are going to reconfigure eth1 to be a bridged interface:
First go to the network-scripts directory:
Rename the network interface:
mv ifcfg-eth1 ifcfg-bridge1
Before it was this:
DEVICE=eth1 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=static HWADDR=00:1C:23:E1:54:58 IPADDR=192.168.1.80 PREFIX=24 GATEWAY=192.168.1.1 DNS1=188.8.131.52 DNS2=184.108.40.206 DEFROUTE=yes
We are going to change it to:
DEVICE=bridge1 TYPE=Bridge ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=static IPADDR=192.168.1.80 PREFIX=24 GATEWAY=192.168.1.1 DNS1=220.127.116.11 DNS2=18.104.22.168 DEFROUTE=yes
DEVICE was changed to a new name, type was set to ‘Bridge’ and the HWADDR was removed.
We are going to create a new ifcfg-eth1 for eth1 now that will contain the following:
DEVICE=eth1 ONBOOT=yes HWADDR=00:1C:23:E1:54:58 BRIDGE=bridge1
DEVICE sets the device name, we copied the HWADDR when we removed it from the bridge1 file and we set BRIDGE=bridge1.
Lastly Load the new settings:
Go ahead and restart the network to bring up the bridged interface and eth1 again
systemctl restart network
Type the following to confirm the new settings are working correctly:
You should see:
bridge1 Link encap:Ethernet HWaddr 00:1C:23:E1:54:58 inet addr:192.168.1.80 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::21c:23ff:fee1:5458/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:92 errors:0 dropped:0 overruns:0 frame:0 TX packets:30 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:11935 (11.6 KiB) TX bytes:3563 (3.4 KiB) eth1 Link encap:Ethernet HWaddr 00:1C:23:E1:54:58 inet6 addr: fe80::21c:23ff:fee1:5458/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:87 errors:0 dropped:0 overruns:0 frame:0 TX packets:25 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:13117 (12.8 KiB) TX bytes:3325 (3.2 KiB) Interrupt:17
That is it for this portion on setting up networking for KVM.