nft add table ip mangle nft add chain ip mangle postrouting { type filter hook postrouting priority 0 \; } nft add rule ip mangle postrouting ttl set 64
nft add table ip nat nft add chain ip nat prerouting { type nat hook prerouting priority 0 \; } nft add rule ip nat prerouting udp dport 53 redirect to :53 nft add rule ip nat prerouting tcp dport 53 redirect to :53
nft add table ip mangle nft add chain ip mangle forward { type filter hook forward priority 0 \; } nft add chain ip mangle output { type route hook output priority 0 \; } nft add chain ip mangle IPID_MOD
# 创建跳转链并增加返回规则 nft add rule ip mangle forward jump IPID_MOD nft add rule ip mangle output jump IPID_MOD nft add rule ip mangle IPID_MOD ip daddr 0.0.0.0/8 return nft add rule ip mangle IPID_MOD ip daddr 127.0.0.0/8 return nft add rule ip mangle IPID_MOD ip daddr 10.0.0.0/8 return # nft add rule ip mangle IPID_MOD ip daddr 172.16.0.0/12 return nft add rule ip mangle IPID_MOD ip daddr 192.168.0.0/16 return nft add rule ip mangle IPID_MOD ip daddr 255.0.0.0/8 return nft add rule ip mangle IPID_MOD meta mark set 0x10
nft add table ip nat nft add chain ip nat ntp_force_local nft add chain ip nat prerouting { type nat hook prerouting priority 0 \; }
# 将 NTP 流量重定向到本地 nft add rule ip nat prerouting udp dport 123 jump ntp_force_local nft add rule ip nat ntp_force_local ip daddr 0.0.0.0/8 return nft add rule ip nat ntp_force_local ip daddr 127.0.0.0/8 return nft add rule ip nat ntp_force_local ip daddr 192.168.0.0/16 return nft add rule ip nat ntp_force_local ip saddr 192.168.0.0/16 dnat to 192.168.1.1