Debian Networking Part 4 - Bridges

 Bridging

One of the most common situations for bridging setups is when passing networking to VMs. Most of the time, the VM can simply be passed straight through from the host's main interface.

# Debian network configuration for two bridged interfaces
# Copy into /etc/network/interfaces
#
# Prerequisites:
#        apt install brctl

# Loopback interface
auto lo
iface lo inet loopback

# Default primary network interface
iface eth0 inet manual

# The network bridge
auto br0
iface br0 inet static
    bridge_ports eth0
    bridge_stp off
    bridge_fd 0
    address 192.168.0.2
    netmask 255.255.255.0
    gateway 192.168.0.1
    dns-nameservers 1.1.1.1 1.0.0.1
    pre-up ifup eth0
    post-down ifdown eth0

It is possible to also have no interfaces bridged together, which is useful when making a machine-only network for local VMs.

# Debian network configuration for two bridged interfaces
# Copy into /etc/network/interfaces
#
# Prerequisites:
#        apt install brctl

# Loopback interface
auto lo
iface lo inet loopback

# Default primary network interface
iface eth0 inet manual

# The network bridge
auto br0
iface br0 inet static
    bridge_ports eth0
    bridge_stp off
    bridge_fd 0
    address 192.168.0.2
    netmask 255.255.255.0
    gateway 192.168.0.1
    dns-nameservers 1.1.1.1 1.0.0.1
    pre-up ifup eth0
    post-down ifdown eth0

# The local-only bridge
auto br1
iface br1 inet manual
   birdge_ports none
   bridge_stp off
   bridge_fd 0

Finally, VLAN tags can be passed through the bridge with another flag, for use with VM heads to access multiple networks while still maintaining isolation of the networking for all VMs.

# Debian network configuration for two bridged interfaces
# Copy into /etc/network/interfaces
#
# Prerequisites:
#        apt install brctl

# Loopback interface
auto lo
iface lo inet loopback

# Default primary network interface
iface eth0 inet manual

# The network bridge
iface br0 inet manual
    bridge_ports eth0
    bridge_stp off
    bridge_fd 0
    bridge_vlan_aware yes
    pre-up ifup eth0
    post-down ifdown eth0

# VLANs
auto br0.2
iface br0.2 inet static
   address 192.168.1.2
   netmask 255.255.255.0
   gateway 192.168.1.1
   dns-nameservers 1.1.1.1 1.0.0.1

ARM SBCs - My favorite computers

Debian Networking Part 3 - VLANs