linux – iptables:构建针对DNS放大攻击滥用的规则集

linux – iptables:构建针对DNS放大攻击滥用的规则集,第1张

概述我一直致力于构建一个规则集来检测和阻止DNS放大攻击. 我卡住了,希望能在这里找到帮助. 我将在这里发布我的内容(bash脚本,与DNS有关的部分): IPTABLES='/sbin/iptables -v' SERVERIP=a.b.c.decho '################ Previously initiated and accepted exchanges bypass ru 我一直致力于构建一个规则集来检测和阻止DNS放大攻击.

我卡住了,希望能在这里找到帮助.

我将在这里发布我的内容(bash脚本,与DNS有关的部分):

IPtableS='/sbin/iptables -v' SERVERIP=a.b.c.decho '################ PrevIoUsly initiated and accepted exchanges bypass rule checking #'$IPtableS --append input  -m state --state ESTABliSHED,RELATED     --jump ACCEPTecho '################################################ Allow unlimited outbound traffic #'$IPtableS --append OUTPUT -m state --state NEW,ESTABliSHED,RELATED --jump ACCEPTecho '################################################################## Rules for DNS #'# DIG ANY ISC.ORG attack preventer.# QUESTION1: this one does not work,why!?!?$IPtableS --append input --proto udp --dport 53 -m string --string "isc.org" --algo bm --to 65535 --jump LOG --log-prefix "iptables: UDP ISC0 "$IPtableS --append input --proto udp --dport 53 -m string --hex-string "|03697363036f726700|" --algo bm --to 65535 --jump LOG --log-prefix "iptables: UDP ISC "$IPtableS --append input --proto udp --dport 53 -m string --hex-string "|03697363036f726700|" --algo bm --to 65535 --jump DROP# DNS DNSIPSOK List$IPtableS --new DNSFLOODRulES$IPtableS --append DNSFLOODRulES --source 127.0.0.1 --jump RETURN$IPtableS --append DNSFLOODRulES --source $SERVERIP --jump RETURN$IPtableS --append DNSFLOODRulES --jump LOG --log-prefix "iptables: UDP BLOCK "$IPtableS --append DNSFLOODRulES --jump ACCEPT#$IPtableS --append DNSFLOODRulES --jump DROP# I have it turned off right Now,because echo '# S & D port rules'# DNS limit rule for standard acceptance# QUESTION2: can't get the connbytes to work properly :($IPtableS --append input --proto udp --source 0/0 --dport 53 \    -m state --state NEW \    -m connbytes --connbytes 75 --connbytes-dir reply --connbytes-mode bytes    -m limit --limit 1/s --limit-burst 10 --jump ACCEPT # DNS log / drop the abusers EXEPT the whiteListed IP numbers$IPtableS --append input --proto udp --source 0/0 --dport 53 -m state --state NEW --jump DNSFLOODRulES$IPtableS --append input --proto udp --source 0/0 --sport 53 -m state --state NEW --jump DNSFLOODRulES# DNS allow the whiteListed IP numbers$IPtableS --append input --proto udp --source 0/0 --dport 53 -m state --state NEW --jump ACCEPT$IPtableS --append input --proto udp --source 0/0 --sport 53 -m state --state NEW --jump ACCEPT

问题1:
为什么它需要是十六进制字符串,普通的字符串会更容易维护,但是那个字节不会字节,你能告诉我为什么吗?

问题2:
通过TCPdump我可以看到大多数答案都很小,因此需要列入白名单.还有本地主机(以及我自己的一些服务器,我广泛地查询名称服务器(DNSFLOODRulES).DNS放大攻击是一个持续激增的“大”答案,我想限制.
问题是我不能让’connbytes’部分工作.我一直在摸索它,也认为它应该是OUTPUT的艺术,因为它大约是答案的大小,而不是问题.我还尝试了“允许无限制的出站流量”部分,但这种情况非常糟糕.

非常感谢您的想法和帮助.

解决方法 问题1:

字符串不匹配,因为“.”不包含在数据包中. DNS数据包不包含“主机名”,而是“标签”.在数据包中,域名的每个部分都是一个标签,前缀为标签的字节数.

所以“isc.org”转换为:

isc: 03 69 73 63org: 03 6f 72 67

或者在数据包中:

03697363036f7267

每个标签限制为63个字节,整个名称限制为255个字节.

它在DNS RFC中解释:

http://tools.ietf.org/html/rfc1035#section-2.3.4

http://tools.ietf.org/html/rfc1035#section-4.1.2

问题2:

您需要启用net.netfilter.nf_conntrack_acct标志才能使用conntrack选项(请参阅iptables联机帮助页).但我不认为这样使用它是明智的.始终存在大包的合法答案.

也许你最好使用hashlimit扩展.已经提到过:

https://lists.dns-oarc.net/pipermail/dns-operations/2012-October/009321.html

总结

以上是内存溢出为你收集整理的linux – iptables:构建针对DNS放大攻击滥用的规则集全部内容,希望文章能够帮你解决linux – iptables:构建针对DNS放大攻击滥用的规则集所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1040588.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存