Linux - CentOS 7 open port 80 open external network access

scene:

widows10 installed VMware, VMware security of the centos7, nat mode network connection, before you can be off the firewall connectivity (ie windows can access the web on linux, mysql database can also be connected on linux), but after the restart after problems my Windows and linux can ping each other, and can be networked with each other. Check the information, it should be linux ports are not open, do the following:

Check the firewall is turned on

systemctl status firewalld

If you do not open the open

systemctl start firewalld  #关闭则start改为stop

After the stop will look something like this:

View all open ports

firewall-cmd --list-ports

Note: After starting the firewall, the default does not open any ports, you need to manually open ports

Firewall open port access
 

firewall-cmd --zone=public --add-port=80/tcp --permanent

Command Meaning: --zone # scope --add-port = 80 / tcp # Add port, the format is: port / protocol --permanent # permanent, this argument does not restart after failure
Note: When you turn on the firewall only need to restart entered into force, [reboot] command:

 firewall-cmd --reload

And then perform the firewall-cmd --list-ports view once the discovery has opened:

Then I open port 3306:

Other commonly used commands:

firewall-cmd --state                          ##查看防火墙状态,是否是running
firewall-cmd --reload                          ##重新载入配置,比如添加规则之后,需要执行此命令
firewall-cmd --get-zones                      ##列出支持的zone
firewall-cmd --get-services                    ##列出支持的服务,在列表中的服务是放行的
firewall-cmd --query-service ftp              ##查看ftp服务是否支持,返回yes或者no
firewall-cmd --add-service=ftp                ##临时开放ftp服务
firewall-cmd --add-service=ftp --permanent    ##永久开放ftp服务
firewall-cmd --remove-service=ftp --permanent  ##永久移除ftp服务
firewall-cmd --add-port=80/tcp --permanent    ##永久添加80端口 
firewall-cmd --remove-port=80/tcp --permanent    ##永久添加80端口 
firewall-cmd --zone=public --list-ports       ##查看已开放的端口

iptables -L -n                                ##查看规则,这个命令是和iptables的相同的
man firewall-cmd   

 

Published 705 original articles · won praise 666 · Views 1.43 million +

Guess you like

Origin blog.csdn.net/qq_36761831/article/details/104863905
Recommended