
CentOS / Redhat Iptables Firewall Configuration Tutorial. Please refer to iptables man page for more information about iptables usage and syntax: Make sure iptables is allowing port 80 / 110 / 143 connections by listing rules: Run following command ss command/netstat command: # firewall-cmd -permanent -add-port 2000-3000/tcp To open port range between 2000-3000/tcp, enter: # firewall-cmd -permanent -add-port 80/tcp Type the following command to open TCP port 80 for Apache/httpd server: # firewall-cmd -get-zone-of-interface=eth0 Valid_lft 79076sec preferred_lft 79076sec To find about interface name use ip command:ġ: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1 Sample outputs: block dmz drop external home internal public trusted work # service iptables save A note about Red Hat Enterprise Linux 7.x and CentOS 7.xĪbove commands or files won’t work on RHEL/CentOS 7.x or the latest version of Fedora Linux.
# iptables -I INPUT -p tcp -m tcp -dport 443 -j ACCEPT You can also use the iptable command as follows to open port 443: # service iptables restart A note about opening a port on CentOS/RHEL 6
A RH-Firewall-1-INPUT -m state -state NEW -m tcp -p tcp -dport 143 -j ACCEPT Restart iptables service A RH-Firewall-1-INPUT -m state -state NEW -m tcp -p tcp -dport 110 -j ACCEPT Open port 143 on a CentOS # /etc/init.d/iptables restart Open port TCP port # 110 on a RHEL A RH-Firewall-1-INPUT -m state -state NEW -m tcp -p tcp -dport 80 -j ACCEPT How to open TCP port 80 on a RHEL/CentOS Linux Let us see how to open a port in the firewall on CentOS or RHEL version 5.x/6.x and 7.x including the latest version of Fedora Linux 27 or above. Red Hat Enterprise Linux 3 / 4 / 5 and 6.