{"id":19,"date":"2015-04-15T16:11:19","date_gmt":"2015-04-15T14:11:19","guid":{"rendered":"https:\/\/blog.unetresgrossebite.com\/?p=19"},"modified":"2015-04-16T13:39:53","modified_gmt":"2015-04-16T11:39:53","slug":"dns","status":"publish","type":"post","link":"https:\/\/blog.unetresgrossebite.com\/?p=19","title":{"rendered":"DNS"},"content":{"rendered":"<p>Wondering on wikipedia, we can learn in the early ages of the Internet, some guy at Stanford Research International maintained a file mapping alphanumeric hostnames to their numeric addresses on the ARPANET.<br \/>\nLater on, the first concepts were defined (<a title=\"RFC882\" href=\"http:\/\/tools.ietf.org\/rfc\/rfc882.txt\" target=\"_blank\">RFC882<\/a> and <a title=\"RFC883\" href=\"http:\/\/tools.ietf.org\/rfc\/rfc883.txt\" target=\"_blank\">RFC883<\/a>, then superseded by <a href=\"http:\/\/tools.ietf.org\/rfc\/rfc1034.txt\">RFC1034<\/a> and <a href=\"http:\/\/tools.ietf.org\/rfc\/rfc1035.txt\">RFC1035<\/a>), leading the the first implementation (bind, 1984).<\/p>\n<p>I&#8217;m not especially familiar with the history of a technology older than me, and yet DNS servers are one of the few cornerstones of networks, from your local network to Internet as we know it.<br \/>\nThe idea hasn&#8217;t changed since ARPANET: we prefer to use human-readable juxtaposed words, over a 4 digits identifier, to access a service. Thus, we&#8217;ve multiplied contributions to scale, redound, decentralize or secure a unified and standardized directory.<\/p>\n<p>While hosting your own DNS server could be pretty straight-forward, popular services are usually popular targets, with their flows. Taking care of defining the function that would implement your server is crucial, though usually overlooked.<\/p>\n<p>The most common attack targeting DNS servers is well known, exploiting poorly configured servers since over 10 years : amplification attacks.<br \/>\nAn attacker would spoof its IP to his victim&#8217;s one, querying for ? ANY isc.org (64b in), resulting in a ~3200b answer. Depending on UDP: no connection state. Spoofing only requires you to write your headers properly (without being able to answer some ACK), which makes any UDP protocol especially vulnerable.<br \/>\nAssuming your DNS server answer to such queries, our attacker would have amplified its traffic by 50, as well as hidden his address.<br \/>\nNote\u00a0while you may configure ACLs at software level, even a denied client would be answered to.\u00a0To avoid sending anything that may end up in a DDOS attempt, there&#8217;s nothing like a goodol&#8217; firewall.<\/p>\n<p>While carrier-grade solution may involve reverse-route checking of inbound traffic, the only thing to do for us regular folks, is to restrict accesses to our DNS servers, to the very clients we know.<br \/>\nRenting servers in Dedibox and Leaseweb facilities, I&#8217;ve found out both management interfaces allow me to replicate my zones in their DNS servers. Thus, my split-horizon is configured to publicly announce Leaseweb and Dedibox&#8217;s NS as my masters, while these are the only public clients allowed to reach my masters.<\/p>\n<p><strong>Bind \/ named<\/strong><\/p>\n<p>The historic implementation, most widely-spread. Its only concurrent in terms of features being PowerDNS.<br \/>\nBind implements what they call DLZ (Dynamically-Loadable Zones), allowing the storage of records in a database such as PostgreSQL or ODBC.<br \/>\nHaving tested the OpenLDAP connector for a few years, I&#8217;ld mostly complain about being forced to patch and build my own package (RFC3986, http:\/\/repository.unetresgrossebite.com\/sources\/dlz-ldap+r1-9.9.3-P2.patch), and being unable to resolve adresses containing characters such as &#8216;(&#8216;. In the end, keeping my databases as plain file is easier to maintain.<\/p>\n<p>Its usages include authoritative zone serving, zone replication and caching, split-horizon, TSIG, IPv6 and wildcard records, records caching, DNS &amp; DNSSEC resolution and recursion, lying DNS using RPZ, &#8230;<\/p>\n<p>see:<\/p>\n<ul>\n<li><a href=\" https:\/\/gitlab.unetresgrossebite.com\/DevOps\/puppet\/tree\/master\/modules\/named\" target=\"_blank\">Current puppet repository, named module<\/a><\/li>\n<li><a href=\"https:\/\/gitlab.unetresgrossebite.com\/DevOps\/ansible\/tree\/master\/roles\/named\" target=\"_blank\">Former ansible repository, named module<\/a><\/li>\n<li><a href=\"https:\/\/gitlab.unetresgrossebite.com\/DevOps\/puppet-3.0\/tree\/master\/modules\/bind\" target=\"_blank\">Former puppet repository, dind module<\/a><\/li>\n<\/ul>\n<p><strong>Unbound<\/strong><\/p>\n<p>A relatively new solution (2004), targeting cache and DNSSEC related features.<br \/>\nIf you may declare records in your configuration, Unbound won&#8217;t answer to transfert queries, and thus does not qualify as an authoritative name server.<br \/>\nUnbound is perfect either for home usage, or as a local cache for your servers.<\/p>\n<p>Also vulnerable to amplification attacks, keep in mind to deny accesses from unexpected clients.<\/p>\n<p>see:<\/p>\n<ul>\n<li><a href=\" https:\/\/gitlab.unetresgrossebite.com\/DevOps\/puppet\/tree\/master\/modules\/unbound\" target=\"_blank\">Current puppet repository, unbound module<\/a><\/li>\n<li><a href=\" https:\/\/gitlab.unetresgrossebite.com\/DevOps\/ansible\/tree\/master\/roles\/unbound\" target=\"_blank\">Former ansible repository, unbound module<\/a><\/li>\n<li><a href=\" https:\/\/gitlab.unetresgrossebite.com\/DevOps\/puppet-3.0\/tree\/master\/modules\/unbound\" target=\"_blank\">Former puppet repository, unbound module<\/a><\/li>\n<\/ul>\n<p><strong>NSD<\/strong><\/p>\n<p>NSD is a drop-in replacement for BIND zone serving features, while it won&#8217;t provide with split horizon, caching or recursive DNS resolution.<br \/>\nIts features being restricted to serving and replicating zones, NSD only applies for authoritative usage and should be used in conjunction with some cache solution such as Unbound.<\/p>\n<p><strong>Dnsmasq<\/strong><br \/>\nOne of the most popular implementation, embedded in devices such as cable box routers, Linksys WRT54-G mods, or even Ubuntu desktop installations. The key feature being Dnsmasq is a DNS server, embedding a DHCP server. Or vice-versa.<br \/>\nLike Unbound, serving configured records is possible, though Dnsmasq is not authoritative.<\/p>\n<p>Vulnerable to amplification attacks, but most likely not to be exposed.<\/p>\n<p>see:<\/p>\n<ul>\n<li><a href=\" https:\/\/gitlab.unetresgrossebite.com\/DevOps\/puppet-3.0\/tree\/master\/modules\/dnsmasq\" target=\"_blank\">Former ansible repository, dnsmasq module<\/a><\/li>\n<\/ul>\n<p><strong>UTGB Refactoring<\/strong><\/p>\n<p>Back on the subject, refactoring my services. Today&#8217;s topic, obviously, DNS.<\/p>\n<p>Being particularly found of my split-horizon, NSD does not apply in my case.<br \/>\nContinuing to validate and deploy my puppet modules, reinstalling my self-hosted services, I&#8217;ve ended up setting a new BIND server, rewriting my zones from LDAP to plain-text files.<br \/>\nAfter several spontaneous rewrites from scratches over the last few years, one thing I often miss managing my DNS zones, is the ability to synchronize a set of values (let&#8217;s say, NS, MX and TXT records) towards all my zones, without having to edit 30 files. Thus, you&#8217;ll note the latest named module used in my puppet repository stores temporary zones in <em>\/usr\/share\/dnsgen<\/em>, and allow you to use a single SOA record template as well as a coupe of zone headers and trailers to generate an exhaustive split-horizon configuration.<\/p>\n<p>Next step on the subject would be to setup some key infrastructure, then publish my key to Gandi and serve my own DNSSEC records, &#8230;<\/p>\n<p>Meanwhile, I&#8217;ve started replacing my DNS caches as well. From unbound to unbound.<br \/>\nThe specificity of my caches, is that their configuration declare about 100.000 names, redirecting them onto some locally-hosted pixel server.<br \/>\nThe big news in this new version of unbound module, is that the names source isn&#8217;t static any more, and would be regularly downloaded and updated. Actual list now include around 6.000 entries, and might be completed later on.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wondering on wikipedia, we can learn in the early ages of the Internet, some guy at Stanford Research International maintained a file mapping alphanumeric hostnames to their numeric addresses on the ARPANET. Later on, the first concepts were defined (RFC882 and RFC883, then superseded by RFC1034 and RFC1035), leading the the first implementation (bind, 1984). [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=\/wp\/v2\/posts\/19"}],"collection":[{"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=19"}],"version-history":[{"count":7,"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=\/wp\/v2\/posts\/19\/revisions"}],"predecessor-version":[{"id":30,"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=\/wp\/v2\/posts\/19\/revisions\/30"}],"wp:attachment":[{"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.unetresgrossebite.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}