Blocking DNS DDoS attempts

| | Comments (0) | TrackBacks (0)

I've noticed a lot of DNS requests for ./NS/IN lately, usually with a source IP in the 69.63 region used by Facebook’s Chinese servers:

Jun 24 12:37:25 named[2892]: client 69.63.180.238#32934: query (cache) './NS/IN' denied
Jun 24 12:37:26 named[2892]: client 69.63.180.238#32934: query (cache) './NS/IN' denied
Jun 24 12:38:04 named[2892]: client 69.63.186.213#38594: query (cache) './NS/IN' denied
Jun 24 12:38:05 named[2892]: client 69.63.186.213#38594: query (cache) './NS/IN' denied
Jun 24 12:38:05 named[2892]: client 69.63.180.242#33150: query (cache) './NS/IN' denied

A bit of research led to this post that taught me these are probably spoofed IP addresses conducting a DDoS on the Facebook servers. What happens is that the perpetrator sends the request to many DNS servers, seemingly coming from the victim — who then receives all the answers. In an improperly-configured DNS server allowing external requests for domains outside its jurisdiction, a fairly length reply is sent; correctly-configured servers send a “refused” message. Either way, the poor victim ends up having to deal with a lot of network traffic.

I wanted to block these. There is no circumstance in which an external address should be querying my server for the root domain, and I want to block this on principle. It is worth noting that my decision will have very little effect on the victim, who is being hit by thousands of responses from many servers.

The solution on the above-mentioned post is to use iptables with the u32 module. However, getting this to work on my Slicehost server proved too non-trivial for me to bother with, so I devised a simpler solution.

Having done some packet logging with iptables, I determined that the packets I wanted to drop were shorter than valid requests. This doesn’t come as a surprise: valid requests will contain one of my domain names whereas the DDoS packets were requests for the root domain “.”. This rule works for me:

Chain udp_inbound
target  prot opt source   destination
DROP    udp  --  anywhere anywhere udp dpt:domain length 1:51

…which drops packets up to length 51 (IP packet length, I think). The command line to get this rule to happen is below; you’ll need to adjust it to match your chain names, as I have a separate chain for processing inbound UDP packets like these:

iptables -A udp_inbound -p udp --dport 53 --match length --length 1:51 -j DROP

You should check the 51-byte limit works for you, blocking all external root requests but nothing else. This isn’t foolproof and infallible, but it works for me for now. Facebook China, contact me to find out where to send the reward for lightening the load on your servers ;-)

Where next?

Search the web:

Entry sequence:

Site contents:

Other entries in category:

Other entries tagged:

0 TrackBacks

Listed below are links to blogs that reference this entry: Blocking DNS DDoS attempts.

TrackBack URL for this entry: http://mark.tranchant.co.uk/mt-tb.cgi/38

Leave a comment

About this entry

This entry was posted on 24 June 2009 at 21:53.

iPod Shuffle 2G and Windows 2000 was the previous entry in this blog.

Photographing violet not possible is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Flickrings

February 2010

Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28