Chapter 19. Routing, Bridges, VLANs, and VPNs

Chapter 17 configured one host's links, addresses, and default route, and Chapter 18 filtered the packets that cross a single box. This chapter is about the network between hosts: making a Debian system forward between several networks, letting routing protocols keep route tables correct without manual edits, dividing one physical link into several virtual LANs, combining physical links into one logical link, and joining separate sites or remote users with encrypted tunnels. The same inspection tools carry through all of it - ip, ping, traceroute, the journal - and the same discipline applies: temporary changes with ip for experiments, persistent changes in configuration files, verification after every step.

The chapter builds one lab of four Debian 13 machines and keeps it running through all seven sections. Static routes and policy routing come first, then FRRouting runs OSPF and BGP between the routers, then VLANs, bridges, and bonds reorganize the layer-2 fabric, and finally WireGuard and OpenVPN carry traffic across the administration network. The last section reboots everything and verifies that the whole topology returns on its own, which is the actual test of configuration written to disk rather than typed into a kernel.

The four machines, their roles, and their practice interfaces:

Host Role Practice interfaces
rtrouter router; FRR AS 65001 eth0 - administration, 192.168.121.117/24; eth1 - LAN A, 192.168.219.2/24; eth2 - LAN B, 192.168.220.2/24; eth3 - transit, 192.168.221.2/24; eth4 - trunk, 192.168.222.2/24
rtclient client and layer-2 endpoint eth0 - administration, 192.168.121.229/24; eth1 - LAN A, 192.168.219.10/24; eth2 - trunk, 192.168.222.10/24; eth3, eth4 - bond members, no addresses; eth5 - bridge port, no address
rtserver server and layer-2 endpoint eth0 - administration, address assigned by DHCP; eth1 - LAN B, 192.168.220.10/24, runs dnsmasq for server.ch19.example; eth2 - trunk, 192.168.222.20/24; eth3, eth4 - bond members; eth5 - bridge port
rtpeer FRR AS 65002; VPN server eth0 - administration, 192.168.121.49/24; eth1 - transit, 192.168.221.20/24; eth2 - LAN B, 192.168.220.20/24; dummy0 - 198.51.100.1/24, an advertised test network

The chapter 19 practice network

Figure 19.1. Six isolated practice networks connect the four hosts. The administration network carries SSH and, in Section 19.5 onward, the encrypted tunnels; no exercise depends on it for practice traffic.

Every host's eth0 sits on the administration network 192.168.121.0/24, carries the default route, and is where SSH arrives. Practice links live on six other isolated networks: LAN A (192.168.219.0/24), LAN B (192.168.220.0/24), the transit network (192.168.221.0/24), a trunk that later carries VLAN 219 (192.168.222.0/24), the bond network (192.168.223.0/24), and the bridge network (192.168.224.0/24). Addresses come from RFC 1918 private space and the documentation blocks 198.51.100.0/24 and 203.0.113.0/24, so nothing here can disturb a real network. This is the same out-of-band arrangement a production site builds with a separate management VLAN: Section 19.7 deliberately breaks practice links while administration keeps working.

Commands entered in john's ordinary shell begin with $ and commands entered in a root shell begin with #; the prompt marker is not typed. Where a single elevated command is more natural than a root shell, it is written $ sudo command, which asks for john's password the first time in a session (the password is not echoed). This chapter runs its elevated steps exactly that way - one $ sudo command at a time from john's ordinary shell - so no block below carries the # marker; a sustained root shell entered with $ sudo -i and left with exit remains available, as Chapter 17 showed. Every host has the john account with sudo access, established during installation (Chapter 2) and governed as Chapter 5 describes. Except where a block or its introduction names another host, commands run on the host the surrounding prose identifies, and every host switch is announced. Editing files uses the terminal editor from Chapter 3.

Create the workspace before the first example, on each of the four hosts. Configuration files being staged for /etc, key material, VPN profiles, and everything else john creates stay under it:

$ mkdir -p ~/debian-handbook/routing

The command prints nothing when it succeeds. Make it the working directory with cd ~/debian-handbook/routing; the relative paths used throughout the chapter are written from inside it. Interface and route inspection come from Chapter 17; nftables from Chapter 18; systemd services, networkctl, and the journal from Chapter 8 and Section 17.3.3; sysctl persistence from Chapter 7. Building the DNS and DHCP services a production site would run is Chapter 22's subject; attaching virtual machines to the bridges built here is Chapter 24's; hardened remote administration over the administration network is Chapter 20's.

The starting state matches Section 17.3.3's systemd-networkd layout: one .network drop-in per practice link, carrying only its address. The router's eth1 file is representative:

# /etc/systemd/network/10-ch19-eth1.network
[Match]
Name=eth1

[Network]
Address=192.168.219.2/24
ConfigureWithoutCarrier=yes

The other files differ only in Name= and Address= and follow the table above; the 10-ch19- prefix groups them so the whole chapter's configuration can be listed or removed at once. Every file sets ConfigureWithoutCarrier=yes so a link without a peer still receives its address, which keeps the exercises independent of cable timing. rtpeer's dummy0 uses the same pattern with a .netdev that creates the device itself:

# /etc/systemd/network/10-ch19-dummy0.netdev
[NetDev]
Name=dummy0
Kind=dummy
# /etc/systemd/network/10-ch19-dummy0.network
[Match]
Name=dummy0

[Network]
Address=198.51.100.1/24

One host runs two configuration backends at once. rtclient keeps NetworkManager for the desktop-style VPN profile imported in Section 19.6.2, while its practice links stay with systemd-networkd. That is only safe because each practice device is marked unmanaged, exactly the single-owner rule from Section 17.2.2:

# /etc/NetworkManager/conf.d/99-ch19-unmanaged.conf
[keyfile]
unmanaged-devices=interface-name:eth1;interface-name:eth2;interface-name:eth3;interface-name:eth4;interface-name:eth5;interface-name:bond0;interface-name:br0;interface-name:br0.219;interface-name:eth2.219;interface-name:eth5.219;interface-name:wg0;interface-name:wg1;interface-name:tun0;interface-name:dummy0

With that file installed and NetworkManager restarted, the two backends never touch the same link, and every interface this chapter creates later is already on the list.

In this section