Firewalls on RHEL
Here’s firewall configuration RHEL 6 and below
Check the status for reboot persistance
chkconfig –list | grep iptables
Command to add the firewall to accept traffic with port 22 on source 192.1.1.2
iptables -I INPUT 2 -p tcp –dport 22 -s 192.1.1.2 -j ACCEPT
Default location of iptables files
/etc/sysconfig/iptables
Location of iptables configuration file
/etc/sysconfig/iptables-config
Stop & Start the iptables service
service iptables stop
service iptables start
List all the iptables
service iptables status
OR
iptables -L
Add iptables rule
iptables -A INPUT -p tcp -s 0.0.0.0./0 -m tcp –dport 20301 -j ACCEPT
Drop iptables rule
iptables -D INPUT -p tcp -s 0.0.0.0/0 -m tcp –dport 20301 -j DROP
Save the currently running iptables to the file and system
service iptables save (It automatically overwrites it to the /etc/sysconfig/iptables)
If you edited the iptable file and want to save it use
iptables-restore < /etc/sysconfig/iptables
If you edited the iptables via commands and want to save it
service iptables save