“Bridge (br0) interface on Ubuntu 16.04 LTS Server Edition”

ubuntu-16-04-lts

UBUNTU SERVER

What is a bridged?

A Bridged networking is nothing but a simple technique to connect to the outside network through the physical interface. It is useful for LXC/KVM/Xen/Containers virtualization and other virtual interfaces. The virtual interfaces appear as regular hosts to the rest of the network. In this tutorial I will explain how to configure a Linux bridge with bridge-utils (brctl) command line utility on Ubuntu server.

Our sample bridged networking

Fig.01: Sample Ubuntu Bridged Networking Setup For Kvm/Xen/LXC Containers (br0)
In this example eth0 and eth1 is the physical network interface. eth0 connected to the LAN and eth1 is attached to the upstream ISP router/Internet.

01 STEP – INSTALL BRIDGE-UTILS

Type the following apt-get command to install the bridge-utils:

$: sudo apt install bridge-utils

02 STEP – CREATING A PERMANENT NETWORK BRIDGE

Edit /etc/network/interface:

$: sudo cp /etc/network/interfaces /etc/network/interfaces.bck
$: sudo nano /etc/network/interfaces

If the bridge br0 is to be assigned an IP address by DHCP:

auto ens33
iface ens33 inet manual

auto br0
iface br0 inet dhcp
    bridge_ports  ens33

If the bridge br0 is to be assigned a static IP address:

auto ens33
iface ens33 inet manual

auto br0
iface br0 inet static
        address 1.1.10.6
        netmask 255.255.255.0
        network 1.1.10.0
        broadcast 1.1.10.255
        gateway 1.1.10.2
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 8.8.8.8 8.8.4.4 
        dns-search localdomain.local 
        # bridge options
        bridge_ports ens33

Save and close the file, while on our VMware Fusion the network is

Screen Shot 2016-11-04 at 22.34.38.png

03 – RESTART THE NETWORK SERVICE

to restart the networking service

$: sudo reboot

Use the ping/ip commands to verify that both LAN and WAN interfaces are reachable:

# See br0
$: ip a show
# See routing info
$:  ip r
# ping public site
$: ping -c 2 cyberciti.biz
# ping lan server
$: ping -c 2 10.0.80.12

Sample outputs:

Fig.03: Verify Bridging Ethernet Connections

Now if we want, we can configure a LXC containers to use br0 to reach directly Internet or LAN.


“cya to the next 1…. Njoy !”
bye dakj

Disclaimer: All the tutorials included on this site are performed in a lab environment to simulate a real world production scenario. As everything is done to provide the most accurate steps to date, we take no responsibility if you implement any of these steps in a production environment.

“We learn from our mistakes”

Advertisements