firewalld配置
#禁用iptables
[root@web02 ~]# systemctl mask iptable
Created symlink from /etc/systemd/system/iptable.service to /dev/null.
#取消禁用iptables
[root@web02 ~]# systemctl unmask iptables
Removed symlink /etc/systemd/system/iptables.service.
[root@web02 ~]# systemctl start firewalld
#查看默认区域
[root@web02 ~]# firewall-cmd --get-default-zone
public
#查看区域规则(默认区域)
[root@web02 ~]# firewall-cmd --list-all
public
target: default
icmp-block-inversion: no
interfaces:
sources:
services: dhcpv6-client ssh
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
#查看区域规则(指定区域)
[root@web02 ~]# firewall-cmd --list-all --zone=trusted
trusted #区域名称
target: ACCEPT #状态:接收(默认状态)
icmp-block-inversion: no #icmp块
interfaces: #绑定的网卡
sources: #允许通过的IP地址、网段
services: #允许通过的服务
ports: #允许访问的端口
protocols: #允许通过的协议 (TCP/UDP/DCCP/SCTP)
masquerade: no #IP伪装
forward-ports: #转发的端口
source-ports: #源端口
icmp-blocks: #icmp块
rich rules: #富规则
#查询一个区域是否有某条规则
[root@web02 ~]# firewall-cmd --query-service=ssh
yes
[root@web02 ~]# firewall-cmd --query-service=http
no
#重启防火墙(清理默认的规则)
[root@web02 ~]# firewall-cmd --reload
success
本文来自博客园,作者:六月OvO,转载请注明原文链接:https://www.cnblogs.com/chenlifan/p/13679197.html