检查NAT类型

pra*_*tri 5 linux networking iptables

我读到有许多类型的 NAT 可用,例如对称 NAT、全锥 NAT 等。如果我位于 NAT 后面,有什么方法可以找出我当前正在处理的 NAT 类型吗?

我使用基本的 iptables 规则并添加一张网卡,将自己的 Ubuntu 桌面设置为 NAT 机器。我使用了以下规则:

$ iptables -t nat -A POSTROUTING --out-interface eth0 -j MASQUERADE
$ iptables -t filter -A FORWARD --in-interface eth1 -j ACCEPT
Run Code Online (Sandbox Code Playgroud)

有什么方法可以查看我的 NAT 表吗?

Cal*_*leb 0

您可以运行iptables -S转储当前加载到内核过滤表中的所有规则的列表。您可以选择添加一个-t参数来指定要转储的特定表。

man iptables

   -S, --list-rules [chain]
          Print all rules in the selected chain.  If no chain is selected,  
          all chains  are  printed  like  iptables-save.Like every other  
          iptables command, it applies to the specified table (filter is  
          the default).
Run Code Online (Sandbox Code Playgroud)

至于了解您作为客户端所使用的 NAT 类型,目前还没有现成的信息。您最多可以通过查看它对流量的影响来推断它的设置方式。