When we use the CentOS system, the CentOS firewall sometimes needs to change the settings. The CentOS firewall is turned on by default, and the installation of the CentOS firewall open port method is as follows:
To open the Iptables configuration file:
Vi/etc/sysconfig/iptables
When modifying the CentOS Firewall Note: Be sure to leave a good posterior for yourself. A management port and SSH management port
The following is an example of a iptables:
# Firewall configuration written by System-config-securitylevel
# Manual Customization of this file are not recommended.
*filter
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
: Rh-firewall-1-input-[0:0]
-A input-j Rh-firewall-1-input
-A forward-j Rh-firewall-1-input
-A rh-firewall-1-input-i lo-j ACCEPT
-A rh-firewall-1-input-p icmp–icmp-type any-j ACCEPT
-A rh-firewall-1-input-p 50-j ACCEPT
-A rh-firewall-1-input-p 51-j ACCEPT
-A rh-firewall-1-input-m state–state established,related-j ACCEPT
-A rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 53-j ACCEPT
-A rh-firewall-1-input-m state–state new-m udp-p udp–dport 53-j ACCEPT
-A rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 22-j ACCEPT
-A rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 25-j ACCEPT
-A rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 80-j ACCEPT
-A rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 443-j ACCEPT
-A rh-firewall-1-input-j Reject–reject-with icmp-host-prohibited
COMMIT
To modify the CentOS firewall, be aware that you have to modify the file according to your server's situation.
For example, if you do not want to open the 80 port to provide Web services, then you should delete this line accordingly:
-A rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 80-j ACCEPT
Restart iptables after all modifications are completed:
Service Iptables Restart
You can verify that the rules are in effect: iptables-l
In this way, we have completed the setup modification of the CentOS firewall.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Set up a centos firewall open port