Home > System Tutorial > LINUX > body text

Lao Pao'er teaches you how to configure the network bridge on Debian Linux

PHPz
Release: 2024-06-28 03:15:02
Original
813 people have browsed it

老炮儿教你在 Debian Linux上配置网桥

How to install brctl

Enter the following apt-get command:

$ sudo apt install bridge-utils
Copy after login
How to set up a network bridge on Debian Linux

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:

Step 1 - Find out your physical interface

Use ip command:

$ ip -f inet a s
Copy after login

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
Copy after login

eno1 is my physical network card.

Step 2 - Update /etc/network/interface file

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
Copy after login
Step 3 - Configure the bridge (br0) in /etc/network/interfaces.d/br0

Create a text file using a text editor, such as vi command:

$ sudo vi /etc/network/interfaces.d/br0
Copy after login

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
Copy after login

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
Copy after login

Save and close the file in vi/vim.

Step 4 - Restart Network Services

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
Copy after login

Confirm that the service has been restarted:

$ systemctl status network-manager
Copy after login

Find the new br0 interface and routing table with the help of ip command:

$ ip a s $ ip r $ ping -c 2 cyberciti.biz
Copy after login

Sample output:
老炮儿教你在 Debian Linux上配置网桥

You can use the brctl command to view bridge-related information:

$ brctl show
Copy after login

Show current bridge:

$ bridge link
Copy after login
About the author

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!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!