VPN & blocking

AWG Router: an AmneziaWG cascade in a web panel, no bash scripts

AWG Router is an open-source panel with speed limits and leak protection that builds an AmneziaWG cascade without bash. What it does to the server network.

On November 14, an author going by COLE_TRAU presented AWG Router on Habr: an open-source web panel (MIT license) that builds an AmneziaWG cascade with checkboxes instead of homemade scripts. In a cascade the client connects to a single entry server: Russian sites open from a Russian IP, and all other traffic leaves through a server abroad.

An exit can be the config of another AmneziaWG server or a SOCKS5 proxy. An individual client can get a separate route: in the author’s example, the client “Dad” goes entirely through a different server. The author presents exit load balancing and speed limiting as features of the panel and covers them in the article. It can be managed from a browser or through a Telegram bot.

Traffic does not pass through the panel: it lays down nftables, ip rule and tc rules, and the Linux kernel routes the packets. That is why stopping or updating the panel does not break the VPN, with the exception of domain-based rules and DNS on the server. Each exit gets its own awgrN interface, and its routing table holds a fallback unreachable route. If the tunnel disappears, packets marked for that exit are dropped and do not leave from the entry server’s address. The tunnel address is substituted through SNAT, because the second server almost certainly uses the same 10.8.1.0/24 subnet as the first server’s clients.

The panel itself is written in Python as a single process with no third-party dependencies, and even the HTTP server is its own. It runs in a container with network_mode: host and privileged mode, and executes network commands through nsenter in the AmneziaWG server’s namespace. AmneziaWG itself can run in Docker or on the host as the awg-quick@awg0 service. The image bundles amneziawg-go, amneziawg-tools, hev-socks5-tunnel and lego for Let’s Encrypt certificates. State is stored in JSON with a .bak backup.

AmneziaWG is a WireGuard fork with packet obfuscation from the Amnezia project, designed to get around DPI. On its own it does not build a cascade. Such a setup is usually assembled by hand: a second interface, ip rules with marks, a separate routing table, an ipset of Russian networks that has to be kept up to date, NAT, MSS clamping and about two hundred lines of bash. AWG Router generates all of this as a single nftables table, where Russian networks sit in a separate set and a client’s personal policy is found with one map lookup.

Source: Хабр