【问题标题】:How to check PREROUTING list from iptable in linux? [closed]如何从 linux 中的 iptables 检查 PREROUTING 列表? [关闭]
【发布时间】:2017-05-19 16:36:31
【问题描述】:

我在 iptable 中添加了数据包转发规则
sudo iptables -t nat -A PREROUTING -p tcp --dport 1111 -j DNAT --to-destination 10.0.3.126:80
我可以看到到达端口 1111 的数据包已正确转发到 10.0.3.126:80。但是,如果我列出规则,我看不到我添加的规则。

sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bootps
ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootps

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

如何查看我添加的规则? 提前谢谢你。

【问题讨论】:

  • sudo iptables-save
  • 谢谢@MichaelO。

标签: linux iptables


【解决方案1】:

使用iptables -L -n -t nat命令
因为PREROUTING链是NAT规则的一部分

【讨论】:

  • 不也是 mangle 的一部分吗?那么您不必查看 mangle 和 nat 的 PREROUTING 链吗?还是链不是特定于表的?
  • PREROUTING是一个阶段,NAT是表,关系是PREROUTING有一个NAT链表,链有规则。需要添加-t nat的原因是As every other iptables command, it applies to the specified table (filter is the default),参考linux.die.net/man/8/iptables
猜你喜欢
  • 1970-01-01
  • 2015-04-06
  • 1970-01-01
  • 2013-01-30
  • 2021-12-16
  • 1970-01-01
  • 2021-02-11
  • 2012-04-29
  • 2012-08-12
相关资源
最近更新 更多