欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Iptables防火墻string模塊擴(kuò)展匹配規(guī)則

 更新時(shí)間:2022年08月10日 14:06:14   作者:jiangxl  
這篇文章主要為大家介紹了Iptables防火墻string模塊擴(kuò)展匹配規(guī)則詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

Iptables防火墻string模塊擴(kuò)展匹配規(guī)則

String模塊的作用是來匹配請(qǐng)求報(bào)文中指定的字符串,經(jīng)常應(yīng)用于攔截用戶訪問某些網(wǎng)站的場(chǎng)景,將防火墻當(dāng)做路由器使用,例如上班時(shí)間不允許用戶訪問淘寶網(wǎng)站等等場(chǎng)景。

String模塊的常用參數(shù):

--string pattern:指定要匹配的字符串。

! --string pattern:反向匹配。

--algo:指定匹配的查詢算法,有bm和kmp兩種算法。

可以在參數(shù)前面加!號(hào)表示去反。

案例:當(dāng)用戶請(qǐng)求的數(shù)據(jù)報(bào)文中包含taobao.com,則拒絕通行,其余的正常放行。

用戶通過防火墻流出然后訪問目標(biāo)端,因此需要在OUTPUT鏈添加規(guī)則。

1)首先來準(zhǔn)備含有taobao.com數(shù)據(jù)報(bào)文的WEB網(wǎng)站。

1.安裝httpd
[root@jxl-1 ~]# yum -y install httpd
[root@jxl-1 ~]# echo hahaha > /var/www/html/ha.html
[root@jxl-1 ~]# echo taobao.com > /var/www/html/taobao.html
[root@jxl-1 ~]# systemctl restart httpd
2.正常的兩個(gè)頁面
[root@jxl-1 ~]# curl 127.0.0.1/ha.html
hahaha
[root@jxl-1 ~]# curl 127.0.0.1/taobao.html
taobao.com

2)編寫防火墻規(guī)則,拒絕數(shù)據(jù)包中包含taobao.com內(nèi)容的數(shù)據(jù)包。

[root@jxl-1 ~]# iptables -t filter -I OUTPUT -p tcp -m string --string "taobao.com" --algo bm -j DROP

3)查看設(shè)置的防火墻規(guī)則。

[root@jxl-1 ~]# iptables -L -n -v --line-number
Chain INPUT (policy ACCEPT 7011 packets, 6693K bytes)
num   pkts bytes target     prot opt in     out     source               destination         
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
Chain OUTPUT (policy ACCEPT 7310 packets, 11M bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1        0     0 DROP       tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            STRING match  "taobao.com" ALGO name bm TO 65535

4)測(cè)試效果,發(fā)現(xiàn)hahaha的頁面可以正常訪問,taobao.com頁面的請(qǐng)求將被攔截。

以上就是Iptables防火墻string模塊擴(kuò)展匹配規(guī)則的詳細(xì)內(nèi)容,更多關(guān)于Iptables防火墻string模塊的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論