Just more ramblings of another IT Guy

Commands to edit iptables


To view the current rules and also view the rule ID use the following:

iptables -L -n –line-numbers
iptables -nL -v –line-numbers


To delete a rule use:

iptables -D INPUT X  (where x is the ID of the rule in question)


To insert a rule before another use the following:

iptables -I INPUT X -s -j DROP (where X is the rule above which the rule is to be inserted)



To replace a rule:
iptables -R INPUT X -s -j DROP



Make sure to save as changes will be dropped on reboot

iptables-save > /etc/iptables.rules
/sbin/service iptables save

This entry was posted in Handy Linux Commands, Security, Tips+Tricks. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *