Sometimes you may need to create network bridge adapter in Linux; specially during the settings of KVM (Kernel-based virtual Machine), and, also while setting up Linux system bins.
This bridge network allows virtual machines to have access to the external network and vice-versa, follow this guide to create network bridge on CentOS 7 / RHEL7.
A bridge interface is actually a virtual interface handled by a config file on your Linux system. Creating a bridge is quite simple, just follow those steps and you’re all set!
CentOS 7 comes with bridging module loaded on system boot by default, verify it by using below command.
# modinfo bridge filename: /lib/modules/3.10.0-327.el7.x86_64/kernel/net/bridge/bridge.ko
If the module is not loading, you can load it using the following command:
# modprobe --first-time bridge
Install bridge-utils for controlling the network adapters.
# yum install bridge-utils -y
Create a Network Bridge:
Now its time To create a network bridge, create a file called “ifcfg-virbrN” replacing “N” with a number, such as “0” in the “/etc/sysconfig/network-scripts/“.
File doesn’t needs to be “virbrN“, you can also give a name like “brN”
# nano /etc/sysconfig/network-scripts/ifcfg-virbr0
Place the following content into that file, modify it according to your environment.
DEVICE="virbr0" BOOTPROTO="static" IPADDR="192.168.12.10" NETMASK="255.255.255.0" GATEWAY="192.168.12.2" DNS1=192.168.12.2 ONBOOT="yes" TYPE="Bridge" NM_CONTROLLED="no"
Now, it’s the time to modify the network configuration of the existing adapter in such a way that it points to a bridge interface.
# nano /etc/sysconfig/network-scripts/ifcfg-eto16886627
Place the content like below.
DEVICE=eto16886627 TYPE=Ethernet BOOTPROTO=none ONBOOT=yes NM_CONTROLLED=no BRIDGE=virbr0
Restart the network using the following command.
# systemctl restart network
Use ifconfig command to see interface details.
That’s all you have to do, Please Give your opinion below if you experience any issues or to discuss your ideas and experiences.