39

I would like to delete POSTROUTING rule below,

[root@hostname ~]# service iptables status
Table: nat
Chain PREROUTING (policy ACCEPT)
num  target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
num  target     prot opt source               destination         
1    MASQUERADE  all  --  192.168.1.0/24       0.0.0.0/0           

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         

then I typed below,

[root@hostname ~]# iptables -D POSTROUTING 1
iptables: No chain/target/match by that name

Is there anything wrong?

Verbeia
  • 4,400
  • 2
  • 23
  • 44
hiroo
  • 657
  • 2
  • 7
  • 13

1 Answers1

72

Try adding the table name explicitly:

iptables -t nat -D POSTROUTING 1
sarnold
  • 102,305
  • 22
  • 181
  • 238
  • "is necessary" -- did you mean "is not necessary" ? Or did this fix your problem? – sarnold Nov 23 '11 at 08:39
  • Sorry,I typed wrong. this fixed my problem thanks to your advice! Thank you very much! – hiroo Nov 23 '11 at 09:07
  • Excellent! [Don't forget to accept this as the answer](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), so that it can help others in the future. Thanks! – sarnold Nov 23 '11 at 09:14
  • Oh finally I found what I was looking for so long, thanks so much for your answer! Was messing around with my iptables configuration for hours and I always missed the -t nat part when trying to remove a very buggy rule. God bless you! +++ – beta Sep 17 '12 at 09:16
  • 3
    This didn't work for myself Ubuntu 13.04 (maybe from my own doings) but ```iptables -t nat -F``` did – davidcollom Oct 14 '13 at 16:19
  • @davidcollom, thanks, I marked your comment up with the hopes it'll be useful to someone else in the future. – sarnold Oct 15 '13 at 22:23
  • `service iptables status` doesn't show `nat` in its output. Is it possible to print it out? – Incerteza Mar 16 '14 at 06:18
  • @AlexanderSupertramp - `iptables -t nat -L` should show you the nat table – davidcollom Sep 08 '14 at 15:31