Making the Case for Access Controlled Recursive Lookups with BIND

To see how I actually solved this particular problem please see Thwarting the isc.org DDoS

It has long been held as best practice that one should use separate servers for authoritative (server) and recursive (client) domain name services. In some cases, this is not practical - for example I inherited one particular network at an ISP I do consulting for that has had its combined authoritative and recursive DNS servers on the same IP addresses for about a decade. Splitting up the roles of the servers would require either hundreds of clients with statically configured DNS to change their settings (imagine the load on tech support) or dozens of domain-holders to update their registrar glue, assuming their registrar even provides it (another load on tech support).

On this network I had - contrary to the gospel I know only too well - allowed recursive lookups from any source on the Internet for several years. I knew it was ideologically incorrect but have found it immeasurably handy to have a set of memorized nameserver IPs that you know will just work any time, anywhere in the world when you are tech supporting or trying to resolve an issue. No one seemed to notice for the years before and after I took on this client, and I couldn't see the harm if a few folks started using them. It didn't - and still doesn't - make sense to me that a spammer would outsource their DNS operations to a vastly remote location (see updates at bottom, they are spammers but they're actually trying to DDoS), at the cost of not only speed and latency but expensive bandwidth at all.

But today they did.

At around 12:40 I was notified of the situation and began my investigation. Handy-dandy iftop told me it was coming from one IP and they were making DNS requests - good news! The server wasn't hacked - it was just being DoSed as a side-effect of over-querying. In fact, named was performing exceptionally well for a ~5-mbit/s load on a tiny virtual machine used to 150kbit/s, it was only the upstream bandwidth throttling that was keeping the flow in check.

I ran a full port scan on the attacker and much to my surprise it didn't respond to pings and all ports were filtered. I was growing suspicious that this wasn't a typical zombie. I blocked the attacker at the gateway and for a moment the network settled down. Then out of nowhere another attacker from a completely different IP showed up - I gave them a full scan and they too were filtered and unresponsive to ICMP echo requests. The new attacker came from but forward lookups didn't work. I didn't have to go to their website to realize this was a VPS provider, clearly I was dealing with someone who owned their own kit - an organized spammer. My suspicions confirmed, I knew I would have to give up my little "public" DNS service and implement an Access Control List for recursive lookups.

By the time the third and most aggressive (getting pissed off about the IPs I was blocking?) wave of queries rolled around I had collected a list of all the networks and public addresses which require recursive lookups. Regardless of whether you have your authoritative services separated from your recursive unless your recursive server is on a private network it is best practice (and even then I would recommend it) to implement an ACL.

Open your named.conf and before the global options section, define an ACL as shown below. Notice that address ranges can be specified with CIDR notation:

acl "trusted" {

Now we can call the trusted ACL with the allow-recursive directive in the global options section. You can define any number of ACLs with different names, we're just going with trusted as an example. Make sure the ACL includes every network and IP address that should have permission to perform recursive lookups - ensure your private subnets, public networks and any stray uplinks or remote locations are included. Those hosts not in the ACL and not performing lookups on domains for which your server is authoritative or already has cached will fail.

options {
 recursion yes;
 allow-recursion { trusted; };
 allow-query-cache { trusted; };

Run rndc reload or restart BIND for the changes to take effect.

As you can tell from the bumps in my graph after the giant spike this guy (or these guys) is taking his time trying to figure out what I did, but the good news is he's using less bandwidth and a whole whack of spam ain't goin nowhere. Eventually they will realize that this server isn't doing them any good and they'll move on to greener pastures.

Finally, I got one of the attackers post-ACL to submit to a scan:

bzp ~ # nmap -P0

Starting Nmap 5.00 ( http://nmap.org ) at 2010-07-20 18:15 EDT
Interesting ports on
Not shown: 990 closed ports
21/tcp   open     ftp
22/tcp   open     ssh
23/tcp   open     telnet
25/tcp   filtered smtp
80/tcp   open     http
139/tcp  filtered netbios-ssn
445/tcp  filtered microsoft-ds
646/tcp  filtered ldp
2000/tcp open     callbook
8291/tcp open     unknown

Nmap done: 1 IP address (1 host up) scanned in 390.66 seconds

Well, that looks like any number of shared hosting servers, I wonder what's on port 80:

An embedded linux routing solution. And their webconfig is wide open to cracking.

MikroTik RouterOS is the operating system of MikroTik RouterBOARD hardware.

It can also be installed on a PC and will turn it into a router with all the necessary features - routing, firewall, bandwidth management, wireless access point, backhaul link, hotspot gateway, VPN server and more.

RouterOS is a stand-alone operating system based on the Linux v2.6 kernel, and our goal here at MikroTik is to provide all these features with a quick and simple installation and an easy to use interface.

You can try RouterOS today, go to www.mikrotik.com and download the installation CD image. The free trial provides all of the features with no limitations.

If I had to guess I'd say this guy went the server route, or maybe he virtualizes his gateways like me. This kind of explains why my port scans are being cut off, a sufficiently advanced firewall like this probably has some sort of Intrusion Prevention mechanism and since I caught them with their web config (and telnet config for that matter) exposed and flapping in the breeze I'd say this is one of the installations my friend the spammer has not completed configuring, hence this one successful scan.

For the interest of Googlers trying to figure out why so and so is blasting the shit out of their name server(s) one IP at a time, here's a list of IPs and PTRs (where available) I've caught so far:   sju13-2-82-225-94-140.fbx.proxad.net   something from schlund.de  RIPE says the block belongs somewhere in Dubai    hosted by dragonara.net, listed as comment spammer by project honeypot  hosted by ev1servers.net MOLECHART.com  hosted by schlund.de  hosted by schlund.de     Rogers (Wave ???)   Italian-show-passion-quality-hostserver.com (lol)     Rogers (Wave ???)  server12.elnastalk.com

Update I found spamming on a strange Iraqi forum that reveals posters' IP addresses to the general public. Strange indeed, but now I know I'm dealing with web form spammers, not e-mail spammers. Here's a sample of the spam found at http://www.iraqal7ob.com/vb/t710.html

The image at the top was hotlinked from a free hosting service, the exact URL was http://hosting.bearzddl.com/uploads/9b0b60d466.jpg. Bearzddl is itself a shady file site and at the time of writing http://hosting.bearzddl.com/uploads/ provides a directory listing of all sorts of spammy looking images that have been uploaded through their free file hosting feature:

Update This morning we were attacked once again, I took the following sample capture:

 11.695249 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.695449 xxx.xxx.xxx.xxx -> DNS Standard query response RRSIG RRSIG DS DS NS ams.sns-pb.isc.org NS ns.isc.afilias-nst.info NS ord.sns-pb.isc.org NS sfba.sns-pb.isc.org
 11.705516 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.705891 xxx.xxx.xxx.xxx -> DNS Standard query response RRSIG RRSIG DS DS NS ns.isc.afilias-nst.info NS ams.sns-pb.isc.org NS sfba.sns-pb.isc.org NS ord.sns-pb.isc.org
 11.723779 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.723787 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.723983 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.723989 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.724154 xxx.xxx.xxx.xxx -> DNS Standard query response RRSIG RRSIG DS DS NS sfba.sns-pb.isc.org NS ams.sns-pb.isc.org NS ns.isc.afilias-nst.info NS ord.sns-pb.isc.org
 11.724333 xxx.xxx.xxx.xxx -> DNS Standard query response RRSIG RRSIG DS DS NS ord.sns-pb.isc.org NS sfba.sns-pb.isc.org NS ns.isc.afilias-nst.info NS ams.sns-pb.isc.org
 11.724495 xxx.xxx.xxx.xxx -> DNS Standard query response RRSIG RRSIG DS DS NS ams.sns-pb.isc.org NS ns.isc.afilias-nst.info NS sfba.sns-pb.isc.org NS ord.sns-pb.isc.org
 11.724648 xxx.xxx.xxx.xxx -> DNS Standard query response RRSIG RRSIG DS DS NS ams.sns-pb.isc.org NS ord.sns-pb.isc.org NS sfba.sns-pb.isc.org NS ns.isc.afilias-nst.info
 11.725244 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.725256 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.725488 xxx.xxx.xxx.xxx -> DNS Standard query response RRSIG RRSIG DS DS NS sfba.sns-pb.isc.org NS ord.sns-pb.isc.org NS ns.isc.afilias-nst.info NS ams.sns-pb.isc.org
 11.725645 xxx.xxx.xxx.xxx -> DNS Standard query response RRSIG RRSIG DS DS NS ns.isc.afilias-nst.info NS ord.sns-pb.isc.org NS ams.sns-pb.isc.org NS sfba.sns-pb.isc.org

See how this story progressed:



• cotters07

I dont know if you ever found a solution to this? I didn't so I have written my own UDP packet filter that is presented as a Windows Service (64bit although I can provide a 32bit version if necessary).

Its configurable so multiple domains can be specified in the filter but I only have a problem with isc.org from botnets participating in the DNS Reflection/Ampflication attack.

Although I cannot erradicate the inital 50-64 byte request, the filter drops the that request before the DNS server receives and processes it, saving up to 140GB/month in upload bandwidth on my connection.

If you (or anybody else is interested) please contact me at [email protected]


This DoS is from this servers list

Thwarting the isc.org DNS DDoS | foxpa.ws

[...] I posted an article regarding the importance of ACLs in BIND because a client’s DNS server was under extreme load [...]