Add/view/delete an entry to iptables to enable Apache/VNCServer/FTP, etc.

The default CentOS 5.6 firewall configuration does not allow Apache httpd traffic on port 80.  In order to open the port for utilization, a change must be made to the firewall configuration.

iptables -I INPUT -p tcp -m tcp ––dport 80 -j ACCEPT

To open a hole for VNCServer (running on display 20):

iptables -I INPUT -p tcp -m tcp ––dport 5920 -j ACCEPT

To open a hole for VNCServer (running on display 20) web base interface:

iptables -I INPUT -p tcp -m tcp ––dport 5820 -j ACCEPT

To display the openings you’ve created in your firewall:

iptables -L INPUT -n ––line-numbers

To remove a line entry from your iptables file (for example, entry #3):

iptables -D INPUT 3

Notes:

There are two dashes in front of parameters such as “––line-numbers” and “––dport.”

The iptables service must be saved, and restarted before changes take effect.

service iptables save

service iptables restart

Leave a comment