Question

I have the following iptable rules and need help removing it if possible?

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

i know -D stands for delete rule but i cant figure out where in my command im meant to put it,

Cheers in advance

Updated ==>

Output of 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
Was it helpful?

Solution

Using iptables -F PREROUNTING you can delete all rules for chain PREROUNTING.

Using iptables -D PREROUTING 1 you can delete a single first rule from chain PREROUTING. So to delete above two rules you will have to use the same command twice.

Use iptables -t nat -D PREROUTING -p tcp --dport 12348 -j DNAT --to-destination 192.168.0.5:12348 and iptables -t nat -D PREROUTING -p tcp --dport 7778 -j DNAT --to-destination 192.168.0.5:7778 to delete these two specific rules.

Just replacing -I with -D.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top