diff options
| author | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2026-08-26 13:02:54 -0500 |
|---|---|---|
| committer | Collin Williams <96917990+bluedragon1221@users.noreply.github.com> | 2026-08-26 13:03:27 -0500 |
| commit | 8b83d306199622b3b5a952d84b776e80a063be0c (patch) | |
| tree | 7d07cda5e99886dfedefc43a0ce105c15e5f139e /hosts/mercury | |
| parent | 6161c1f5308b6035b13304bd714b106031b2c9d2 (diff) | |
try to switch between full tunnel and split tunnel without rebuilding (not working yet)
Diffstat (limited to 'hosts/mercury')
| -rw-r--r-- | hosts/mercury/wireguard.nix | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/hosts/mercury/wireguard.nix b/hosts/mercury/wireguard.nix index 1af84c0..35c6a24 100644 --- a/hosts/mercury/wireguard.nix +++ b/hosts/mercury/wireguard.nix @@ -4,8 +4,36 @@ pkgs, lib, ... -}: { - environment.systemPackages = [pkgs.wireguard-tools]; +}: let + wg-mode = pkgs.writeShellScriptBin "wg-mode" '' + PEER_KEY="${hosts.ganymede.wg_pubkey}" + IFACE="wg0" + case "$1" in + full) + sudo bash -c " + wg set '$IFACE' peer '$PEER_KEY' allowed-ips 0.0.0.0/0,::/0 + ip route add default dev '$IFACE' metric 100 + " + echo "Switched $IFACE to Full Tunnel" + ;; + split) + sudo bash -c " + ip route del default dev '$IFACE' metric 100 + wg set '$IFACE' peer '$PEER_KEY' allowed-ips 10.0.0.0/24 + " + echo "Switched $IFACE to Split Tunnel" + ;; + *) + echo "Usage: wg-mode [full|split]" + exit 1 + ;; + esac + ''; +in { + environment.systemPackages = [ + pkgs.wireguard-tools + wg-mode + ]; systemd.services.udp2raw-client = { description = "udp2raw WireGuard transport"; |
