【问题标题】:Removing specific iptables rule删除特定的 iptables 规则
【发布时间】:2013-11-19 11:06:07
【问题描述】:

我有以下 iptable 规则,如果可能需要帮助删除它?

iptables -t nat -I PREROUTING -p tcp --dport 12348 -j DNAT --to-destination 192.168.0.5:12348
iptables -t nat -I PREROUTING -p tcp --dport 7778 -j DNAT --to-destination 192.168.0.5:7778

我知道 -D 代表删除规则,但我不知道我的命令要放在哪里,

提前干杯

更新 ==>

iptables -L -t nat 的输出:

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
DNAT       tcp  --  anywhere             anywhere            tcp dpt:interwise to:192.168.0.5:7778
DNAT       tcp  --  anywhere             anywhere            tcp dpt:12348 to:192.168.0.5:12348
DNAT       tcp  --  anywhere             anywhere            tcp dpt:7772 to:192.168.0.5:7772
DNAT       tcp  --  anywhere             anywhere            tcp dpt:12342 to:192.168.0.5:12342
DNAT       tcp  --  anywhere             anywhere            tcp dpt:interwise to:192.168.0.5:7778
DNAT       tcp  --  anywhere             anywhere            tcp dpt:12348 to:192.168.0.5:12348
DNAT       tcp  --  anywhere             anywhere            tcp dpt:12348 to:192.168.0.5:12348
DNAT       tcp  --  anywhere             anywhere            tcp dpt:12342 to:192.168.0.5:12342
DNAT       tcp  --  anywhere             anywhere            tcp dpt:7772 to:192.168.0.5:7772
DNAT       tcp  --  anywhere             anywhere            tcp dpt:interwise to:192.168.0.5:7778
DNAT       tcp  --  anywhere             anywhere            tcp dpt:vstat to:192.168.0.5:7779
DNAT       tcp  --  anywhere             anywhere            tcp dpt:12349 to:192.168.0.5:12349
DNAT       tcp  --  anywhere             anywhere            tcp dpt:imtc-map to:192.168.0.2:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:b2-runtime to:192.168.0.3:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:b2-license to:192.168.0.4:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:jps to:192.168.0.5:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:hpocbus to:192.168.0.6:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:hpssd to:192.168.0.7:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:hpiod to:192.168.0.8:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:rimf-ps to:192.168.0.9:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:http to:192.168.0.6:80
DNAT       tcp  --  anywhere             anywhere            tcp dpt:ica to:192.168.0.6:1494
DNAT       tcp  --  anywhere             anywhere            tcp dpt:shell to:192.168.0.2:514
DNAT       tcp  --  anywhere             anywhere            tcp dpt:avt-profile-2 to:192.168.0.5:5005
DNAT       tcp  --  anywhere             anywhere            tcp dpt:wsm-server to:192.168.0.5:5006
DNAT       tcp  --  anywhere             anywhere            tcp dpt:wsm-server-ssl to:192.168.0.5:5007
DNAT       tcp  --  anywhere             anywhere            tcp dpt:synapsis-edge to:192.168.0.5:5008
DNAT       tcp  --  anywhere             anywhere            tcp dpt:winfs to:192.168.0.5:5009
DNAT       tcp  --  anywhere             anywhere            tcp dpt:telelpathstart to:192.168.0.5:5010
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50000 to:192.168.0.5:50000
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50005 to:192.168.0.5:50005
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50009 to:192.168.0.5:50009
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50010 to:192.168.0.5:50010
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50011 to:192.168.0.5:50011
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50012 to:192.168.0.5:50012
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50013 to:192.168.0.5:50013
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50014 to:192.168.0.5:50014
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50184 to:192.168.0.5:50184
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50185 to:192.168.0.5:50185
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50186 to:192.168.0.5:50186
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50187 to:192.168.0.5:50187
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50188 to:192.168.0.5:50188
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50189 to:192.168.0.5:50189
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50000 to:192.168.0.5:50000
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50005 to:192.168.0.5:50005
DNAT       tcp  --  anywhere             anywhere            tcp dpt:50009 to:192.168.0.5:50009
DNAT       tcp  --  anywhere             anywhere            tcp dpts:50010:50014 to:192.168.0.5:50010-50014
DNAT       tcp  --  anywhere             anywhere            tcp dpts:50184:50189 to:192.168.0.5:50184-50189
DNAT       tcp  --  anywhere             anywhere            tcp dpt:binderysupport to:192.168.0.2:23
DNAT       tcp  --  anywhere             anywhere            tcp dpt:proxy-gateway to:192.168.0.3:23
DNAT       tcp  --  anywhere             anywhere            tcp dpt:attachmate-uts to:192.168.0.4:23
DNAT       tcp  --  anywhere             anywhere            tcp dpt:mt-scaleserver to:192.168.0.5:23
DNAT       tcp  --  anywhere             anywhere            tcp dpt:tappi-boxnet to:192.168.0.6:23
DNAT       tcp  --  anywhere             anywhere            tcp dpts:checkoutdb:5510 to:192.168.0.5:5505-5510
DNAT       tcp  --  anywhere             anywhere            tcp dpt:gotodevice to:192.168.0.17:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:foliocorp to:192.168.0.42:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:magicom to:192.168.0.43:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:nmsserver to:192.168.0.44:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:hao to:192.168.0.45:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:pc-mta-addrmap to:192.168.0.46:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:antidotemgrsvr to:192.168.0.47:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:remote-collab to:192.168.0.50:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:dif-port to:192.168.0.51:22
DNAT       tcp  --  anywhere             anywhere            tcp dpt:lnvalarm to:192.168.0.82:22

【问题讨论】:

  • 您需要删除所有规则还是只删除这两条规则?
  • 就这两条规则……

标签: linux firewall iptables nat


【解决方案1】:

使用iptables -F PREROUNTING可以删除链PREROUNTING的所有规则。

使用 iptables -D PREROUTING 1 您可以从链 PREROUTING 中删除一条第一条规则。所以要删除以上两条规则,你必须使用相同的命令两次。

使用 iptables -t nat -D PREROUTING -p tcp --dport 12348 -j DNAT --to-destination 192.168.0.5:12348iptables -t nat -D PREROUTING - p tcp --dport 7778 -j DNAT --to-destination 192.168.0.5:7778 删除这两条具体规则。

只需将 -I 替换为 -D。

【讨论】:

  • 好的,谢谢,我是这个领域的新手,如何将 iptables -D PREROUTING 1 链接到我自己的规则?我可以通过键入“iptables -L -t nat”来查看我的规则,我要删除的规则是它看起来的第一条和第二条规则,但是输入 iptables -D PREROUTING 1 会导致以下“没有链/目标/匹配”名字。”
  • -D 选项将删除规则。没听懂你的问题?
  • 提供“iptables -L -t nat”的输出
猜你喜欢
  • 2015-05-17
  • 2012-04-29
  • 2014-01-30
  • 2016-01-09
  • 2014-01-11
  • 1970-01-01
  • 2012-01-04
  • 1970-01-01
  • 2018-10-09
相关资源
最近更新 更多