Configure NAT manually
This commit is contained in:
parent
5cbb5d2f33
commit
c93000421f
|
@ -20,13 +20,6 @@
|
|||
networking.defaultGateway = "192.168.0.1";
|
||||
networking.nameservers = [ "192.168.0.1" ];
|
||||
|
||||
networking.nat = {
|
||||
enable = true;
|
||||
internalInterfaces = ["ve-+"];
|
||||
externalInterface = "wg0";
|
||||
enableIPv6 = true;
|
||||
};
|
||||
|
||||
networking.firewall.enable = false;
|
||||
|
||||
networking.wireguard.interfaces = {
|
||||
|
@ -44,6 +37,26 @@
|
|||
persistentKeepalive = 25;
|
||||
}
|
||||
];
|
||||
postSetup = [
|
||||
# Force traffic from container networks through wg0
|
||||
"ip route add table 2 default dev wg0"
|
||||
"ip rule add from 192.168.100.0/24 table 2"
|
||||
"ip rule add from 192.168.5.0/24 table 2"
|
||||
# NAT
|
||||
"iptables -I POSTROUTING -t nat -o wg0 -j MASQUERADE"
|
||||
# Port forwarding
|
||||
"iptables -A PREROUTING -t nat -p tcp -i wg0 --dport 51506 -j DNAT --to-destination 192.168.100.11:51506"
|
||||
];
|
||||
postShutdown = [
|
||||
# Force traffic from container networks through wg0
|
||||
"ip rule del from 192.168.100.0/24 table 2"
|
||||
"ip rule del from 192.168.5.0/24 table 2"
|
||||
"ip route del table 2 default dev wg0"
|
||||
# NAT
|
||||
"iptables -D POSTROUTING -t nat -o wg0 -j MASQUERADE"
|
||||
# Port forwarding
|
||||
"iptables -D PREROUTING -t nat -p tcp -i wg0 --dport 51506 -j DNAT --to-destination 192.168.100.11:51506"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue