Many people have lingering questions about CentOS firewall configuration. Today, I’ll walk you through the methods to set up the CentOS firewall.

I’ve seen several pages with incorrect CentOS firewall content; here is the correct method:
- #/sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT
- #/sbin/iptables -I INPUT -p tcp –dport 22 -j ACCEPT
Then save: #/etc/rc.d/init.d/iptables save This way, after rebooting the computer, the firewall will have opened ports 80 and 22 by default.
Finally, don’t forget to restart it: service iptables restart