Fix wireguard service
ci / test (push) Failing after 30s Details
ci / deploy (push) Has been skipped Details

This commit is contained in:
Ciapa 2024-02-09 20:39:50 +01:00
parent c93000421f
commit 937cdc5c1d
1 changed files with 13 additions and 13 deletions

View File

@ -1,4 +1,4 @@
{ ... }: { pkgs, ... }:
{ {
networking.useDHCP = false; networking.useDHCP = false;
networking.bridges = { networking.bridges = {
@ -43,20 +43,20 @@
"ip rule add from 192.168.100.0/24 table 2" "ip rule add from 192.168.100.0/24 table 2"
"ip rule add from 192.168.5.0/24 table 2" "ip rule add from 192.168.5.0/24 table 2"
# NAT # NAT
"iptables -I POSTROUTING -t nat -o wg0 -j MASQUERADE" "${pkgs.iptables}/bin/iptables -I POSTROUTING -t nat -o wg0 -j MASQUERADE"
# Port forwarding # Port forwarding
"iptables -A PREROUTING -t nat -p tcp -i wg0 --dport 51506 -j DNAT --to-destination 192.168.100.11:51506" "${pkgs.iptables}/bin/iptables -A PREROUTING -t nat -p tcp -i wg0 --dport 51506 -j DNAT --to-destination 192.168.100.11:51506"
]; ];
postShutdown = [ };
};
systemd.services.wireguard-wg0.preStop = [
# Force traffic from container networks through wg0 # Force traffic from container networks through wg0
"ip rule del from 192.168.100.0/24 table 2" "ip rule del from 192.168.100.0/24 table 2"
"ip rule del from 192.168.5.0/24 table 2" "ip rule del from 192.168.5.0/24 table 2"
"ip route del table 2 default dev wg0" "ip route del table 2 default dev wg0"
# NAT # NAT
"iptables -D POSTROUTING -t nat -o wg0 -j MASQUERADE" "${pkgs.iptables}/bin/iptables -D POSTROUTING -t nat -o wg0 -j MASQUERADE"
# Port forwarding # Port forwarding
"iptables -D PREROUTING -t nat -p tcp -i wg0 --dport 51506 -j DNAT --to-destination 192.168.100.11:51506" "${pkgs.iptables}/bin/iptables -D PREROUTING -t nat -p tcp -i wg0 --dport 51506 -j DNAT --to-destination 192.168.100.11:51506"
]; ];
};
};
} }