Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to build a Bridge in Ubuntu

Shulou Source: shulou.com Published: 2022-06-01 14:49:15 09月23日 Update

This article shows you how to build a bridge in Ubuntu. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Network example of bridging

In this example, eth0 and eth2 are physical network interfaces. Eth0 is connected to the local area network, and eth2 is connected to the upstream router and the Internet.

Install bridge-utils

Use the apt-get command to install bridge-utils:

$sudo apt-get install bridge-utils

Or

$sudo apt install bridge-utils

Sample output:

Create a bridge on the Ubuntu server

Modify using a text editor that you are familiar with

/ etc/network/interfaces

For example, vi or nano:

$sudo cp / etc/network/interfaces / etc/network/interfaces.bakup-1-july-2016$ sudo vi / etc/network/interfaces

Next, set up eth2 and map it to br1, enter the following (delete or comment all eth2-related configurations):

# br1 uses static public network IP address and uses ISP router as the gateway auto br1iface br1 inet static address 208.43.222.51 network 255.255.255.248 netmask 255.255.255.0 broadcast 208.43.222.55 gateway 208.43.222.49 bridge_ports eth2 bridge_stp off bridge_fd 0 bridge_maxwait 0

Next, set up eth0 and map it to br0, and enter the following (delete or comment all eth0-related configurations):

Auto br0iface br0 inet static address 10.18.44.26 netmask 255.255.255.192 broadcast 10.18.44.63 dns-nameservers 10.0.80.11 10.0.80.12 # set static route for LAN post-up route add-net 10.0.0.0 netmask 255.0.0.0 gw 10.18.44.1 post-up route add-net 161.26.0.0 netmask 255 .255.0.0 gw 10.18.44.1 bridge_ports eth0 bridge_stp off bridge_fd 0 bridge_maxwait 0

A note about br0 and DHCP

If you use DHCP, the configuration options are as follows:

Auto br0iface br0 inet dhcp bridge_ports eth0 bridge_stp off bridge_fd 0 bridge_maxwait 0

Save and close the file.

Restart the server or network service

You need to restart the server or enter the following command to restart the network service (this may not work in a SSH login session):

$sudo systemctl restart networking

If you use Ubuntu 14.04 LTS or older systems that do not have systemd, enter:

$sudo / etc/init.d/restart networking

Verify that the network configuration is successful

Use the ping/ip command to verify that the LAN and WAN network interfaces are operational:

# View br0 and br1ip a show### to view routing information ip renders # ping external site ping-c 2 cyberciti.biz### ping LAN server ping-c 2 10.0.80.12

Sample output:

The above content is how to build a bridge in Ubuntu. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Network service bridge server input configuration command routing next content local area network local area network skills interface comments knowledge network services router output authentication Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Microsoft macOS Shulou Information Huawei