This article will describe creating bridge interface of ethernet. This makes that other machines in network can connect to virtual machines on KVM via network.
Table of Contents
1 Install bridge-utils package
Install bridge-utils package before creating bridge.
$ sudo yum install -y bridge-utils
2 Network interfaces of before creating bridge
Network interfaces of before creating bridge is as below.
$ ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.11.92 netmask 255.255.255.0 broadcast 192.168.11.255 inet6 fe80::5054:ff:fe86:9b9a prefixlen 64 scopeid 0x20<link> ether 52:54:00:86:9b:9a txqueuelen 1000 (Ethernet) RX packets 106 bytes 13910 (13.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 101 bytes 13430 (13.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 4 bytes 340 (340.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4 bytes 340 (340.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
3 Create bridge
ifcfg-eth0 before creating bridge is as below.
$ cat /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE="Ethernet" BOOTPROTO="dhcp" DEFROUTE="yes" PEERDNS="yes" PEERROUTES="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_PEERDNS="yes" IPV6_PEERROUTES="yes" IPV6_FAILURE_FATAL="no" NAME="eth0" UUID="e7765049-e76f-4dc5-8347-db5d4c7b0c8d" DEVICE="eth0" ONBOOT="yes"
Copy ifcfg-eth0 to ifcfg-br0. Modify ifcfg-br0 as below.
- Make TYPE to Bridge.
- Erase UUID.
- Make NAME and DEVICE to br0.
$ cat /etc/sysconfig/network-scripts/ifcfg-br0 TYPE="Bridge" BOOTPROTO="dhcp" DEFROUTE="yes" PEERDNS="yes" PEERROUTES="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_PEERDNS="yes" IPV6_PEERROUTES="yes" IPV6_FAILURE_FATAL="no" NAME="br0" DEVICE="br0" ONBOOT="yes"
Create new ifcfg-eth0.
- Make HWADDR to 52:54:00:86:9b:9a which is displayed by ifconfig.
- Make BRIDGE to br0.
$ cat /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE="Ethernet" HWADDR="52:54:00:86:9b:9a" NAME="eth0" DEVICE="eth0" ONBOOT="yes" BRIDGE="br0"
Restart network service.
$ sudo systemct restart network
4 Network interfaces of after creating bridge
br0 which has the same MAC address with eth0 is created. IP address is assigned to br0.
$ ifconfig br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.11.92 netmask 255.255.255.0 broadcast 192.168.11.255 inet6 fe80::5054:ff:fe86:9b9a prefixlen 64 scopeid 0x20<link> ether 52:54:00:86:9b:9a txqueuelen 0 (Ethernet) RX packets 35 bytes 2924 (2.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 45 bytes 6341 (6.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 52:54:00:86:9b:9a txqueuelen 1000 (Ethernet) RX packets 796 bytes 75769 (73.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 502 bytes 79165 (77.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 12 bytes 1020 (1020.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 12 bytes 1020 (1020.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0