centos firewall enable, close, disable or open ports

Source http://www.linuxidc.com/Linux/2012-06/63111.htm

Basic operation command of firewall:
Query firewall status:
[root@localhost ~]# service iptables status

Stop firewall:
[root@localhost ~]# service iptables stop

start the firewall:
[root@localhost ~]# service iptables start

restart the firewall:
[root@localhost ~]# service iptables restart

permanently close the firewall:
[root@localhost ~]# chkconfig iptables off

enable after permanent shutdown:
[root @localhost ~]# chkconfig iptables on


1. View the firewall status
[root@localhost ~]# service iptables status


2. Edit the /etc/sysconfig/iptables file. In our example, we need to open port 8080 and port 9990. Open /etc/sysconfig/iptables
with an editor.


3. According to the gourd drawing, we add port 8080 and port 9990


4. Save the /etc/sysconfig/iptables file, and execute
[root@localhost ~]# service iptables restart in the terminal


5. Check the firewall status again
[root@localhost ~]# service iptables status


6. At this time, the server's 8080 and 9990 port can provide external services.
7. The open mode of other ports is similar to this open mode.




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326144682&siteId=291194637