On-prem servers must deal with different challenges that Cloud providers magically take care of and make it look very easy.

  • Network Bridge
    • Make Linux works as a layer2 switch forwarding frames based on a local ARP table per interface.
  • Link Aggregation
    • Combine the speed of multiple network interfaces as a single interface with fault tolerance to hardware issues.
  • VLAN
    • A Linux server can work as a router between multiple VLANs or simply serve over multiple sub-networks.

NETWORK BRIDGE

sudo apt install bridge-utils -y
sudo brctl addbr br0
sudo brctl addif br0 eth0 eth1
ip addr show

Configuring bridging using /etc/network/interfaces:

# Set up interfaces manually:
iface eth0 inet manual
iface eth1 inet manual

# set up the Bridge interface:
iface br0 inet static
  bridge_ports eth0 eth1
    address 192.168.1.2
    broadcast 192.168.1.255
    netmask 255.255.255.0
    gateway 192.168.1.1

There are additional configurations that might be applicable to your scenario:

  • bridge_stp off
    • Disable Spanning Tree Protocol
  • bridge_waitport 0
    • No delay before a port becomes available
  • bridge_fd 0
    • No forwarding delay
  • bridge_ports regex eth*
    • Use a regular expression

LINK AGGREGATION

Configuring LACP using /etc/network/interfaces:

auto bond0
iface bond0 inet manual
    up ifconfig bond0 0.0.0.0 up
    slaves eth0 eth1 eth2 eth3
    bond-mode 4      # 4 = 802.3ad
    bond-miimon 100
    bond-downdelay 200
    bond-updelay 200
    bond-lacp-rate 1
    bond-xmit-hash-policy layer2+3

Configure LACP Bonding Using Netplan.

network:
 version: 2
 renderer: networkd
 ethernets:
   eports:
     match: 
       name: eth*
 bonds:
   bond0:
     interfaces: [eports]
     addresses: [10.0.0.1/24]
     gateway4: 10.0.0.1
     nameservers:
       search: [domain.local]
       addresses: [8.8.8.8]
     parameters:
       mode: 802.3ad
       lacp-rate: fast
       mii-monitor-interval: 100

Apply the configuration:

sudo netplan apply

VLAN

Configure VLAN via command line non-persistently:

sudo apt install vlan
modprobe --first-time 8021q
modinfo 8021q
sudo ip link add link eth0 name eth0.100 type vlan id 100
sudo ip addr add 192.168.1.2/24 dev eth0.100

Configure VLAN with Netplan.

Edit the file(s) in the directory /etc/netplan/ accordingly:

network:
  ethernets:
    eth0:
      dhcp4: true
    vlans:
        eth0.100:
            id: 100
            link: eth0
            addresses: [192.168.10.10/24]

And restart the network service.

sudo systemctl restart systemd-networkd

Configure Vlan with ifconfig

sudo apt install net-tools -y

Add the following line to the file /etc/network/interfaces

auto eth0.100
iface eth0.100 inet static
address 192.168.10.10
netmask 255.255.255.0
vlan-raw-device eth0.100

Then, light it up:

sudo ifconfig eth0.100 up