Skip to content

Instantly share code, notes, and snippets.

@datacustodian
Last active April 16, 2017 12:06
Show Gist options
  • Save datacustodian/af6ded85fd7f2d7f099408d8511d0e32 to your computer and use it in GitHub Desktop.
Save datacustodian/af6ded85fd7f2d7f099408d8511d0e32 to your computer and use it in GitHub Desktop.
Setting up bridge network on Ubuntu

Setting up bridge network on Ubuntu

Edit /etc/network/interfaces in a text editor.

DEFAULT

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

SIMPLEST (DHCP)

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto br0
iface br0 inet dhcp
    bridge_ports eth0

iface eth0 inet manual

STATIC

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto br0 
iface br0 inet static
    address 192.168.0.44
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1
    # dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 8.8.8.8 8.8.4.4 #google-dns
    dns-search localdomain.local #optional-line
    # bridge options
    bridge_ports eth0
    
iface eth0 inet manual

Restart the interfaces. Note that this will disconnect SSH sessions, so physical access to the machine/VM is required.

sudo ifdown eth0 && sudo ifup eth0 && sudo ifup br0

To restart networking without disconnecting the SSH seesion, try:

sudo /etc/init.d/networking restart

Run ifconfig on the CLI to confirm the changes have been applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment