Skip to content

WireGuard multi-hop topologies, practically

How to chain WireGuard peers for entry-exit separation, jurisdictional hops, or hub-and-spoke routing — kernel routing, namespaces, and the operational nuance involved.

A “multi-hop” WireGuard topology means a client’s traffic enters node A and exits node B, with each hop only knowing its immediate neighbours. It is useful for entry-exit separation (no single node sees both your IP and your destination), for jurisdictional routing (entry in one country, exit in another), and for hub-and-spoke designs where a central concentrator brokers traffic between branch sites. WireGuard does not implement multi-hop natively — you build it with kernel routing, optionally namespaces, and a clear-headed view of which interface owns which packet.

How to verify

Before you stitch hops together, confirm each WireGuard interface is up, the routing table reflects what you intend, and packets are not being dropped at the kernel layer.

wg show all
ip -br link show type wireguard
ip route show table all | grep -E 'wg|10\.|fd'
sysctl net.ipv4.ip_forward net.ipv6.conf.all.forwarding
nft list ruleset 2>/dev/null | head -40

A common surprise: wg show reports a handshake but the kernel has no route for the inner subnet because AllowedIPs was set narrowly. Check that the AllowedIPs on each peer covers every destination you expect to send through that hop.

What’s happening

WireGuard is a stateless point-to-point construct. A peer entry says: “for packets destined to these IPs, encrypt and send to that endpoint.” There is no concept of “next hop” beyond the immediate peer — multi-hop is a property of the kernel routing table and (optionally) network namespaces, not of WireGuard itself.

Two common patterns:

Cascaded interfaces, same namespace. The client has one WireGuard interface wg0 pointing at node A. Node A has wg0 (back to client) and wg1 (out to node B). The client’s traffic enters node A’s wg0, the routing table says “default via wg1,” and packets re-encrypt and exit via wg1 to node B. Node B has wg0 (back to A) and a default route to the internet via its physical NIC.

Namespace isolation per hop. On the multi-hop gateway, wg0 lives in the default namespace and wg1 lives in a separate namespace. The kernel routes the inner packet by veth-pair across the namespace boundary. This is the pattern Mullvad and other commercial multi-hop providers use because it prevents accidental cross-leak — if wg1 goes down, packets cannot escape the namespace.

The hard part is symmetry: the return path. Node B must know that 10.0.1.0/24 (the client subnet) lives behind node A, and node A must know that the client lives behind wg0. AllowedIPs on each peer is what teaches the kernel.

The procedure

Walking through the cascaded form, simplest viable shape.

  1. On the client, single peer pointing at node A:

    [Interface]
    PrivateKey = <client-key>
    Address    = 10.0.0.2/32
    
    [Peer]
    PublicKey  = <node-A-pub>
    Endpoint   = node-a.example.org:51820
    AllowedIPs = 0.0.0.0/0
    PersistentKeepalive = 25
  2. On node A, two interfaces — wg0 faces the client, wg1 faces node B:

    [Interface]    # wg0
    PrivateKey = <A-key>
    Address    = 10.0.0.1/24
    ListenPort = 51820
    
    [Peer]
    PublicKey  = <client-pub>
    AllowedIPs = 10.0.0.2/32
    [Interface]    # wg1
    PrivateKey = <A-key2>
    Address    = 10.0.1.2/32
    
    [Peer]
    PublicKey  = <node-B-pub>
    Endpoint   = node-b.example.org:51820
    AllowedIPs = 0.0.0.0/0
    PersistentKeepalive = 25
  3. Enable forwarding on node A and route default via wg1.

    sysctl -w net.ipv4.ip_forward=1
    ip route replace default dev wg1
    nft add rule inet filter forward iif wg0 oif wg1 accept
    nft add rule inet nat postrouting oif wg1 masquerade
  4. On node B, single peer pointing at node A, plus a return route for the client subnet:

    [Interface]
    PrivateKey = <B-key>
    Address    = 10.0.1.1/24
    ListenPort = 51820
    
    [Peer]
    PublicKey  = <node-A-pub2>
    AllowedIPs = 10.0.1.2/32, 10.0.0.0/24

    Enable forwarding and NAT out the physical interface on node B:

    sysctl -w net.ipv4.ip_forward=1
    nft add rule inet nat postrouting oif eth0 masquerade
  5. For namespace isolation, move wg1 on node A into a dedicated namespace, then connect with a veth pair:

    ip netns add hop2
    ip link add veth-host type veth peer name veth-ns
    ip link set veth-ns netns hop2
    ip addr add 169.254.10.1/30 dev veth-host
    ip -n hop2 addr add 169.254.10.2/30 dev veth-ns
    ip link set veth-host up
    ip -n hop2 link set veth-ns up
    ip -n hop2 link set lo up
    # Move wg1 into the namespace
    ip link set wg1 netns hop2
    ip -n hop2 addr add 10.0.1.2/32 dev wg1
    ip -n hop2 link set wg1 up
    ip -n hop2 route add default dev wg1

Operational notes

  • MTU compounds with every hop. WireGuard adds ~60 bytes; two hops eat 120 from your 1500. Set MTU = 1380 on the client interface or expect mysterious PMTU stalls on large responses.
  • Persistent keepalives are mandatory on every hop that sits behind NAT. Without them, the inner hop dies after the conntrack idle timeout and traffic stops with no warning.
  • Logging is sparse. WireGuard does not log per-packet; if a hop misroutes, the only signal is “traffic stops.” Pair with nft monitor trace or conntrack -E to see where packets land.
  • Asymmetric routing kills the tunnel silently. If node B’s reply comes back through a path that does not have AllowedIPs for the client subnet, it gets dropped by the cryptokey routing check.
  • Failover is your responsibility. WireGuard has no concept of “secondary hop”; you implement that with wg-quick PostUp/PostDown scripts or an external controller.

Multi-hop WireGuard is the kind of design we build for clients with jurisdictional or zero-trust requirements — a multi-region environment where the network path itself is a compliance control. The configuration above is the easy part; the operational discipline (key rotation, hop health checks, failover semantics) is where the engagement lives.