[Centos7] Firewall port management

Demand background

In the process of system deployment, it is found that the network between the target servers is normal, but the ports are blocked. Check the firewall status and show that the firewall is open. The external server should not easily turn off the firewall. Therefore, you need to configure the ports of the firewall.

Firewall status check and change:


#1、查看防火墙状态

sudo systemctl status firewalld

#或

firewall-cmd --state

 

#2、开启防火墙

sudo systemctl start firewalld #//马上生效,重启会恢复原来状态
sudo systemctl enable firewalld #//重启生效,重启不会恢复原来状态

 

#3、关闭防火墙

sudo systemctl stop firewalld #//马上生效,重启会恢复原来状态
sudo systemctl disable firewalld #//重启生效,重启不会恢复原来状态

 

#4、重新加载防火墙配置

firewall-cmd --reload

surroundings

centos7

Reference article

https://www.cnblogs.com/hopkings/p/12427570.html

text

firewall-cmd --zone=public --add-port=3838/tcp --permanent  //打开tcp3838
firewall-cmd --zone=public --add-port=3838/udp --permanent  //打开udp3838
firewall-cmd --reload //重新加载防火墙
【命令含义】
–zone #作用域
–add-port=3838/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
-reload  #重新加载。不中断用户连接,不丢失状态信息。

#2、移除端口

#*与新增端口关键字相反,把add改为remove即可。
firewall-cmd --zone=public --remove-port=3838/tcp --permanent  //关闭tcp3838
 

#3、查询指定端口是否开启防火墙

firewall-cmd --query-port=3939/tcp   #查询tcp端口3939

 

#4、查询哪些端口开放

firewall-cmd --list-port

Guess you like

Origin blog.csdn.net/u010472858/article/details/106591910