Network
Modern Linux networking is typically managed through ip commands (from iproute2), NetworkManager (nmcli), or systemd-networkd. This note covers common tasks using these tools.
Viewing Network State
List all interfaces and their addresses:
Show the routing table:
|
|
Show active connections and listening ports:
|
|
Static IP Address
Using ip commands (temporary, lost on reboot)
Using NetworkManager (persistent)
To modify an existing connection:
Additional IP Addresses
Add a second address to an interface:
|
|
With NetworkManager:
Bridges
Create a bridge and add an interface to it:
With NetworkManager:
Spanning Tree
Disable spanning tree on a bridge (common for VM host bridges):
|
|
NIC Bonding
Create a bond with two interfaces in active-backup mode:
Common bond modes:
balance-rr(0) - Round-robin for load balancingactive-backup(1) - Only one active interface, failover802.3ad(4) - LACP, requires switch support
VLANs
Create a VLAN interface:
With NetworkManager:
Routing
Enable IP forwarding (required for any routing):
|
|
Make it persistent in /etc/sysctl.d/99-routing.conf:
|
|
Add a static route:
|
|
Useful Tools
ss- Socket statistics (replacement for netstat)ip- Network interface and routing configurationnmcli- NetworkManager command line interfaceconntrack- View/manage connection tracking entriestcpdump- Packet capturemtr- Combines traceroute and ping for network path analysis
libvirtd
libvirt is an open source API and management tool for managing platform virtualization. It is used to manage Linux KVM and Xen virtual machines through …
Linux Virtual Servers
KeepalivedMy VMs each have three interfaces, eth0 is the 'public' network network, eth1 is the 'synchronization' network, and eth2 is the 'internal' network. …
Quick and Silent Gigabit Packet Interception
I regularly find myself inspecting traffic on Linux systems. Usually I'm already on the client or server when doing this (such as when diagnosing weird low …