Disclaimer up front: this is for AmneziaWG, a WireGuard fork that disguises the handshake so tunnels survive DPI in countries like Russia, China and Iran. I'm the author. If you don't deal with blocking, it's still a server-side policy routing setup on plain Linux (nftables, routing tables, conntrack, tc), and I think this crowd will find the design interesting.
AWG Router is a web panel that turns an AWG server into the entry point of a cascade. Clients connect only to it, and it decides per connection where traffic leaves: direct from the entry server, or through one of several upstream AWG tunnels / SOCKS5 proxies. Client configs stay standard because the policy lives entirely on the server.
**How the routing works:**
- Each exit gets its own interface `awgrN` with its own routing table. SOCKS5 exits use hev-socks5-tunnel as a TUN
- Client packets are marked with nftables (an `ip awgr` table) based on rules: countries, ASNs, subnets, URL lists
- The tunnel address on the upstream server is SNATed, so it never clashes with your client subnet
- If an exit tunnel disappears, an `unreachable` route stays in its table, so traffic fails closed instead of leaking out the default route (unless you explicitly choose direct or another exit as the fallback)
- Load balancing pins each client to an exit, and every connection stores its exit in conntrack (`ct mark`). Moving a client only affects its new connections, and existing flows don't break
- Domain rules for SOCKS5 exits: TCP 80/443 is redirected to a small handler that reads SNI/Host and hands the name to the proxy, so ISP DNS spoofing doesn't matter. Non-matching connections go back through an nftables `type route` chain with the client's mark
- Shaping is tc HTB + fq_codel on `awg0` and `awgrN`, with ingress through `ifb`
- Optional DNS forwarder: queries go through the client's exit (DoH/DoT), with a separate cache per exit. A resolver on the entry server otherwise makes CDNs pick nodes near the entry, not the exit
On the AWG side, it exposes every 3.1 parameter (Jc/Jmin/Jmax, S1–S4, H1–H4, I1–I5, header protection, padding) and ships presets for I1–I5 that mimic STUN, QUIC, DNS and SIP, with randomised parts. Masking can also be set per client.
It's all Python standard library, with no pip dependencies. The routing is tested end-to-end in network namespaces, including a real AWG client↔server tunnel.
Repo (MIT): https://github.com/r-slashslash/AWG-Router