日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

Iptables防火墻iprange模塊擴展匹配規則詳解_安全相關

作者:jiangxl ? 更新時間: 2022-10-05 編程語言

Iptables防火墻iprange模塊擴展匹配規則

iprange模塊可以同時設置多個IP或者設置IP的某一段連續的范圍,通過iprange模塊可以對多個來源地址同時設置策略。

iprange模塊的參數:

  • --src-range:指定源地址范圍。
  • --dst-range:指定目標地址范圍。
  • ! --src-range:非指定的源地址。
  • ! --dst-range:非指定的目標地址。

可以在參數前面加!號表示去反。

案例:

源地址范圍為192.168.20.10-192.168.20.19的IP地址都不允許ping192.168.20.20這個目標地址。

1)編寫防火墻規則

在INPUT鏈的filter表中添加對應的規則。

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)查看添加的規則

禁止192.168.20.10-192.168.20.19的源地址請求的ICMP協議數據報文進入本機。

[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這個服務器中ping192.168.20.20,發現ping不通,登陸192.168.20.21這個服務器,發現能ping通192.168.20.20。

原文鏈接:https://juejin.cn/post/7130054965074067492

欄目分類
最近更新