centos7 firewall-cmd 常用命令

开启、重启、关闭:

# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop

查询端口是否放通:

#查询XXX端口
firewall-cmd --query-port=XXX/tcp
firewall-cmd --query-port=XXX/udp
#查看防火墙规则
firewall-cmd --list-all

开放XXX端口:

firewall-cmd --zone=public --add-port=XXX/tcp --permanent
firewall-cmd --zone=public --add-port=XXX/udp --permanent

关闭XXX端口:

firewall-cmd --zone=public --remove-port=XXX/tcp --permanent
firewall-cmd --zone=public --remove-port=XXX/udp --permanent

添加--permanent表示长期有效

Last modification:February 16th, 2020 at 09:48 pm
If you think my article is useful to you, please feel free to appreciate