19.7. Operating Complex Network Topologies
Everything built so far works while someone is watching. This last section is about the parts that only fail when nobody is: boot-time ordering, disruptive tests on secondary links, and following a packet through a topology that no single command can see end to end.
19.7.1. Persisting Interface Dependencies Across Reboots
Nothing in this chapter configured interfaces "in order", and that is
the point: the dependency graph lives in the files themselves, and
systemd-networkd walks it at boot. A .netdev names its kind; a
members file's Bond= or a port file's Bridge= claims the upper
layer; a parent's VLAN= creates the sub-interface; [Match]
sections on file names bind everything to devices as udev produces
them. The drop-in inventory after all sections have run:
| Host | /etc/systemd/network/ drop-ins |
Upper layers |
|---|---|---|
| rtrouter | 10-…-eth1 (policy rules), 10-…-eth2 (table 100 route), 10-…-eth3 (table 200 route), 10-…-eth4 |
- |
| rtclient | 10-…-eth1 (static routes), 10-…-eth2 (parent of VLAN), 20-…-vlan219.netdev + 20-…-vlan219.network, 30-…-br0.netdev + port + address, 40-…-bond0.netdev + members + address |
eth2.219, br0, bond0 |
| rtserver | 10-…-eth1 (static routes), 10-…-eth2, 20-…-vlan219.*, 30-…-br0.*, 40-…-bond0.* |
eth2.219, br0, bond0 |
| rtpeer | 10-…-eth1, 10-…-eth2, 10-…-dummy0.netdev + network |
dummy0 |
The numbering (10-, 20-, 30-, 40-) groups the files for
humans - networkd reads them all and resolves dependencies itself -
and it makes the whole chapter's footprint one shell glob
(/etc/systemd/network/*ch19*) when the practice setup is retired.
The test is a reboot of all four hosts. The command itself is anticlimactic - on rtclient, as john:
$ sudo systemctl reboot
Connection to 192.168.121.229 closed by remote host.
The SSH client reports the session ending as the machine goes down; rtrouter, rtserver, and rtpeer get the same command (their sessions close the same way or simply drop). SSH returns a minute later on each host - the administration network never participated in any exercise, so nothing had to survive for it to work.
Then walk the whole chapter in kernel state. On rtrouter, as john, the links, including the tunnel that must come back on its own:
$ ip -br addr
lo UNKNOWN 127.0.0.1/8 ::1/128
eth0 UP 192.168.121.117/24 fe80::5054:ff:fedf:6221/64
eth1 UP 192.168.219.2/24 fe80::5054:ff:fe4b:42fc/64
eth2 UP 192.168.220.2/24 fe80::5054:ff:fe8e:c7d0/64
eth3 UP 192.168.221.2/24 fe80::5054:ff:fe1e:737/64
eth4 UP 192.168.222.2/24 fe80::5054:ff:fe23:ecd/64
wg0 UNKNOWN 10.19.0.1/24
The policy rules from Section 19.1.3, rebuilt from the .network
files:
$ ip rule show
0: from all lookup local
100: from 192.168.219.0/24 lookup 100 proto static
200: from 192.168.220.0/24 lookup 200 proto static
32766: from all lookup main
32767: from all lookup default
Forwarding, from the sysctl drop-in:
$ sudo sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
On rtclient, as john, the layered interfaces each came back - the VLAN:
$ ip -br addr show eth2.219
eth2.219@eth2 UP 10.19.219.10/24 fe80::5054:ff:fed0:957e/64
and the bond - the complete proc file, which also shows which member active-backup picked this boot:
$ cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v6.12.86+deb13-amd64
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth4
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0
Slave Interface: eth4
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 52:54:00:c8:e6:74
Slave queue ID: 0
Slave Interface: eth3
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 52:54:00:e4:48:0b
Slave queue ID: 0
Both members are up again, and eth4 happens to be the active one -
without Primary= in the [Bond] section, whichever member joins
first after boot takes the role, the same race Section 19.4.2 sidestepped
by admitting the members one at a time, and a fact worth knowing before
assuming a cable moved. The bridge returned with its port forwarding,
the tagged and untagged pings both answer, and the rest of the
inventory can be checked the same way:
| Check (host, as john) | Expected result |
|---|---|
ip -br addr show br0 on rtclient |
192.168.224.10/24, port forwarding under bridge link show |
ping -c 2 10.19.219.20 on rtclient |
ttl=64, two replies |
ping -c 2 192.168.223.20 on rtclient |
two replies - bond path |
ping -c 2 192.168.224.20 on rtclient |
two replies - bridge path |
ip route show table 100 on rtrouter |
198.51.100.1 via 192.168.220.20 dev eth2 proto static |
The dynamic protocols had to find each other again from scratch. On rtrouter, as john, the OSPF adjacency reformed on its own timers:
$ sudo vtysh -c "show ip ospf neighbor"
Neighbor ID Pri State Up Time Dead Time Address Interface RXmtL RqstL DBsmL
10.19.255.2 1 Full/- 46.570s 3.027s 192.168.221.20 eth3:192.168.221.2 0 0 0
BGP re-established and re-learned its one prefix:
$ sudo vtysh -c "show bgp summary"
IPv4 Unicast Summary:
BGP router identifier 10.19.255.1, local AS number 65001 VRF default vrf-id 0
BGP table version 4
RIB entries 3, using 384 bytes of memory
Peers 1, using 23 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
192.168.221.20 4 65002 45 43 4 0 0 00:00:49 1 1 N/A
Total number of neighbors 1
The Up/Down column is the whole story: 49 seconds old, which means
the session ended and restarted when the machines booted, and
reached Established with policy intact - one prefix in, one out.
The WireGuard site tunnel, enabled as a systemd instance in
Section 19.5.4, and its keepalive session:
$ sudo wg show
interface: wg0
public key: UvZjldYteq3cULo4AEWp1f0YJY1cSiTzsnKVLqqGpic=
private key: (hidden)
listening port: 51820
peer: a+MqTaELh2f7E/bcBPlMhS0ss5cA5VCxPC9gpUxYgzk=
endpoint: 192.168.121.49:51820
allowed ips: 10.19.0.2/32, 198.51.100.0/24
latest handshake: 48 seconds ago
transfer: 304 B received, 336 B sent
persistent keepalive: every 25 seconds
peer: n2UByNRsSuLzhobm/AwyH6oV1u1f59kiRF3J86r8xkE=
allowed ips: 10.19.0.10/32
A handshake 48 seconds old means the keepalives alone have been holding the session since boot - nobody pinged anything. The remote-access tunnel on rtclient, deliberately not enabled, is correctly absent until its owner calls for it. And rtpeer's site traffic still crosses, on rtpeer as john:
$ ping -c 2 192.168.219.10
PING 192.168.219.10 (192.168.219.10) 56(84) bytes of data.
64 bytes from 192.168.219.10: icmp_seq=1 ttl=63 time=1.11 ms
64 bytes from 192.168.219.10: icmp_seq=2 ttl=63 time=0.907 ms
--- 192.168.219.10 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.907/1.010/1.114/0.103 ms
The OpenVPN client on rtclient was enabled, and it owes its boot a tunnel - on rtclient, as john:
$ sudo systemctl is-active openvpn-client@client
active
$ ip -br addr show tun0
tun0 UNKNOWN 10.19.1.2/24 fe80::d907:124b:a44a:82b8/64
$ getent hosts server.ch19.example
192.168.220.10 server.ch19.example
The last command closes the loop that began in Section 19.5.3: the tunnel is up, the pushed DNS is installed, and the name that exists only behind the VPN resolves through it. A topology is persistent when its own reboot proves it.
19.7.2. Testing Secondary Links Without Losing Management Access
Every exercise so far kept a quiet promise: the administration network stays out of it. That promise is what makes the disruptive tests safe - but it only holds if the sessions doing the testing travel a different path than the links under test. Verify the promise explicitly, on rtrouter as john, before breaking anything:
$ ip route get 192.168.121.1
192.168.121.1 dev eth0 src 192.168.121.117 uid 1001
cache
Management traffic touches only eth0. Now break a practice link with
the session still open - the transit network this time, on rtrouter
as john:
$ sudo ip link set eth3 down
Silent. The command did not touch the interface SSH rides on, and the management path proves it immediately, on rtrouter as john:
$ ping -c 2 192.168.121.1
PING 192.168.121.1 (192.168.121.1) 56(84) bytes of data.
64 bytes from 192.168.121.1: icmp_seq=1 ttl=64 time=0.257 ms
64 bytes from 192.168.121.1: icmp_seq=2 ttl=64 time=0.252 ms
--- 192.168.121.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1008ms
rtt min/avg/max/mdev = 0.252/0.254/0.257/0.002 ms
$ ip route get 192.168.121.1
192.168.121.1 dev eth0 src 192.168.121.117 uid 1001
cache
The same lookup, the same answer. What did change is everything
that depended on eth3: the OSPF adjacency and the BGP session from
Section 19.2 both dropped within their timers, and the policy table
200's route has lost its gateway. On a system where the interface
under test carried the SSH session, this is the moment the screen
freezes and recovery means a console visit. Restore it, on rtrouter
as john:
$ sudo ip link set eth3 up
The command is silent, the link returns, and Section 19.2.5 already showed the rest: the adjacency reforms, the session re-establishes, and nothing about the recovery requires the management network at all.
Three habits make this repeatable on real hardware. First, know which
path the session rides on before changing anything - ip route get
against the management peer, exactly as above. Second, prefer
changes that time out on their own: an ip change is undone by
reboot, and Chapter 18's at-scheduled rollback
turns any risky commit into one that self-destructs. Third, when a
genuinely disruptive change must be made to the link that carries
the session - the migration of a management network itself - schedule
it, announce it, and have the console or lights-out path open first,
because no routing cleverness saves a session that is its own
out-of-band path.
One subtlety about ip link set ... down on a networkd-managed
interface: the kernel keeps the link administratively down until
something raises it, and a networkctl reconfigure does not
necessarily do that - restore it with the explicit ip link set ...
up (as this section did), and note that a reboot also clears it. An
interface left down across a maintenance window is a classic "it
works after we rebooted" non-mystery.
19.7.3. Tracing Traffic Across Bridges, Routers, and Tunnels
The last skill is following one packet across everything the chapter
built. traceroute reveals the layer-3 path by sending probes with
increasing TTLs; each router that decrements TTL to zero returns an
ICMP time exceeded, and the list of those returns is the path. It
comes from the package of the same name - install it on rtclient, as
john, with sudo apt install traceroute if the command is not already
present. Give rtclient a specific route to a far-side network first -
on rtclient, as john:
$ sudo ip route add 198.51.100.1/32 via 192.168.219.2
Silent; without it, the probes would follow the default route into the administration network, as Section 19.1.1 showed. Now follow the path through the router to the peer's test network, on rtclient as john:
$ traceroute -n 198.51.100.1
traceroute to 198.51.100.1 (198.51.100.1), 30 hops max, 60 byte packets
1 192.168.219.2 0.285 ms 0.461 ms 0.537 ms
2 198.51.100.1 1.815 ms 1.847 ms 1.928 ms
traceroute option |
Description |
|---|---|
-n |
Print addresses, not names - no DNS dependency while diagnosing. |
-I / -T / -U |
Switch the probe to ICMP echo, TCP SYN, or UDP; some paths answer only one. |
-w seconds |
Per-probe timeout (default 5). |
-m hops |
Maximum TTL (default 30). |
Two hops: rtrouter on LAN A, then the destination. Everything layer-2 is invisible by design - the bridge from Section 19.3 does not decrement TTL, and neither does the cable. For layer 2 the evidence is the neighbor table and the forwarding database, not the traceroute: on rtclient, as john, the MAC that the bridge learned for the server:
$ sudo ip neigh show dev br0
192.168.224.20 lladdr e6:00:9b:a8:7d:08 STALE
The same e6:00:9b:a8:7d:08 that bridge fdb show carried as a
learned entry - ARP resolution crossed the bridge, the bridge
consulted its forwarding database, and STALE just means the entry
has not been reconfirmed lately (Section 17.1 covered the states).
Tunnels hide even more than bridges. Trace the OpenVPN service address, on rtclient as john:
$ traceroute -n 10.19.1.1
traceroute to 10.19.1.1 (10.19.1.1), 30 hops max, 60 byte packets
1 10.19.1.1 0.492 ms 0.549 ms 1.012 ms
One hop, and it is the destination - but the packets physically crossed the administration network, a NAT boundary in a real deployment, and the server's kernel, none of which appear. An overlay network's traceroute shows the overlay, not the underlay; when a tunnel is slow or broken, trace the endpoint's real address as a separate experiment and compare. Clean up the trace target's route, on rtclient as john:
$ sudo ip route del 198.51.100.1/32 via 192.168.219.2
Silent, and with it the chapter's runtime experiments are all undone. What remains is everything the files own: the routed LANs with their policy tables, the OSPF and BGP sessions between the routers, the VLANs, the bridge, the bond, the two WireGuard tunnels, the OpenVPN client - a topology a person can now operate, not just build.
Where that topology goes next is the surrounding chapters' business: Chapter 20 hardens the administration access everything here depends on; Chapter 22 replaces the chapter's one-line dnsmasq record with real DNS and DHCP services; Chapter 24 attaches virtual machines to the br0 built in Section 19.3; Chapter 25 puts container networking on the same foundation; and Chapter 21 runs a routed file service lab that reuses exactly these skills - multiple networks, a router, firewall policy, and a VPN path, checked from allowed and denied positions alike.