Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a bridge over Ubuntu

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to build a bridge on Ubuntu". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "how to build a bridge on Ubuntu".

Network example of bridging

Figure 01: Kvm/Xen/LXC Container Bridge example (br0)

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:

Figure 02: Ubuntu installs the bridge-utils package

Create a bridge on the Ubuntu server

Modify / etc/network/interfaces using a text editor you are familiar with, such as 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 br1 iface 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 br0 iface 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 br0 iface 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 br1 ip a show # View routing information ip r # ping external site ping-c 2 cyberciti.biz # ping LAN server ping-c 2 10.0.80.12

Sample output:

Figure 03: verify the Ethernet connection of the bridge

Now you can configure br0 and br1 to allow XEN/KVM/LXC containers to access the Internet or private Lans. It is no longer necessary to set SNAT rules for specific routes or iptables.

The above is all the contents of the article "how to build a Bridge on Ubuntu". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report