Enter the following apt-get command:
$ sudo apt install bridge-utils
You need to edit the /etc/network/interface file. However, I recommend placing a fresh configuration in the /etc/network/interface.d/ directory. The process of configuring a network bridge in Debian Linux is as follows:
Use ip command:
$ ip -f inet a s
Sample output is as follows:
2: eno1: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 inet 192.168.2.23/24 brd 192.168.2.255 scope global eno1 valid_lft forever preferred_lft forever
eno1 is my physical network card.
Make sure only lo (loopback is active in /etc/network/interface). (LCTT Annotation: loopback refers to the local loopback interface, also known as the loopback address) Delete any configuration related to eno1. This is the configuration file I printed using the cat command:
$ cat /etc/network/interface # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback
Create a text file using a text editor, such as vi command:
$ sudo vi /etc/network/interfaces.d/br0
Add configuration in it:
## static ip config file for br0 ## auto br0 iface br0 inet static address 192.168.2.23 broadcast 192.168.2.255 netmask 255.255.255.0 gateway 192.168.2.254 # If the resolvconf package is installed, you should not edit # the resolv.conf configuration file manually. Set name server here #dns-nameservers 192.168.2.254 # If you have muliple interfaces such as eth0 and eth1 # bridge_ports eth0 eth1 bridge_ports eno1 bridge_stp off # disable Spanning Tree Protocol bridge_waitport 0 # no delay before a port becomes available bridge_fd 0 # no forwarding delay
If you want to use DHCP to obtain an IP address:
## DHCP ip config file for br0 ## auto br0 # Bridge setup iface br0 inet dhcp bridge_ports eno1
Save and close the file in vi/vim.
Before restarting the network service, make sure the firewall is turned off. The firewall may reference an older interface such as eno1. Once the service is restarted, you must update the firewall rules for the br0 interface. Restart the firewall by typing:
$ sudo systemctl restart network-manager
Confirm that the service has been restarted:
$ systemctl status network-manager
Find the new br0 interface and routing table with the help of ip command:
$ ip a s $ ip r $ ping -c 2 cyberciti.biz
Sample output:
You can use the brctl command to view bridge-related information:
$ brctl show
Show current bridge:
$ bridge link
The author is the creator of nixCraft and an experienced system administrator, DevOps engineer, and trainer of Linux operating systems/Unix shell scripts. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics by subscribing to the RSS/XML stream or weekly email push.
The above is the detailed content of Lao Pao'er teaches you how to configure the network bridge on Debian Linux. For more information, please follow other related articles on the PHP Chinese website!