admin管理员组

文章数量:1642344

以下只是针对自定义规则的简单说明和举例,其实也就是帮助文档里面的东西;详细的说明自行参考 firewall-cmd --help

传递的参数 与 iptables, ip6tables 以及 ebtables 一致!

Centos7 Firewall 用户操作接口依然调用系统内核的iptables模块来设定规则!

直接选项

–direct需要是直接选项的第一个参数。

将命令传递给防火墙。参数 可以是 iptables, ip6tables 以及 ebtables 命令行参数。

firewall-cmd --direct --passthrough { ipv4 | ipv6 | eb }

为表

增加一个新链 。

firewall-cmd --direct --add-chain { ipv4 | ipv6 | eb }

从表

中删除链 。

firewall-cmd --direct --remove-chain { ipv4 | ipv6 | eb }

查询 链是否存在与表

. 如果是,返回0,否则返回1.

firewall-cmd --direct --query-chain { ipv4 | ipv6 | eb }

如果启用,此命令将有返回值。此命令没有输出信息。

获取用空格分隔的表

中链的列表。

firewall-cmd --direct --get-chains { ipv4 | ipv6 | eb }

为表

增加一条参数为 的链 ,优先级设定为 。

firewall-cmd --direct --add-rule { ipv4 | ipv6 | eb }

参考示例:

方式-:[reload 生效,修改后重启才可生效]

#firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 1 -s 192.168.1.0/24 -p tcp --dport=22 -j ACCEPT

firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 2 -p tcp --dport=22 -j DROP

方式二:[重载或重启后失效]
iptables -t filter -I INPUT_direct -s 192.168.1.20 -p tcp --dport=22 -j ACCEPT

iptables -A INPUT_direct -p tcp --dport=22 -j DROP

从表

中删除带参数 的链 。

firewall-cmd --direct --remove-rule { ipv4 | ipv6 | eb }

firewall-cmd --direct --remove-rule ipv4 filter INPUT 2 -p tcp --dport=22 -j DROP

查询带参数 的链 是否存在表

firewall-cmd --direct --query-rule { ipv4 | ipv6 | eb }

获取表

中所有增加到链 的规则,并用换行分隔。

firewall-cmd --direct --get-rules { ipv4 | ipv6 | eb }

本文标签: 自定义规则firewalld