nixos/nat: create nixos-nat-{pre,post,out} in ip6tables too
This commit is contained in:
parent
70a0add412
commit
3e792fb6df
|
@ -13,20 +13,24 @@ let
|
||||||
dest = if cfg.externalIP == null then "-j MASQUERADE" else "-j SNAT --to-source ${cfg.externalIP}";
|
dest = if cfg.externalIP == null then "-j MASQUERADE" else "-j SNAT --to-source ${cfg.externalIP}";
|
||||||
|
|
||||||
flushNat = ''
|
flushNat = ''
|
||||||
iptables -w -t nat -D PREROUTING -j nixos-nat-pre 2>/dev/null|| true
|
ip46tables -w -t nat -D PREROUTING -j nixos-nat-pre 2>/dev/null|| true
|
||||||
iptables -w -t nat -F nixos-nat-pre 2>/dev/null || true
|
ip46tables -w -t nat -F nixos-nat-pre 2>/dev/null || true
|
||||||
iptables -w -t nat -X nixos-nat-pre 2>/dev/null || true
|
ip46tables -w -t nat -X nixos-nat-pre 2>/dev/null || true
|
||||||
iptables -w -t nat -D POSTROUTING -j nixos-nat-post 2>/dev/null || true
|
ip46tables -w -t nat -D POSTROUTING -j nixos-nat-post 2>/dev/null || true
|
||||||
iptables -w -t nat -F nixos-nat-post 2>/dev/null || true
|
ip46tables -w -t nat -F nixos-nat-post 2>/dev/null || true
|
||||||
iptables -w -t nat -X nixos-nat-post 2>/dev/null || true
|
ip46tables -w -t nat -X nixos-nat-post 2>/dev/null || true
|
||||||
|
ip46tables -w -t nat -D OUTPUT -j nixos-nat-out 2>/dev/null || true
|
||||||
|
ip46tables -w -t nat -F nixos-nat-out 2>/dev/null || true
|
||||||
|
ip46tables -w -t nat -X nixos-nat-out 2>/dev/null || true
|
||||||
|
|
||||||
${cfg.extraStopCommands}
|
${cfg.extraStopCommands}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
setupNat = ''
|
setupNat = ''
|
||||||
# Create subchain where we store rules
|
# Create subchain where we store rules
|
||||||
iptables -w -t nat -N nixos-nat-pre
|
ip46tables -w -t nat -N nixos-nat-pre
|
||||||
iptables -w -t nat -N nixos-nat-post
|
ip46tables -w -t nat -N nixos-nat-post
|
||||||
|
ip46tables -w -t nat -N nixos-nat-out
|
||||||
|
|
||||||
# We can't match on incoming interface in POSTROUTING, so
|
# We can't match on incoming interface in POSTROUTING, so
|
||||||
# mark packets coming from the external interfaces.
|
# mark packets coming from the external interfaces.
|
||||||
|
@ -88,8 +92,9 @@ let
|
||||||
${cfg.extraCommands}
|
${cfg.extraCommands}
|
||||||
|
|
||||||
# Append our chains to the nat tables
|
# Append our chains to the nat tables
|
||||||
iptables -w -t nat -A PREROUTING -j nixos-nat-pre
|
ip46tables -w -t nat -A PREROUTING -j nixos-nat-pre
|
||||||
iptables -w -t nat -A POSTROUTING -j nixos-nat-post
|
ip46tables -w -t nat -A POSTROUTING -j nixos-nat-post
|
||||||
|
ip46tables -w -t nat -A OUTPUT -j nixos-nat-out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
Loading…
Reference in New Issue