[Linux] A collection of common commands for Linux firewalls

Check firewall status:

firewall-cmd --state

stop/restart/start firewall

systemctl stop firewalld.service
systemctl restart firewalld.service
systemctl start firewalld.service

Disable/enable firewall startup on boot

systemctl disable firewalld.service
systemctl enable firewalld.service

Query which ports are open

firewall-cmd --list-port

Query whether a port is open, such as 1010

firewall-cmd --query-port=1010/tcp --permanent

Open a port, such as 9090

firewall-cmd --zone=public --add-port=9090/tcp --permanent
firewall-cmd --reload   # 重新加载配置

–zone #Scope
–add-port=9090/tcp #Add port, the format is: port/communication protocol
–permanent #Permanently, it will be invalid after restart without this parameter

Close a port, such as 1010

firewall-cmd --zone=public --remove-port=1010/tcp --permanent
firewall-cmd --reload   # 重新加载配置

The WeChat public account has been opened first. You can find me by searching for "Jiang Xiaonan and his friends". Friends, you can pay attention. The article will be updated synchronously for easy viewing.

Guess you like

Origin blog.csdn.net/weixin_45842494/article/details/123451817