usage: --direct --add-rule { ipv4 | ipv6 | eb } <table> <chain> <priority> <args>
[root@kvm5 ~]# firewall-cmd --permanent --direct --get-all-rules [root@kvm5 ~]# firewall-cmd --direct --get-all-rules
[root@kvm5 ~]# firewall-cmd --permanent --direct --add-rule \ ipv4 filter INPUT 0 -s 192.168.122.0/24 -p tcp --dport 22 -j REJECT success
[root@kvm5 ~]# firewall-cmd --permanent --direct --get-all-rules ipv4 filter INPUT 0 -s 192.168.122.0/24 -p tcp --dport 22 -j REJECT [root@kvm5 ~]# firewall-cmd --direct --get-all-rules
[root@kvm7 ~]# ssh kvm5.deyu.wang root@kvm5.deyu.wang's password: Last login: Sun Aug 30 21:38:01 2015 from deyu.wang [root@kvm5 ~]# exit logout Connection to kvm5.deyu.wang closed.
--permanent 參數永久有效是指開機生效,但目前狀態並不會改變,所以如果要測試是否生效,必須取消 --permanent 參數再執行一次,才能改變目前的狀態,這與服務的啟動概念一樣。 REJECT 必須大寫。
[root@kvm5 ~]# firewall-cmd --direct --add-rule ipv4 \ filter INPUT 0 -s 192.168.122.0/24 -p tcp --dport 22 -j REJECT success
[root@kvm5 ~]# firewall-cmd --permanent --direct --get-all-rules ipv4 filter INPUT 0 -s 192.168.122.0/24 -p tcp --dport 22 -j REJECT [root@kvm5 ~]# firewall-cmd --direct --get-all-rules ipv4 filter INPUT 0 -s 192.168.122.0/24 -p tcp --dport 22 -j REJECT
[root@kvm7 ~]# ssh kvm5.deyu.wang ssh: connect to host kvm5.deyu.wang port 22: Connection refused
[root@kvm5 ~]# firewall-cmd --direct --remove-rule \ ipv4 filter INPUT 0 -s 192.168.122.0/24 -p tcp --dport 22 -j REJECT success [root@kvm5 ~]# firewall-cmd --direct --permanent --remove-rule \ ipv4 filter INPUT 0 -s 192.168.122.0/24 -p tcp --dport 22 -j REJECT success
[root@kvm5 ~]# firewall-cmd --permanent --direct --get-all-rules [root@kvm5 ~]# firewall-cmd --direct --get-all-rules
[root@kvm5 ~]# man 5 firewalld.direct
-p icmp --icmp-type echo-request。