一,firewalld对一个请求会适用哪个zone?
1, 当接收到一个请求时,firewalld具体使用哪个zone?
firewalld是通过三个步骤来判断的:
-
source,即:源地址
-
interface,即:接收请求的网卡
-
firewalld.conf中配置的默认zone
通常值为:DefaultZone=public
说明:三个步骤的优先级顺序降低
即:如果通过source匹配到了一个zone,
则不会再使用interface,
如果通过interface匹配到了zone,
则不会再使用默认zone
2, 为什么会是这样?这是firewalld的设置,
查看active-zones
[root@192 ~]# firewall-cmd --get-active-zones
dropsources: 192.168.7.7
publicinterfaces: ens33
trustedsources: 192.168.8.8
查看default-zone
[root@192 ~]# firewall-cmd --get-default-zone
public
查看backend的nftables规则:
chain filter_INPUT_ZONES {ip saddr 192.168.7.7 goto filter_IN_dropip saddr 192.168.8.8 goto filter_IN_trustediifname "ens33" goto filter_IN_publicgoto filter_IN_public}
二,firewalld的rich规则执行顺序:
1,执行顺序
1,日志规则
2,drop/reject规则
3,accept规则
2,列出所有规则
[root@192 ~]# firewall-cmd --list-all
public (active)target: defaulticmp-block-inversion: nointerfaces: ens33sources:services: cockpit dhcpv6-client sshports:protocols:forward: yesmasquerade: noforward-ports:source-ports:icmp-blocks:rich rules:rule family="ipv4" source address="13.17.12.210" port port="22" protocol="tcp" acceptrule family="ipv4" source address="13.17.12.210" reject
查看nftables的规则:
chain filter_IN_public {jump filter_INPUT_POLICIES_prejump filter_IN_public_prejump filter_IN_public_logjump filter_IN_public_denyjump filter_IN_public_allowjump filter_IN_public_postjump filter_INPUT_POLICIES_postmeta l4proto { icmp, ipv6-icmp } acceptreject with icmpx type admin-prohibited}
这个顺序中,就是按 log/deny/allow的顺序执行