如何使用 nftables 跟踪 nat 传出连接。只需要查看 nat 统计信息,即或多或少使用了哪些输出地址。
root@nat-1:~# nft list table nat
table ip nat {
chain post {
type nat hook postrouting priority 100; policy accept;
ip saddr 10.0.0.0/8 oif "bond0.926" snat to 19.246.159.1-19.246.159.7
}
chain pre {
type nat hook prerouting priority -100; policy accept;
}
}
Run Code Online (Sandbox Code Playgroud)
netstat-nat 适用于 iptables,但不再适用于 nftables。
netstat-nat -S
Could not read info about connections from the kernel, make sure netfilter is enabled in kernel or by modules.
Run Code Online (Sandbox Code Playgroud)
我当然可以使用 tcpdump,但应该有一些更好的实用程序;-)