Interfaces/Bridge, IPv4/IPv6 Addressing
Network interfaces are the points of connection between a host and a network. Linux provides a rich set of tools for configuring, bonding, bridging, and virtualising network interfaces.
Network Interfaces
Every network interface in Linux is represented by a kernel interface object. Physical interfaces correspond to hardware NICs; virtual interfaces are created in software.
List interfaces with ip:
ip link show ip addr show
Common Interface Types
- eth0, enp0s3: Physical Ethernet interfaces.
- wlan0, wlp2s0: Wireless interfaces.
- lo: Loopback interface (127.0.0.1).
- docker0, br0: Virtual bridges.
- veth0: Virtual Ethernet pairs (used by containers).
- tun0, tap0: Tunnels (VPN).
- bond0: Bonded interfaces (link aggregation).
- vlan10: VLAN-tagged interfaces.
Configuring Interfaces
ip addr add 192.168.1.10/24 dev eth0 ip link set eth0 up ip route add default via 192.168.1.1
Persistent configuration is typically managed by NetworkManager, systemd-networkd, or netplan.
Bridges
A bridge connects multiple network segments at the data link layer (Layer 2). It makes multiple interfaces appear as a single interface, forwarding frames between them.
Create a bridge:
ip link add name br0 type bridge ip link set eth0 master br0 ip link set eth1 master br0 ip addr add 192.168.1.10/24 dev br0 ip link set br0 up
Bridges are commonly used with virtual machines and containers.
Bonding (Link Aggregation)
Bonding combines multiple physical interfaces into a single logical interface for redundancy or increased bandwidth.
Common modes:
- active-backup: One interface active, others standby.
- balance-rr: Round-robin distribution.
- 802.3ad (LACP): Link Aggregation Control Protocol (requires switch support).
ip link add name bond0 type bond mode active-backup ip link set eth0 master bond0 ip link set eth1 master bond0
IPv4 Addressing
IPv4 addresses are 32-bit numbers, typically written in dotted-decimal notation (e.g., 192.168.1.10).
Address Classes
- Class A: 1.0.0.0 to 126.255.255.255 (large networks).
- Class B: 128.0.0.0 to 191.255.255.255 (medium networks).
- Class C: 192.0.0.0 to 223.255.255.255 (small networks).
Private Address Ranges
Private addresses are not routed on the public internet:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
Subnetting
A subnet mask divides an IP address into network and host portions. CIDR notation combines address and mask: 192.168.1.0/24.
IPv6 Addressing
IPv6 addresses are 128-bit numbers, written in hexadecimal with colons (e.g., 2001:db8::1).
Address Types
- Global Unicast: Publicly routable addresses.
- Link-Local:
fe80::/10, automatically configured on every interface. - Unique Local:
fc00::/7, similar to IPv4 private addresses. - Loopback:
::1, equivalent to 127.0.0.1. - Multicast:
ff00::/8, for one-to-many communication.
IPv6 Autoconfiguration
IPv6 supports Stateless Address Autoconfiguration (SLAAC), where hosts generate their own addresses using router advertisements:
sysctl net.ipv6.conf.eth0.accept_ra=1
Related Articles
- OSI model: Article - OSI network model
- Protocols: Article - Main protocols: ARP, ICMP, UDP, TCP
- Routing: Article - Routing