CentOS7 open external network access port (firewall)



The firewall of CentOS7 has been replaced by firewall. Here are some records. Here are some commands:
>>> Open port
firewall-cmd --zone=public --add-port=80/tcp --permanent
Command meaning:
--zone #Scope
--add-port=80/tcp #Add port, the format is: port/communication protocol
--permanent #Permanently effective, it will be invalid after restart without this parameter
>> Restart firewall
firewall-cmd --reload
Introduction to common commands
firewall-cmd --state ##Check the firewall status, whether it is running
firewall-cmd --reload ##Reload the configuration, for example, after adding rules, you need to execute this command
firewall-cmd --get-zones ##List support The zone
firewall-cmd --get-services ##List the supported services, the service in the list is the
approved firewall-cmd --query-service ftp ##Check whether the ftp service is supported, return yes or no
firewall-cmd --add-service=ftp ##Temporarily open ftp service
firewall-cmd --add-service=ftp --permanent ##permanently open ftp service
firewall-cmd --remove-service=ftp --permanent ##permanently remove ftp service
firewall-cmd --add-port=80/ tcp --permanent ##Permanently add port 80
iptables -L -n ##View the rules, this command is the same as iptables
man firewall-cmd   


usage is as follows:
>>> close the firewall
systemctl stop firewalld.service #stop firewall
systemctl disable firewalld.service #Disable the firewall to start on startup


Enable firewall:
systemctl start firewalld.service


and install iptables-services:
yum install iptables-services

Set boot up:
systemctl enable iptables

systemctl [stop|start|restart] iptables
#or
service iptables [stop |start|restart]

service iptables save
#or
/usr/libexec/iptables/iptables.init save

Guess you like

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