Iptables防火墻iprange模塊擴展匹配規(guī)則詳解
Iptables防火墻iprange模塊擴展匹配規(guī)則
iprange模塊可以同時設(shè)置多個IP或者設(shè)置IP的某一段連續(xù)的范圍,通過iprange模塊可以對多個來源地址同時設(shè)置策略。
iprange模塊的參數(shù):
--src-range:指定源地址范圍。--dst-range:指定目標地址范圍。! --src-range:非指定的源地址。! --dst-range:非指定的目標地址。
可以在參數(shù)前面加!號表示去反。
案例:
源地址范圍為192.168.20.10-192.168.20.19的IP地址都不允許ping192.168.20.20這個目標地址。
1)編寫防火墻規(guī)則
在INPUT鏈的filter表中添加對應(yīng)的規(guī)則。
1.無需指定目標地址 [root@jxl-1 ~]# iptables -t filter -I INPUT -p icmp -m iprange --src-range 192.168.20.10-192.168.20.19 -j DROP 2.也可以指定目標地址,效果都一樣 [root@jxl-1 ~]# iptables -t filter -I INPUT -p icmp -m iprange --src-range 192.168.20.10-192.168.20.19 --dst-range 192.168.20.20 -j DROP
2)查看添加的規(guī)則
禁止192.168.20.10-192.168.20.19的源地址請求的ICMP協(xié)議數(shù)據(jù)報文進入本機。
[root@jxl-1 ~]# iptables -L -n -v --line-number Chain INPUT (policy ACCEPT 2033 packets, 2002K bytes) num pkts bytes target prot opt in out source destination 1 0 0 DROP icmp -- * * 0.0.0.0/0 0.0.0.0/0 source IP range 192.168.20.10-192.168.20.19 Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) num pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 2072 packets, 3079K bytes) num pkts bytes target prot opt in out source destination
3)測試效果
登陸192.168.20.10這個服務(wù)器中ping192.168.20.20,發(fā)現(xiàn)ping不通,登陸192.168.20.21這個服務(wù)器,發(fā)現(xiàn)能ping通192.168.20.20。

以上就是Iptables防火墻iprange模塊擴展匹配規(guī)則詳解的詳細內(nèi)容,更多關(guān)于Iptables防火墻iprange的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Mac下使用mitmproxy抓包HTTPS數(shù)據(jù)方法詳解
在Mac上常用的抓包軟件是 Charles下面為大家介紹另一個抓包神器 mitmproxy,具體使用方法大家可以參考下面的介紹2020-02-02
黑客入侵Windows XP系統(tǒng)常用七大招數(shù)
黑客入侵Windows XP系統(tǒng)常用七大招數(shù)...2006-10-10

