参考:
https://blog.csdn.net/bbwangj/article/details/74502967
查看内部端口占用情况
netstat -ntlp
systemctl 的基本使用
启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld
开机禁用 : systemctl disable firewalld
开机启用 : systemctl enable firewalld
firewalld的基本使用
# 查看防火墙是否开启
firewall-cmd --state
//查看开放的防火墙端口
firewall-cmd --list-all
//查看某端口防火墙状态
firewall-cmd --query-port=8080/tcp
# 开放端口--permanent
firewall-cmd --permanent --add-port=3306/tcp
# 删除端口
firewall-cmd --zone=public --remove-port=80/tcp --permanent
# 配制后需要重新加载
sudo firewall-cmd --reload
# 放通指定IP192.168.0.73访问2375端口
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.0.73" port protocol="tcp" port="2375" accept"
# 删除指定IP192.168.0.73访问2375端口
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.0.73" port protocol="tcp" port="2375" accept"
[root@localhost docker]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp1s0
sources:
services: ssh dhcpv6-client
ports: 80/tcp 8080/tcp 5000/tcp 7072/tcp 7073/tcp 6379/tcp 3306/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
rule family="ipv4" source address="192.168.0.73" port port="2375" protocol="tcp" accept
检查防火墙状态
# 检查防火墙状态
systemctl status firewalld
# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop