On-prem servers must deal with challenges that cloud providers handle behind the scenes.
- Network Bridge
- Makes Linux work as a layer 2 switch, forwarding frames based on a local ARP table per interface.
- Link Aggregation
- Combines multiple network interfaces into a single interface for increased throughput and hardware fault tolerance.
- VLAN
- A Linux server can route traffic between multiple VLANs or serve across 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
bridge-stp off
bridge-fd 0
address 192.168.1.2
broadcast 192.168.1.255
netmask 255.255.255.0
gateway 192.168.1.1
Additional options that may apply to your setup:
- 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*
- Match ports using a regular expression
LINK AGGREGATION
Configuring LACP using /etc/network/interfaces:
sudo apt install ifenslave -y echo "bonding" | sudo tee -a /etc/modules modprobe bonding sudo nano /etc/network/interfaces
auto bond0
iface bond0 inet static
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
bond-mode 802.3ad
bond-miimon 100
bond-lacp-rate fast
bond-slave eth0 eth1
bond-downdelay 200
bond-updelay 200
bond-lacp-rate 1
bond-xmit-hash-policy layer2+3
allow-hotplug eth0
auto eth0
iface eth0 inet manual
allow-hotplug eth1
auto eth1
iface eth1 inet manual
sudo systemctl restart networking cat /proc/net/bonding/bond0
Configuring 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:
netplan status --diff --all sudo netplan apply cat /proc/net/bonding/bond0
VLAN
Configure a VLAN via the command line (non-persistent):
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 a VLAN using Netplan.
Edit the relevant file(s) in /etc/netplan/:
network:
ethernets:
eth0:
dhcp4: true
vlans:
eth0.100:
id: 100
link: eth0
addresses: [192.168.10.10/24]
Then restart the network service:
sudo systemctl restart systemd-networkd
Configure a VLAN using ifconfig:
sudo apt install net-tools -y
Add the following to /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 bring the interface up:
sudo ifconfig eth0.100 up