To add a new firewall rule to your existing IPTABLES configuration, I am using three simple commmands.

With the first command I am checking which rules are currently active:

sudo iptables -L

This gives me an overview of which IPTABLES rules are currently in place. The next command opens my existing IPTABLES file in vi. Replace vi with your preferred edit such as vim or nano:

sudo vi /etc/iptables.firewall.rules

Now you can modify your firewall rules, then save and exit vi with :wq. In the last step we will write the firewall rules to iptables-restore, so the firewall rules will be in place every time we restart our server:

sudo iptables-restore < /etc/iptables.firewall.rules

Now run the first command one more time to verify your changes are in:

sudo iptables -L

0 Comments

Leave a Reply

Avatar placeholder

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.