# 查看帮助
firewall-cmd --help
# mask
systemctl unmask firewalld
systemctl mask firewalld
# Enable firewalld
systemctl enable firewalld
# Disable firewalld
systemctl disable firewalld
# 启动防火墙
systemctl start firewalld
# 关闭防火墙
systemctl stop firewalld
# 重启防火墙
systemctl restart firewalld
# 防火墙状态
firewall-cmd --state
systemctl status firewalld
# 重载规则
firewall-cmd --reload
# 关闭FTP服务端口
firewall-cmd --remove-service=ftp --permanent
# 查询服务是否生效(返回yes or no)
firewall-cmd --query-service=http
firewall-cmd --query-port=22/tcp
# 查看当前绑定网卡
firewall-cmd --list-interfaces
# 查询自定义开放服务
firewall-cmd --list-all
# 开启自定义端口
# 命令含义:
# --zone //作用域
# --add-port=80/tcp //添加端口,格式为:端口/通讯协议
# --permanent //永久生效,没有此参数重启后失效
firewall-cmd --add-port=3128/tcp
firewall-cmd --zone=public --add-port=1688/tcp --permanent
firewall-cmd --zone=dmz --add-port=8080/tcp
firewall-cmd --zone=public --add-port=5060-5061/udp
firewall-cmd --zone=public --add-port=20000-30000/tcp --permanent
firewall-cmd --zone=public --remove-port=20000-30000/tcp --permanent
# 获取支持的服务名
firewall-cmd --permanent --get-services
# 开启服务
firewall-cmd --permanent --zone=public --add-service=ssh
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
# 关闭服务或端口
firewall-cmd --permanent --zone=trusted --remove-service=http
firewall-cmd --permanent --zone=public --remove-port=1688/tcp
# 获取支持的作用域
firewall-cmd --get-zones
# 设置默认作用域(默认为public)
firewall-cmd --set-default-zone=public
# 向public作用域添加网卡
# 需要在网卡配置文件添加ZONE=public
firewall-cmd --zone=public --add-interface=em1
# 查询当前所有作用域分别开启的服务
firewall-cmd --list-all-zones
# 查看服务文件
ls /usr/lib/firewalld/services
支持的服务名称
- amanda-client
- bacula
- bacula-client
- dhcp
- dhcpv6
- dhcpv6-client
- dns
- ftp
- high-availability
- http
- https
- imaps
- ipp
- ipp-client
- ipsec
- kerberos
- kpasswd
- ldap
- ldaps
- libvirt
- libvirt-tls
- mdns
- mountd
- ms-wbt
- mysql
- nfs
- ntp
- openvpn
- pmcd
- pmproxy
- pmwebapi
- pmwebapis
- pop3s
- postgresql
- proxy-dhcp
- radius
- rpc-bind
- samba
- samba-client
- smtp
- ssh
- telnet
- tftp
- tftp-client
- transmission-client
- vnc-server
- wbem-https
文章评论