Files
2026-10-05 22:44:09 +05:00

75 lines
3.3 KiB
Markdown

# Route the whole machine
Send every app's traffic through the proxy, including apps with no proxy settings. There
are two global modes, and either can start at boot.
## Config
```nix
services.proxy-suite = {
enable = true;
proxy = {
enable = true;
outbounds = [ { tag = "my-vps"; urlFile = "/run/secrets/my-vps-url"; } ];
tun.enable = true;
autostart = "tun"; # or null, to start it by hand
};
killSwitch.enable = true;
};
```
## TUN or TProxy
- **TUN** adds a virtual network interface and routes everything into it. It is the usual
pick.
- **TProxy** intercepts TCP and UDP with nftables instead of adding an interface. Pick it if
this host is a gateway for other devices: list their interfaces in
`proxy.tproxy.lanInterfaces` (NixOS needs `networking.nftables.enable` for that).
You can enable both and switch between them. Starting one global mode stops the other, and
an AmneziaWG profile running as a global VPN counts as one too.
Your [routing rules](./routing.md) still apply in both modes. Sites that the rules send
direct skip the proxy.
## Commands
```sh
proxy-ctl proxy tun on # or: off, toggle, restart
proxy-ctl proxy tproxy on
proxy-ctl status # which mode is running
proxy-ctl killswitch # kill switch state
proxy-ctl killswitch off # lift the kill switch without stopping the tunnel
```
## Good to know
- The kill switch blocks outgoing traffic from boot until the tunnel is up, while it restarts
and after it fails, so nothing leaks. LAN, DHCP and the time daemon's NTP stay open.
Subscriptions are fetched through the tunnel; only if that fails are they fetched
directly, so the proxy can come up from a cold cache. The subscription host then sees
your address. Turning the tunnel off with `proxy-ctl` lifts the kill switch until the
next boot or tunnel start.
- With TUN or a global AmneziaWG profile, the kill switch also holds forwarded traffic
(Docker, libvirt, podman) to the LAN while the tunnel is down. TProxy diverts only
`proxy.tproxy.lanInterfaces`, so in TProxy mode other containers and VMs bypass the proxy
whether the tunnel is up or not. With TProxy alone the kill switch lets them through, and
with TUN or AmneziaWG also configured it cuts them off in TProxy mode.
- Networks the kill switch should leave open besides the private ranges, such as a routed
IPv6 prefix on a VM bridge, go in `killSwitch.allowedSubnets`. It defaults to
`proxy.tproxy.localSubnets`, so what TProxy leaves out stays reachable.
- If the uplink has no IPv6, set `proxy.dns.strategy = "ipv4_only"` (sing-box). Otherwise
direct IPv6 connections hang instead of falling back to IPv4.
- `proxy.tproxy.localSubnets` lists networks that skip TProxy. Add your LAN and VM bridges if
they are not in `192.168.0.0/16`.
- While a global mode is on, per-app `tun`, `tproxy` and `zapret` profiles run the app
without their route, so wrapped programs still start.
## See also
- [`proxy.tun`](../options/proxy.md#services-proxy-suite-proxy-tun-enable)
- [`proxy.tproxy`](../options/proxy.md#services-proxy-suite-proxy-tproxy-enable)
- [`proxy.autostart`](../options/proxy.md#services-proxy-suite-proxy-autostart)
- [`killSwitch.enable`](../options/killSwitch.md#services-proxy-suite-killswitch-enable)
- [`proxy.ipv6`](../options/proxy.md#services-proxy-suite-proxy-ipv6)