How to set up the network bridge in Ubuntu

Source: Internet
Author: User

As a beginner of Ubuntu 16.04 LTS. How do I build a network bridge on Ubuntu 14.04 and 16.04 hosts?

As the name suggests, the role of the network Bridge is to connect the internal and external network through the physical interface. This is useful for virtual ports or lxc/kvm/xen/containers. The Network Bridge virtual port appears to be a regular device on the network. In this tutorial, I'll explain how to configure the Linux bridge on the Ubuntu server via the bridge-utils (BRCTL) command line.

Network-Bridged Networks example


In this example, eth0 and eth1 are physical network interfaces. The eth0 is connected to the LAN, and the eth1 is connected to the upstream router and the Internet.

Install Bridge-utils

To install bridge-utils using the Apt-get command:

$ sudo apt-get install Bridge-utils
Or

$ sudo apt install bridge-utils

Sample output:


Create a network bridge on an Ubuntu server

Use your familiar text editor to modify/etc/network/interfaces, such as VI or nano:

$ sudo cp/etc/network/interfaces/etc/network/interfaces.bakup-1-july-2016
$ sudo vi/etc/network/interfaces
Next, set eth1 and map it to BR1, and enter the following (delete or annotate all eth1 related configurations):

### BR1 uses a static public IP address and takes the ISP router as the Gateway
Auto BR1
iface br1 inet static
      &nb Sp 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 eth1
        bridge_stp off
         bridge_fd 0
        bridge_maxwait 0
Next set Eth0 and map it to BR0, enter the following (delete or annotate 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 little description of Br0 and DHCP

If you are using DHCP, this is the configuration option:

Auto Br0
Iface br0 inet DHCP
Bridge_ports eth0
BRIDGE_STP off
BRIDGE_FD 0
Bridge_maxwait 0
Save and close the file.

Restarting a server or network service

You need to reboot the server or enter the following command to restart the Network service (this may not work in an SSH logon session):

$ sudo systemctl restart networking
If you are using an Ubuntu 14.04 LTS or older system with no systemd, enter:

$ Sudo/etc/init.d/restart Networking
Verifying Network configuration Success

Use the PING/IP command to verify that the LAN and WAN network interfaces are functioning:

### 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:

Now you can configure BR0 and BR1 to allow XEN/KVM/LXC containers to access the Internet or private LAN. There is no need to set a particular routing or iptables SNAT rule anymore.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.