我正在使用wg-quick
打开 VPN 连接。我可以看到该实用程序正在设置一些nft
规则,我想了解它们。我对 iptables 有一定的了解,但对 nftables 一无所知。
这是 Wireguard 配置文件:
[Interface]
PrivateKey = xxxxx
Address = 10.2.0.2/32
DNS = 10.2.0.1
[Peer]
PublicKey = yyyyyyyy
AllowedIPs = 0.0.0.0/0
Endpoint = 185.159.157.129:51820
当我调用时,wg-quick
我看到了这个:
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.2.0.2/32 dev wg0
[#] ip link set mtu 1420 up dev wg0
[#] resolvconf -a tun.wg0 -m 0 -x
[#] wg set wg0 fwmark 51820
[#] ip -4 route add 0.0.0.0/0 dev wg0 table 51820
[#] ip -4 rule add not fwmark 51820 table 51820
[#] ip -4 rule add table main suppress_prefixlength 0
[#] sysctl -q net.ipv4.conf.all.src_valid_mark=1
[#] nft -f /dev/fd/63
这是nft
规则的转储:
table ip wg-quick-wg0 {
chain preraw {
type filter hook prerouting priority raw; policy accept;
iifname != "wg0" ip daddr 10.2.0.2 fib saddr type != local drop
}
chain premangle {
type filter hook prerouting priority mangle; policy accept;
meta l4proto udp meta mark set ct mark
}
chain postmangle {
type filter hook postrouting priority mangle; policy accept;
meta l4proto udp meta mark 0x0000ca6c ct mark set meta mark
}
}
这些nft
规则是什么意思,它们的用途是什么,为什么需要它们?