How and why I run my own DNS servers
bugsplat.info
bugsplat.info
So a few months go by, everything has been fine and then another DDoS hits. Looking through the web-servers, not hitting there, all is fine. Study firewall traffic through the network and note that the majority of incoming traffic (that was making it through to the network that is), was headed to the DNS servers. The attackers were sending the DDoS to the DNS servers, requesting some of our root domains and given that it appeared as valid traffic there was not much to be done to filter any of it. The easy solution in this case happened to be blocking all Chinese and Russian IP's for a couple days which mitigated enough of it to solve. After that, we stopped hosting our own DNS.
Moral of the story: DNS services are a great learning tool to use and PowerDNS is probably where you want to start, but at scale you may or may not want to actually run your own.
Would like to point out that ddos is a ymmv item obviously for anyone scared off by the potential for this which is the same as the potential for any ddos attack and mitigation. A company affiliated with ours has been managing dns for a customer since 1996 with 10k zones. Back when you had to read Cricket Liu Oreilly book. (movie.edu if anyone remembers). They've never experienced a problem. All run on pretty low powered hardware for that matter.
That said there are things to know about dns while not difficult time could be better spent elsewhere if there is no compelling reason to diy.
For that matter, I don't know of a reputable DDoS mitigation service that doesn't provide DNS hosting as part of the package. It's pretty core to the whole thing.
Registrar here. This may be a requirement of some registrars but not a requirement of all registrars. And in any case you can fake this (see warning) by simply using the same IP address with a different host name or by using a different IP address with a made up IP address.
Warning: Obviously you should have two valid DNS servers no doubt. I am simply pointing out that there are work arounds to this especially if you are trying to get up and running and won't have the 2nd dns operational for a short period of time you can at least get started with DNS that should work (since it only takes one and assuming that one is working you will be serving up records.)
I'll leave you to guess which one. :)
Jay [at> jaytaylor dot com
The registrar could have another one.
.com .net "require" only 1 nameserver (Verisign). PIR/Afilias require two (hence the need to fake or use a real one).
Please note also that my parent comment was with regards to the statement "the registrars require you to list two IP addresses" not why that may or may not have been required by the registry.
It's possible of course that even though .com .net only require one nameserver, a registrar might require two for some reason. It's also possible (but unlikely) that even though .org requires two the registrar could take care of this by putting in a dummy record if they wanted and only requiring one of the customer.
End users don't deal with the registry. They deal with the registrar.
We are an ICANN accredited registrar.
Updating and querying the name records is a piece of cake thanks to the MySQL database, and if I ever get around to finishing it, I can have my own web-based front-end for it.
Best of all, I can have a nice, short ttl on all of my entries, and PowerDNS is configured to always check the database, so I have a two minute refresh period on any changes made to entries on my name servers -- that alone has been well worth running my own. (Client: "Don't I have to wait like a few hours or a day or something for this to spread over the internet or something?" "Nope. 'Bout two minutes in most cases, little bit more for AT&T's customers.")
I definitely didn't do it right the first time, though. DNS has a few gotchas, like making sure you disable axfr requests, making sure you have an SOA record for appropriate zones, and so on. I'm probably still doing something wrong, but I don't know what it is at this point. Also, the default recommended PowerDNS MySQL setup is needlessly complex, as far as I can tell.
If you finish it let me know. I would be interested in possibly buying the front end from you (even if it's rough wouldn't be customer facing.)
PowerDNS Tango is the prettiest looking one.
Sure, Google can get away with a 600 second TTL because there is so much traffic that only one person in a million will have to wait.
Do I care that every visitor has to wait a little bit more every few pages or so? Yes, of course I do. But you fail to understand our business or customers at all when you think that a delay caused by a short ttl in dns is a problem that we need to address right now.
A much bigger problem for our customers is when they call or email and ask for help with some kind of hosting change -- moving onto or off of our servers or changing some service or some such thing -- and they get told that there will be a period of minutes or hours or maybe even a day or two where visitors will see either the new version or the old version and no, we can't say which.
When we tell people that, yes, we can change their mail services for them, and by the way, that change should be instantaneous for most people, they are delighted. And delighting our customers is what's most important to us.
Further, you fail to realize that most of our hosting customers are coming from services like BlueHost or GoDaddy, where their sites have probably been living on overprovisioned servers and so they get better performance with us anyway, which also delights them.
You also don't realize that our average customer, so far, is running a poorly optimized WordPress or Joomla installation, and that either of those systems introduces page delays that are far more severe than a DNS lookup. In other words, our customers are not currently people that are looking for the fastest possible website; they merely want it to be "fast" -- which usually means, "renders in about a second or less on my crappy 1.5Mb DSL" -- but mostly, they want it to always be up and they never want to worry about backups or hackers or phishing or viruses or anything else.
So, yeah, once short ttls start to cause problems -- a la an email from a customer saying, "hey, I just profiled my site, and I noticed it's taking an extra 132 ms to load because of a dns lookup, can you check into that" (a message which we haven't even come close to receiving yet) -- then that'll become a bigger issue and I'll address that instead of whatever else I'm working on at the time.
I know I shouldn't get irritated at comments like yours -- I should simply ignore them -- but they bug the hell out of me because you probably don't even realize what the effect is. You're not sharing helpful information; you're not telling me something about short ttls that I didn't already know; you're not telling me about some bug in PowerDNS caused by ttls less than 194 or that ttls less than 233 can cause issues with MySQL if you have more than pi requests/second. The only thing that comments like this do is further demotivate me from sharing information like this in the future. My thought process before commenting in a thread about server configuration is already something like, "Hey, should I bother to mention how we do this? It was a bit fiddly and there's some bad documentation out there. Someone might ask a question that I could answer. Someone might mention something I don't know about. That could be good. But probably someone's just going to tell me I'm wrong. Am I in the mood for that? Nah, not really."
Sorry for slamming you with a wall-o-text response. I had thought about the last time KeepAlive was mentioned in an HN thread before posting my comment about PowerDNS; you just happened to make me feel like an idiot for not listening to my instincts and deciding to not comment in this thread.
By doing that you achieve two great things. First, you help people who genuinely need your caring comments on real world experience. Secondly, you don't feed attention whores.
Great post by the way. You saved me weeks of hair pulling by showing that once you achieve the right mindset this problem, like any other, can be realistically managed.
Finally, have happy new year!
I come from a different background. I bootstrapped a SaaS business that now has about 10 employees. I spent a bunch of time thinking about the best DNS solution for us. My conclusion was that we should go with the most expensive provider coupled with long TTLs. The most expensive provider was because of SEO reasons, and long TTLs are best for PPC conversion rates.
The IP for SSH access should then be heavily filtered to only SSH and the requisite ICMP packets.
Have you considered using Route53 / Cloudflare?
I had considered Route53 but it's actually in the same ballpark as this setup, money wise, and it's less flexible for what I want it to do. I haven't evaluated Cloudflare at all yet.
Of course you need to not run an open DNS resolver which means 'don't do recursive lookups for anything except your trusted addresses'. I saw one setup that worked really well which was to only do recursive lookups from loopback, then client would create a vpn tunnel to the dns server, get their dns service that way. Seemed a bit extreme but it allows off site DNS service.
Its not a bad idea, it just happens that careful sshd practices are good enough that more layers are subject to highly diminished returns.
Your config is bad. Mine is set up for a 12 hour ban. From my logs, it's perfectly sufficient to drop all scanners (I rarely see an IP banned more than twice, and even twice is not common).
If I were to login from a place where an attacker is trying to log in, I would actually appreciate not being exposed - they might only be using networks, but they might also be using cameras and other stuff that would compromise my info.
It was particularly fun to watch young people who were new to the scene sort of freak out at this weird architecture. Old farts were easy to spot, they would start right away with a 'show dev' or 'set host' to try to move around the network. Kind of like a hacker aquarium.
Kudos for having multiple vaxes(n?)!
SendEnv in ssh_config? AcceptEnv in sshd_config? No specifics cited in the man pages.
[Later] Actually, those two have no effect on my remote Debian 6 VPS. Possibly a Debian "fine-tuning".
I don't use a self-hosted secondary. I use a secondary-as-a-service as my secondary /and primary/, which has the advantage of my VPS going down (for less than 4 weeks) wouldn't impact my DNS's uptime.
I blogged about it this month: https://tom-fitzhenry.me.uk/blog/2012/12/host-your-own-dns-w...
I say "noticeable issues", because although my DNS is monitored, the monitoring isn't granular enough to detect sub-minute outages, for example.
Did you have any issues in particular with the stealth primary solution?
DNS NOTIFY is standardised in: https://tools.ietf.org/rfc/rfc1996.txt
BIND 8+ supports it by default, according to http://docstore.mik.ua/orelly/networking_2ndEd/dns/ch10_03.h...
There is a perl script to achieve the same thing in djbdns, according to http://www.fefe.de/djbdns/#notify (which joe_bleau alluded to).
http://cr.yp.to/djbdns/axfrdns.html
It does. I'm doing this currently, I host primary DNS myself with tinydns, and the makefile sends a notify to the registrar-hosted slave DNS, which gets data via this daemon (with tcp server configured to only allow that IP).
I guess this is progress. It just seems strange to me.
If you host with Linode I can't see why you wouldn't use it, unless you are just futzing/curious to roll your own.
I run my own servers with postfix, dovecot and roundcube. Therefore I don't need Gmail for anything. (It's also huge privacy issue.)
I've got around this by having two hostnames for one machine.
The way I see it, since all my services are on this one machine anyway, I'll have bigger problems than DNS if the machine is down: there will be nothing at the address the names are pointing to, so who cares if they resolve properly?
Many applications do plan for unreachable services, but throwing the fault down the stack screws up how the error is handled. You can still use a primary application server box as a DNS server, but I would be certain that it's a secondary/slave server, not the primary server.
Even with a single machine it's still better to have redundant DNS. You want to be able to move around the machine to a new connection / IP, without having to wait for the registrars to update the IP of the DNS server; similarly when your one DNS provider is DDOSed, your site will stop working, but not if you had 2 different providers. So to answer your question: you as the operator will care, because you want to get things back up quickly ...
I think for small servers it's much preferable to run a hidden primary (not publicly listed in DNS), and let secondary DNS servers update from there. That way you have complete control over your DNS, even when your machine goes down.
As recently as a few months ago, I hosted my own DNS server on a Linksys SLUG, but after I suffered a power outage and realized that there's no reason for hosting this stuff myself, I just decided to use namecheap.com for their Free DNS service.
As for SSH, just move it on to a port other than 22, that will fix 99% of the bots trying to guess your password.
fail2ban || denyhosts are also good ways of stopping ssh brute force :)
There are some added bonuses if you happen to be using other AWS services, but even without those, I think Route53 is one of Amazon's better offerings.
For non-authorative local DNS caches:
twistd dns --recursive --cache
For authorative servers, to serve a BIND-style zonefile: twistd dns --bindzone ZONEFILE
But, of course, that's pretty boring. The fun stuff is when you have a Python source file as your zonefile! See: https://twistedmatrix.com/documents/current/names/howto/name...twisted.names (that's the name of the DNS package) is simple enough to use for DNS serving (demonstrated above) and flexible enough to get it to do pretty much whatever you want.