summaryrefslogtreecommitdiff
path: root/etc/nftables.conf
diff options
context:
space:
mode:
authorXiao Pan <gky44px1999@gmail.com>2023-12-03 11:30:06 +0000
committerXiao Pan <gky44px1999@gmail.com>2023-12-03 11:30:06 +0000
commit1e9915fd13ad6e82bad4c54b9bab9867b85abc79 (patch)
treed60a5fd5d11c24800a803ffe63b5bc0ed3536abb /etc/nftables.conf
parent45c29dd905b6777602584d45c656edea0771f04c (diff)
# newer kernel no need for `chain prerouting { type nat hook prerouting priority -100; policy accept; }`, more see https://www.procustodibus.com/blog/2021/11/wireguard-nftables/
Diffstat (limited to 'etc/nftables.conf')
-rw-r--r--etc/nftables.conf16
1 files changed, 7 insertions, 9 deletions
diff --git a/etc/nftables.conf b/etc/nftables.conf
index eae3bbe4..e2e83f5c 100644
--- a/etc/nftables.conf
+++ b/etc/nftables.conf
@@ -3,9 +3,10 @@
# IPv4/IPv6 Simple & Safe firewall ruleset.
# More examples in /usr/share/nftables/ and /usr/share/doc/nftables/examples/.
-# some codes from:
+# references, some codes from:
# https://wiki.archlinux.org/title/Nftables
# https://www.procustodibus.com/blog/2021/11/wireguard-nftables
+# https://wiki.gentoo.org/wiki/Nftables/Examples#Basic_NAT
# needed for reload config using `sudo systemctl restart nftables` or `sudo nft -f /etc/nftables.conf`
flush ruleset
@@ -56,18 +57,15 @@ table inet my_table {
}
}
-# https://wiki.gentoo.org/wiki/Nftables/Examples#Basic_NAT
-# needed by wireguard?
+# needed to wireguard NAT masquerade VPN traffic
# Need inet to masquerade both ipv4 and ipv6? If use ip it will only masquerade ipv4? If use ip6 it will only masquerade ipv6?
# https://wiki.nftables.org/wiki-nftables/index.php/Nftables_families
table inet nat {
- chain prerouting {
- type nat hook prerouting priority 0; policy accept;
- }
-
- # for all packets to WAN, after routing, replace source address with primary IP of WAN interface
+ # newer kernel no need for `chain prerouting { type nat hook prerouting priority -100; policy accept; }`, more see https://www.procustodibus.com/blog/2021/11/wireguard-nftables/
+ # for all packets to $pub_iface, after routing, replace source address with primary IP of $pub_iface interface
chain postrouting {
- type nat hook postrouting priority 100; policy accept;
+ type nat hook postrouting priority 100
+ policy accept
oifname $pub_iface masquerade
}
}