Bridge is what unites two or more network interfaces together. Network Bridging is mostly used in Virtualization to allow Virtual Machines access external Network.
Different tools are available for creating and configuring Network Bridge in Linux World, but they vary depending on Linux distribution you use. My favourite Linux Desktop Distribution is Arch Linux and i will show you how to easily get it working and use it in KVM Environment.
Most common tools that can be used on Arch Linux and related distributions like Manjaro include:
- brctl tool from bridge-utils package.
- netctl tool
- ip tool from iproute2 package.
- Using NetworkManager.
We’ll use netctl tool but achieve results by editing configuration file directly.In example used here, i will create a bridge called br10,then add interfaces eno1 and tap0 to the bridge. I will then demonstrate working status of the bridge by adding it to a Virtual Machine launched with KVM.
So let’s get started. First things first, let’s make sure we have bridge-utils installed, we’ll use to see details of bridge created.
Step 2: Create Bridge:
Create bridge file inside /etc/netctl/ directory. I will name my bridge kvm-bridge, any name will do just fine.
Add the following contents changing br10 with interface bridge you’re creating,eno1 and tap0 with interfaces you’re adding to the bridge, ip network information with your network details:
MACAddressOf=eno1 will make sure that the bridge interface always uses MAC address of interface eno1. If you want the bridge interface to be given unique MAC address you may remove this line. I added it because I’ve MAC address filtering in my network, making bridge br10 to have mac address of physical eno1 interface will allow me to have internet access using bridge br10.
You can bridge any combination of network devices by adding them to “BindsToInterfaces” option line.
If you would like to enable a static IP profile on wired interface no matter if the cable is connected or not, add the line below to your profile:
If you’re configuring ip address information to be obtained using DHCP protocol, then your configuration will look like below:
Below configuration will use dhcp and assign bridge MAC address of eno1 network card.
Step 2: Remove the ip of interface added to the bridge; eno1
My primary physical Ethernet interface is eno1. Since I’ve added this interface to bridge, I have to remove its ip address. You can do this either by editing network profile and adding the line:
Alternatively, you can reset the eno1 interface using NetworkManager. To do this
- Launch Network Manager application by going to All settings > Network > Interface Name
- Click on settings for your interface, mine is eno1
- Then go to Reset
- click on Forget
If you check on interfaces available on Network Manager interface, eno1 should be gone, See screenshot below:
STep 3: Start Bridge
Step 4: Set profile to start when computer boots:
If you make changes to the profile, reenable it since Changes to the profile file will not propagate to the service file automatically:
You can open NetworkManager to see if the bridge interface is working.
- Brctl command can be used to see bridges configured in the system
- To see bridged interfaces:
Up to this point, you’re ready to use the bridge on your KVM virtual machines. Open VM you want to use the bridge on, then go to its settings, NIC and specify br10. see screenshot below: