- 資訊首頁(yè) > 網(wǎng)絡(luò )安全 >
- iptables怎么實(shí)現字符串匹配
這篇文章主要介紹“iptables怎么實(shí)現字符串匹配”,在日常操作中,相信很多人在iptables怎么實(shí)現字符串匹配問(wèn)題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對大家解答”iptables怎么實(shí)現字符串匹配”的疑惑有所幫助!接下來(lái),請跟著(zhù)小編一起來(lái)學(xué)習吧!
分類(lèi): SHELL&linux命令2012-07-03 18:25 3172人閱讀 評論(0) 收藏 舉報
stringinputtcpoutputhexlinux
通過(guò)string匹配域名來(lái)過(guò)濾,范例如下:
iptables -I OUTPUT -p tcp -m string --string "qq.com" --algo bm -j DROP iptables -I OUTPUT -p udp -m string --string "qq.com" --algo bm -j DROP
這樣就無(wú)法訪(fǎng)問(wèn)與QQ相關(guān)的業(yè)務(wù)了,但是代理好像還是可以
系統要求:
1:內核在2.6.18以上
2:iptables在1.3.5以上
3:內核中包含字符串匹配模塊。在.config文件中應有
CONFIG_NETFILTER_XT_MATCH_STRING=m
man手冊
iptables -m string -helpstring This modules matches a given string by using some pattern matching strategy. It requires a linux kernel >= 2.6.14. --algo bm|kmp Select the pattern matching strategy. (bm = Boyer- Moore, kmp = Knuth-Pratt-Morris) --from offset Set the offset from which it starts looking for any matching. If not passed, default is 0. --to offset Set the offset to which it starts looking for any matching. If not passed, default is the packet size. --string pattern Matches the given pattern. --hex-string pattern Matches the given pattern in hex notation. 常見(jiàn)的應用程序和有用的示例規則1:防止***的方法 iptables -I INPUT 1 -p tcp --dport 80 -m string --string "cmd.exe" --algo bm -j DROPiptables -I INPUT -j DROP -p tcp -s 0.0.0.0/0 -m string --algo kmp --string "cmd.exe"2: 保護DDOS服務(wù) iptables -I INPUT 1 -p tcp --dport 80 -m string --string "domain.com" --algo kmp -j DROP3: 防止電子郵件欺騙 iptables -I INPUT -p tcp --dport 25 -m string --string "Subject" --algo bm -j DROP 做個(gè)最優(yōu)規則 iptables -I INPUT -p tcp --dport 25 -m string --string "Subject" --algo bm --to 15000 -j DROP
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自互聯(lián)網(wǎng)轉載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權請聯(lián)系QQ:712375056 進(jìn)行舉報,并提供相關(guān)證據,一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容。
Copyright ? 2009-2021 56dr.com. All Rights Reserved. 特網(wǎng)科技 特網(wǎng)云 版權所有 珠海市特網(wǎng)科技有限公司 粵ICP備16109289號
域名注冊服務(wù)機構:阿里云計算有限公司(萬(wàn)網(wǎng)) 域名服務(wù)機構:煙臺帝思普網(wǎng)絡(luò )科技有限公司(DNSPod) CDN服務(wù):阿里云計算有限公司 中國互聯(lián)網(wǎng)舉報中心 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證B2
建議您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流瀏覽器瀏覽本網(wǎng)站