Setting up the CentOS firewall open port

  
When we use the CentOS system, the CentOS firewall sometimes needs to change settings. The CentOS firewall is enabled by default. The method for setting the CentOS firewall open port is as follows:

Open the iptables configuration file: vi /etc/sysconfig/iptables When modifying the CentOS firewall, be sure to leave a good path for yourself and leave a management for VNC. Port and SSh management port

The following is an example of iptables:

# Firewall configuration written by system-config-securitylevel # Manual customization of this file is 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, you need to be aware that you must modify this file according to your own server.

For example, if you don't want to open port 80 to provide web services, 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: service iptables restart

You can verify if the rules have taken effect: iptables -L

, we have completed the modification of the CentOS firewall settings.

Copyright © Windows knowledge All Rights Reserved