Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I remove the double


line that I have on a Ubuntu server?

This is what I have done:

root@ts:~# iptables -t nat -A POSTROUTING -j MASQUERADE
root@ts:~# sysctl -p /etc/sysctl.conf
net.ipv4.ip_forward = 1
root@ts:~# iptables-save > /etc/iptables.up.rules
root@ts:~# vi /etc/network/interfaces
root@ts:~# iptables-save 
# Generated by iptables-save v1.4.10 on Thu Sep 22 18:00:07 2011
:INPUT ACCEPT [32:6346]
# Completed on Thu Sep 22 18:00:07 2011
root@ts:~# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
share|improve this question
up vote 5 down vote accepted
# iptables -t nat -D POSTROUTING -j MASQUERADE
share|improve this answer

-D will delete the rule you already placed., Just type the same rule you did before and change the -A (append) to -D (delete).

Additionally, since you have no other rules in your table, you can flush all rules and re-add the nat rule. " iptables -F "

share|improve this answer

you don't need to count the rows, instead type:

iptables -L -v -t nat --line-numbers.

Now just use that row number on the left. Much easier.

share|improve this answer

$ iptables -L -v -t nat

count rows

and then

$ iptables -t nat -D POSTROUTING 5

where 5 is you row number for rules-to-delete

Or 2.

$ iptables-save > myfile

edit myfile in you favorite editor (delete row)

$ iptables-restore < myfile

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.