Configure Network Bridge on Ubuntu Debian Linux
This post will guide you how to setup and configure a network interface bridge on Ubuntu or Debian Linux system. How do I create a network bridge based on an existing network interface on Ubuntu Linux.
Configure Network Bridge on Ubuntu Debian Linux
If you want to create a network bridge, and you need to find one network interface, and then update one configuration file called /etc/network/interface. Just do the following steps:
#1 Install brctl package
Type the following command:
# apt-get install bridge-utils
Outputs:
root@ubuntu-dev:~# apt-get install bridge-utils Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: bridge-utils 0 upgraded, 1 newly installed, 0 to remove and 480 not upgraded. Need to get 28.6 kB of archives. After this operation, 102 kB of additional disk space will be used. Get:1 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 bridge-utils amd64 1.5-9ubuntu1 [28.6 kB] Feched 28.6 kB in 4s (5,753 B/s) Selecting previously unselected package bridge-utils. (Reading database ... 179571 files and directories currently installed.) Preparing to unpack .../bridge-utils_1.5-9ubuntu1_amd64.deb ... Unpacking bridge-utils (1.5-9ubuntu1) ... Processing triggers for man-db (2.7.5-1) ... Setting up bridge-utils (1.5-9ubuntu1) ...
#2 create network bridge br0
If you want to create a network bridge br0 based on the network interface enp0s3, you need to create an configuration file called bro, and placed it in /etc/network/interfaces.d/ directory.
Create br0 file via vim editor:
# vim /etc/network/interfaces.d/br0
Adding the following lines into the file.
# For the bootproto as static
auto br0 iface br0 inet static address 192.168.1.199 broadcast 192.168.1.255 netmask 255.255.255.0 gateway 192.168.1.1 bridge_ports enp0s3 bridge_stp off bridge_waitport 0 bridge_fd 0
# For the bootproto as DHCP
auto br0 iface br0 inet dhcp bridge_ports enp0s3
#3 restart the network service
After updated the configuration file, and you need to restart the network service, type:
# systemctl restart network.service
#4 show bridge
# brctl show