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. 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 or 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.
Step 1: Install Bridge tools
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.
sudo pacman -S bridge-utils
Step 2: Create Bridge:
Create bridge file inside /etc/netctl/ directory. I will name my bridge kvm-bridge, any name will do just fine.
$ sudo vim /etc/netctl/kvm-bridge
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:
Description="Bridge Interface br10 : eno1,tap0" Interface=br10 Connection=bridge BindsToInterfaces=(eno1 tap0) IP=static Address='192.168.1.105/24' Gateway='192.168.1.1' DNS='192.168.1.1' MACAddressOf=eno1 ## Ignore (R)STP and immediately activate the bridge SkipForwardingDelay=yes
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:
Description="Bridge Interface br10 : eno1,tap0" Interface=br10 Connection=bridge BindsToInterfaces=(eno1 tap0) IP=dhcp # If you want also for DHCPv6,uncomment below line #IP6=dhcp
Below configuration will use dhcp and assign bridge MAC address of eno1 network card.
Description="Bridge Interface br10 : eno1,tap0" Interface=br10 Connection=bridge BindsToInterfaces=(eno1 tap0) IP=no ExecUpPost="ip link set dev br0 address $(cat /sys/class/net/eno1/address); IP=dhcp; ip_set" ExecDownPre="IP=dhcp"
Step 3: 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 4: Start Bridge
sudo netctl start kvm-bridge
Step 5: Set profile to start when computer boots:
sudo netctl enable kvm-bridge
If you make changes to the profile, reenable it since Changes to the profile file will not propagate to the service file automatically:
sudo netctl reenable kvm-bridge
You can open NetworkManager to see if the bridge interface is working.
- Brctl command can be used to see bridges configured in the system
$ sudo brctl show bridge name bridge id STP enabled interfaces br10 8000.a01d48fad8df no eno1 virbr0 8000.5254007baa03 yes virbr0-nic
- To see bridged interfaces:
$ sudo bridge link 2: eno1 state UP : <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 master br10 state forwarding priority 32 cost 19 5: virbr0-nic state DOWN : <BROADCAST,MULTICAST> mtu 1500 master virbr0 state disabled priority 32 cost 100
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:
There you have it. Network bridge has been configured on Arch Linux / Manjaro system.