Networking: Difference between revisions
IPv6-mostly |
→Port forwarding: Explain that both sections are the same configuration |
||
| Line 46: | Line 46: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
networking = { | networking = { | ||
firewall = { | firewall = { | ||
enable = true; | enable = true; | ||
| Line 73: | Line 62: | ||
]; | ]; | ||
}; | }; | ||
# Previous section is equivalent to : | |||
nftables = { | nftables = { | ||
enable = true; | enable = true; | ||
ruleset = '' | ruleset = '' | ||
table | table ip nat { | ||
chain PREROUTING { | chain PREROUTING { | ||
type nat hook prerouting priority dstnat; policy accept; | type nat hook prerouting priority dstnat; policy accept; | ||
iifname "ens3" | iifname "ens3" tcp dport 80 dnat to 10.100.0.3:80 | ||
} | } | ||
} | } | ||
''; | ''; | ||
}; | }; | ||
}; | |||
</syntaxhighlight> | |||
For IPv6 port forwarding, the example would look like this. Incoming connections on the address <code>2001:db8::</code> and port <code>80</code> will be forwarded to <code>[fe80::1234:5678:9abc:def0]:80</code>. | |||
<syntaxhighlight lang="nix"> | |||
networking = { | |||
firewall = { | firewall = { | ||
enable = true; | enable = true; | ||
| Line 109: | Line 99: | ||
} | } | ||
]; | ]; | ||
}; | |||
# Previous section is equivalent to : | |||
nftables = { | |||
enable = true; | |||
ruleset = '' | |||
table ip6 nat { | |||
chain PREROUTING { | |||
type nat hook prerouting priority dstnat; policy accept; | |||
iifname "ens3" ip6 daddr [2001:db8::] tcp dport 80 dnat to [fe80::1234:5678:9abc:def0]:80 | |||
} | |||
} | |||
''; | |||
}; | }; | ||
}; | }; | ||