CentOS 7.0 turns off the default firewall and enables the iptables firewall

Operating system environment: CentOS Linux release 7.0.1406 (Core) 64-bit
CentOS 7.0 uses firewall as the firewall by default, here is the iptables firewall step.

1. Turn off the firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #Prohibit firewall from starting
firewall-cmd --state #View the default firewall status (notrunning is displayed when it is closed, and running is displayed when it is opened)

2, iptables firewall (iptables has been installed here, configure it below)
vi/etc/sysconfig/iptables #Edit firewall configuration file
# sampleconfiguration for iptables service
# you can edit thismanually or use system-config-firewall
# please do not askus to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT[0:0]
:OUTPUT ACCEPT[0:0]
-A INPUT -m state--state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -jACCEPT
-A INPUT -i lo -jACCEPT
-A INPUT -p tcp -mstate --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -jACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080-j ACCEPT
-A INPUT -j REJECT--reject-with icmp-host-prohibited
-A FORWARD -jREJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #Save and exit

Note: Here we use ports 80 and 8080 as examples. The *** part is generally added above or below the line "-A INPUT -p tcp -m state --state NEW -m tcp--dport 22 -j ACCEPT", remember not to add it to the last line, otherwise the firewall will not be restarted after restarting. effective.
systemctlrestart iptables.service #Finally restart the firewall to make the configuration take effect
systemctlenable iptables.service #Set the firewall to start at boot

End of the full text......

--------------------------------------Dividing line---------- ----------------------------

Detailed explanation of iptables usage examplehttp://www.linuxidc.com/Linux/2014-03/99159.htm

iptables - Packet Filtering (Network Layer) Firewall http://www.linuxidc.com/Linux/2013-08/88423.htm

Linux firewall iptables detailed tutorial http://www.linuxidc.com/Linux/2013-07/87045.htm

iptables+L7+Squid implements a complete software firewallhttp://www.linuxidc.com/Linux/2013-05/84802.htm

Basic use of iptables backup, restore and firewall scripts http://www.linuxidc.com/Linux/2013-08/88535.htm

Detailed explanation of firewall iptables usage rules under Linuxhttp://www.linuxidc.com/Linux/2012-08/67952.htm

--------------------------------------Dividing line---------- ----------------------------

 

Guess you like

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