Bootstrap FreeKB - iptables - iptables-save command
iptables - iptables-save command

Updated:   |  iptables articles

On a Red Hat (RHEL) or CentOS system, the following command will display (but not save) your current iptables rules.

iptables-save

 

The prior command should display something like this.

-A INPUT -i lo -j ACCEPT
-A INPUT -s 192.168.0.0/24 -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -j DROP
-A OUTPUT -p tcp -m tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT
COMMIT
# Completed on Mon Sep 21 04:55:18 2020

 

The following command will permanently save your iptables rules. This command simply redirects the output of the iptables-save to the /etc/sysconfig/iptables file (overwrites the file).

iptables-save > /etc/sysconfig/iptables

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 4cf98a in the box below so that we can be sure you are a human.