html tool

2021年6月3日星期四

转:iptables禁止域名访问

 参考:

https://www.twle.cn/t/539

https://blog.opstree.com/2020/09/15/is-iptable-a-good-fit-for-a-domain-name/


iptables -A INPUT -m string --algo kmp --string "search words" -j DROP

上面这条语句,使用 kmp 字符串查找算法,对输入的请求,如果网址(包含域名)中包括了字符串 "search words",则会被 iptables 直接拒绝

比如说,有一个网址如下

https://www.twle.cn/l/yufei/minigame/minigame-basic-index.html
  1. 如果我们想禁用所有域名为 twle.cn 的请求,则语句如下

    iptables -A INPUT -m string --algo kmp --string "twle.cn" -j DROP
    
  2. 如果我们想禁止访问网址中包含 /minigame 字符串的请求,则语句如下

    iptables -A INPUT -m string --algo kmp --string "/minigame" -j DROP
    

需要注意的是,这条语句是通杀,也就是网址中包含了 /minigame 的请求都会被拒绝

没有评论:

发表评论