【问题标题】:iptables string match accept connectioniptables 字符串匹配接受连接
【发布时间】:2014-01-08 00:01:08
【问题描述】:

我对 iptables 和字符串匹配有疑问。我读过的大部分内容都会丢弃符合规则的数据包。当我使用它时,iptables 将断开与字符串“test”的任何连接

iptables -A INPUT  -p tcp --dport 80 -m string --string ! "test" --algo bm -j LOG --log-prefix ' INPUT TCP--- ' --log-level 4
iptables -A INPUT -p tcp --dport 80 -m string --string ! "test" --algo bm  -j DROP

所以当我去http://www.abc.com/?test时,连接不会通过。

我想做的是相反的,我可以使用字符串匹配来批准连接吗?

iptables -A INPUT  -p tcp --dport 80 -m string --string  "test" --algo bm -j LOG --log-prefix ' INPUT TCP--- ' --log-level 4
iptables -A INPUT -p tcp --dport 80 -m string --string  "test" --algo bm  -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j DROP

我只想允许连接到带有单词 test 的 80 端口,像这样...http://www.abc.com/?test

这个可以吗?

感谢您的帮助, 高尔基体

【问题讨论】:

    标签: string matching iptables


    【解决方案1】:

    他们做类似事情的正确方法是使用代理。使用 iptables 可以做到这一点,但绝对不是最好的解决方案。

    您不能允许带有指定字符串的连接,因为数据将在连接建立后出现。因此,您必须启用 TCP 握手的所有数据包,然后您必须允许带有字符串的数据包。使用此解决方案,您将拥有大量断开的连接:)

    【讨论】:

    • 您能解释一下如何设置代理来执行此操作吗?
    • 使用 Squid:acl blocktest url_regex test http_access deny blocktest
    • 我建议打开一个新问题 :)
    猜你喜欢
    • 2015-10-11
    • 1970-01-01
    • 1970-01-01
    • 2015-10-30
    • 1970-01-01
    • 1970-01-01
    • 2012-05-13
    • 2019-04-19
    • 1970-01-01
    相关资源
    最近更新 更多