删除特定的iptables规则

时间:2013-11-19 11:06:08

标签: linux firewall iptables nat

我有以下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

1 个答案:

答案 0 :(得分:3)

使用 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:12348 iptables -t nat -D PREROUTING - p tcp --dport 7778 -j DNAT --to-destination 192.168.0.5:7778 删除这两个特定规则。

只需用-D替换-I。