Linux Iptables Delete postrouting Rule Command

Linux Iptables Delete postrouting Rule Command

Iptables is a powerful utility for configuring the Linux kernel's built-in firewall. It allows you to specify rules for filtering and manipulating network traffic.

To delete a rule from the postrouting chain in Iptables, use the iptables command with the -D option, followed by the chain name and the rule number. For example, to delete the second rule from the postrouting chain, you can use the following command:

refer to‮ual:‬tturi.com
iptables -t nat -D POSTROUTING 2

This will delete the second rule from the postrouting chain in the nat table.

To delete all rules from the postrouting chain, you can use the -F option instead of the -D option. For example:

iptables -t nat -F POSTROUTING

This will delete all rules from the postrouting chain in the nat table.

Note that these changes will not be persisted after a reboot. To make the changes permanent, you will need to save the iptables rules to a file and restore them at boot time. You can use the iptables-save and iptables-restore commands to do this.

For example, to save the current iptables rules to a file, you can use the following command:

iptables-save > /etc/iptables.rules

To restore the rules at boot time, you can add the following line to the /etc/rc.local file:

iptables-restore < /etc/iptables.rules

This will restore the iptables rules at boot time.

That's it! You now know how to delete a rule from the postrouting chain in Iptables and how to make the changes permanent.

Created Time:2017-10-16 14:38:52  Author:lautturi