<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>HostingFu &#187; opendns</title>
	<atom:link href="http://hostingfu.com/tag/opendns/feed" rel="self" type="application/rss+xml" />
	<link>http://hostingfu.com</link>
	<description>Web Hosting Blog by a Software Developer</description>
	<lastBuildDate>Mon, 19 Jul 2010 09:27:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Fast Domain Name Resolution with OpenDNS + Local Cache</title>
		<link>http://hostingfu.com/article/fast-domain-name-resolution-with-opendns-local-cache</link>
		<comments>http://hostingfu.com/article/fast-domain-name-resolution-with-opendns-local-cache#comments</comments>
		<pubDate>Thu, 25 Jan 2007 07:36:37 +0000</pubDate>
		<dc:creator>scotty</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[opendns]]></category>

		<guid isPermaLink="false">http://hostingfu.com/?p=85</guid>
		<description><![CDATA[Domain name resolution is a very important building block of the Internet today. It translates domain/host names into IP addresses, so your browser would know how to reach this page (okay, I know it is more complicated than that, but&#8230;) At the same time, a slow or broken DNS system can be very frustrating, even [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://hostingfu.com/files/images/opendns-logo.png" alt="OpenDNS Logo" style="float:right;margin:0 0 1ex 1ex"/> Domain name resolution is a very important building block of the Internet today. It translates domain/host names into IP addresses, so your browser would know how to reach this page (okay, I know it is more complicated than that, but&#8230;)</p>
<p>At the same time, a slow or broken DNS system can be very frustrating, even when you are just hosting a service. Little did I realise that how much a typical hosting server depends on domain name services. If you are on a Linux/Unix box, try to remove <code>/etc/resolv.conf</code> from your server for 5 minutes, and see how it can cope.</p>
<p><span id="more-85"></span></p>
<p><a href="http://www.opendns.com/">OpenDNS</a> came to rescue, and its aim is to provide fast and reliable domain name service to everyone &#8212; not just those who browse the web, but it can also benefit those who host a few servers. See my post on <a href="http://hostingfu.com/article/how-opendns-saved-my-day">how OpenDNS saved my day</a>. It is a fast recursive DNS with a gigantic cache, and it rarely goes down &#8212; unlike the DNS server at your ISP.</p>
<p>In this article I will be looking at how to use OpenDNS to speed up DNS queries on your hosted servers. Moreover, how you can employ a local recursive cache to further improve the domain name resolution performance.</p>
<h3 id="toc-step-1-signing-up-opendns">Step 1: Signing up OpenDNS</h3>
<p>No, you don&#8217;t have to sign up an OpenDNS account. You can simply use OpenDNS by pointing to their IP addresses. However there are a few benefits if you have an OpenDNS account, and they are actually quite useful if you are hosting a server.</p>
<ul>
<li><strong>Query statistics</strong>! You&#8217;ll get the daily queries + unique domains in pretty graphs. Everyone likes pretty graphs. No?</li>
<li><strong>Disable typo correction</strong>. By default OpenDNS will perform typo correction if the domain does not exist, however it is not desirable in about everything but web browsers. Having an account lets you turn off typo correction for your IP range.</li>
</ul>
<p>If you still decided against setting up an account there, then go straight to step 3. Otherwise, <a href="https://www.opendns.com/account/create_account.php">create an account here</a>, and all you need is a username, your email address and password.</p>
<h3 id="toc-step-2-manage-your-network-at-opendns">Step 2: Manage Your Network at OpenDNS</h3>
<p>After your account has been set up, you should be able to add networks under your OpenDNS account. OpenDNS will send you verification emails, and request you to visit a web page with a special key from that IP address to claim that network.</p>
<p>Now, add your server&#8217;s IP address there. You then will be able to manage your network/IP address after it has been verified. Go in there and <strong>turn off all features</strong>! You definitely do not want typo correction for your server, as it is necessary for programs to get back <code>NXDOMAIN</code> when the domain name is indeed non-existing.</p>
<p>Save preference, and you are done.</p>
<h3 id="toc-step-3-test-name-resolution-on-your-server">Step 3: Test Name Resolution on Your Server</h3>
<p>SSH into your server, and start testing OpenDNS&#8217;s service by putting their anycast servers in your <code>/etc/resolv.conf</code>:</p>
<pre class="code">
nameserver 208.67.220.220
nameserver 208.67.222.222
</pre>
<p>Then try to resolve a domain name.</p>
<pre class="code">
$ host hostingfu.com
hostingfu.com has address 63.76.232.80
</pre>
<p>Yup. Looks like it is working.</p>
<h3 id="toc-step-4-installing-a-local-recursive-cache">Step 4: Installing a Local Recursive Cache</h3>
<p>If your round-trip time to OpenDNS&#8217;s servers is small, i.e. you happen to be in the same data centre, then I won&#8217;t really worry about having a local cache. If you happen to have your servers across the pacific, taking 160ms to get to their Palo Alto resolvers, then a local recursive resolver/cache will make significant improvement. They will cache the resolving result according to TTL in the records, so subsequent queries do not need to go back to the root servers (or in our case, forward to OpenDNS).</p>
<p>For example, your server might send 30 emails to john@example.com during a 12 hour period. Instead of forwarding to a remote DNS server 30 times for MX records, it will only be done once, and the rest will be served from cache, if TTL on the MX record is greater than 12 hours.</p>
<p>There are many open source recursive DNS servers available, and these are the ones that I have experience with:</p>
<ul>
<li><a href="http://www.thekelleys.org.uk/dnsmasq/doc.html">Dnsmasq</a></li>
<li><a href="http://www.maradns.org/">MaraDNS</a></li>
<li><a href="http://dnrd.sourceforge.net/">Dnrd</a></li>
</ul>
<h4 id="toc-dnsmasq">Dnsmasq</h4>
<p><a href="http://www.thekelleys.org.uk/dnsmasq/doc.html">Dnsmasq</a> is probably the most feature rich and memory efficient of the bunch. It was designed to be deployed on a small LAN so it comes with DHCP capability and can act as authoritative DNS for your local network. I use it for my home network, but because of its small memory footprint, I also use it on my memory impaired VPS (it&#8217;s around 650kb RSS). Of course the DHCP feature is turned off on hosted servers.</p>
<p>However I am having issues with Dnsmasq on my OpenVZ VPS, and have not yet had a chance to dissect the code to figure out what&#8217;s going on.</p>
<p>Installation is easy if you are on Gentoo or Ubuntu, as the packages are already available.</p>
<pre class="code">
# emerge dnsmasq
</pre>
<p>Or</p>
<pre class="code">
# apt-get install dnsmasq
</pre>
<p>Now use the following configuration in <code>/etc/dnsmasq.conf</code>.</p>
<pre class="code">
domain-needed            # Never forward plain names
bogus-priv               # Never forward addresses in the non-routed address spaces
no-resolv                # Don't use /etc/resolv.conf
no-poll                  # Don't poll /etc/resolv.conf
server=208.67.222.222    # Forward to OpenDNS's servers
server=208.67.220.220
listen-address=127.0.0.1 # Listen and bind to only localhost
bind-interfaces
</pre>
<p>Now start the service.</p>
<pre class="code">
# /etc/init.d/dnsmasq start
</pre>
<h4 id="toc-maradns">MaraDNS</h4>
<p><a href="http://www.maradns.org/">MaraDNS</a> is a small, multi-threaded and easy to use DNS system, and is suitable as local recursive DNS cache. It can also act as an authoritative DNS server, although the rule of thumb usually is &#8212; don&#8217;t use the same server for authoritative and recursive DNS. I did not use it for my servers because of its memory usage, which is slightly larger than the others, and the fact that it spawns multiple processes when it starts.</p>
<p>Installation is also trivial, as it is available on Gentoo as well as Unbuntu (Edgy). It is however keyword-masked on Gentoo at the moment.</p>
<pre class="code">
# emerge maradns
</pre>
<p>Or</p>
<pre class="code">
# apt-get install maradns
</pre>
<p>Then put the follow configuration into <code>/etc/mararc</code>.</p>
<pre class="code">
ipv4_bind_addresses = "127.0.0.1"
chroot_dir = "/etc/maradns"
recursive_acl = "127.0.0.1"
upstream_servers = {}
upstream_servers["."] = "208.67.222.222, 208.67.220.220"
</pre>
<p>It basically makes MaraDNS to bind to localhost, chroot to <code>/etc/maradns</code> and forward requests to OpenDNS. Now to get the daemon up and running:</p>
<pre class="code">
# /etc/init.d/maradns start
</pre>
<h4 id="toc-dnrd">Dnrd</h4>
<p><a href="http://dnrd.sourceforge.net/">Domain Name Relay Daemon</a> is a caching, forwarding DNS proxy server. It is small, fast and have just enough feature to do what we want to do here. It does not even need a configuration file!</p>
<p>Installation on Gentoo is easy, as there&#8217;s already an ebuild for it.</p>
<pre class="code">
# emerge dnrd
</pre>
<p>And put the following configuration in <code>/etc/conf.d/dnrd</code>:</p>
<pre class="code">
DNRD_OPTS="-b -s 208.67.222.222 -s 208.67.220.220 -a 127.0.0.1"
</pre>
<p>If you are on other Linux distro, you will need to <a href="http://dnrd.sourceforge.net/download.php">download</a> and build the app yourself. As release 2.20.1 is the latest, here&#8217;s an example (I am using Optus Australia&#8217;s Sourceforge mirror):</p>
<pre class="code">
# wget http://optusnet.dl.sourceforge.net/sourceforge/dnrd/dnrd-2.20.1.tar.gz
# tar zxvf dnrd-2.20.1.tar.gz
# cd dnrd-2.20.1
# ./configure --prefix=/usr/local --disable-master
# make &amp;&amp; make install
# mkdir -p /usr/local/etc/dnrd
</pre>
<p>The last step (<code>mkdir</code>) is necessary as <code>make install</code> does not seem to create the directory where dnrd will chroot to. Now the binary will be installed as <code>/usr/local/sbin/dnrd</code>. We&#8217;ll also make an init script for it, and put it in <code>/etc/init.d/dnrd</code>.</p>
<pre class="code">
#!/bin/sh
. /lib/lsb/init-functions

DNRD_OPTS="-b -s 208.67.222.222 -s 208.67.220.220 -a 127.0.0.1"
case "$1" in
start)
  log_begin_msg "Starting domain name relay daemon..."
  start-stop-daemon -S -q -p /var/run/dnrd.pid -n dnrd -a /usr/local/sbin/dnrd -- $DNRD_OPTS
  log_end_msg $?
  ;;
stop)
  log_begin_msg "Stopping domain name relay daemon..."
  start-stop-daemon -K -q -p /var/run/dnrd.pid -n dnrd
  log_end_msg $?
  ;;
restart)
  log_begin_msg "Restarting domain name relay daemon..."
  start-stop-daemon -K -R 5 -q -p /var/run/dnrd.pid -n dnrd
  start-stop-daemon -S -q -p /var/run/dnrd.pid -n dnrd -a /usr/local/sbin/dnrd -- $DNRD_OPTS
  log_end_msg $?
  ;;
*)
  log_success_msg "Usage: /etc/init.d/dnrd {start|stop|restart}"
  exit 1
  ;;
esac
exit 0
</pre>
<p>Don&#8217;t forget to start it!</p>
<pre class="code">
# /etc/init.d/dnrd start
</pre>
<h4 id="toc-bind">BIND</h4>
<p>I guess if you are running your server as reseller web hosting service, you will probably have <a href="http://www.isc.org/index.pl?/sw/bind/">BIND</a> running. You can obviously run a recursive/cache name server on your existing instance of BIND, who might be currently acting as an authoritative server. However, it is not recommended, quoting <a href="http://www.isc.org/sw/bind/arm93/Bv9ARM.ch01.html#id2547076">ISC&#8217;s documentation</a>:</p>
<blockquote>
<p><b>Name Servers in Multiple Roles</b></p>
<p>The BIND name server can simultaneously act as a master for some zones, a slave for other zones, and as a caching (recursive) server for a set of local clients.</p>
<p>However, since the functions of authoritative name service and caching/recursive name service are logically separate, it is often advantageous to run them on separate server machines. A server that only provides authoritative name service (an authoritative-only server) can run with recursion disabled, <em>improving reliability and security</em>. A server that is not authoritative for any zones and only provides recursive service to local clients (a caching-only server) does not need to be reachable from the Internet at large and can be placed inside a firewall.</p>
</blockquote>
<p>Now, to run on forwarding, add the following configuration to the <code>options</code> section of your BIND&#8217;s configuration file (<code>/etc/named/bind.conf</code> on Gentoo).</p>
<pre class="code">
options {
  ...

  allow-recursion {
    127.0.0.1;
  };
  forward only;
  forwarders {
    208.67.220.220;
    208.67.222.222;
  };
}
</pre>
<p>Restart BIND to make the configuration change effective.</p>
<pre class="code">
# /etc/init.d/named restart
</pre>
<h3 id="toc-step-5-switching-the-resolver">Step 5: Switching the Resolver</h3>
<p>Alright. It is the final step, I promise! Now you have OpenDNS set up and customised for your IP, local recursive DNS running, and the final step to make is to switch over to your local resolver &#8212; use <code>127.0.0.1</code> in your <code>/etc/resolv.conf</code>, i.e.</p>
<pre class="code">
# echo nameserver 127.0.0.1 &gt; /etc/resolv.conf
</pre>
<p>Now, try to resolve some domain names (<code>host hostingfu.com</code>), and check whether it is working. If it doesn&#8217;t work, i.e. does not bring back an IP address, you should</p>
<ol>
<li>Revert the content of <code>/etc/resolv.conf</code> (to the one in step 3, for example).</li>
<li>Use <code>netstat -uan | grep 53</code> to check whether your local recursive DNS is indeed running.</li>
</ol>
<p>If everything is up and running, you should be getting fast and stable domain name resolution on your server.</p>
<h3 id="toc-potential-issues">Potential Issues</h3>
<p>I have been using OpenDNS since last July, and have been using the setup I have stated on 3 of my VPSs for the last two months. Everything is fine &#8212; name resolution is always fast, and OpenDNS has been very stable. However there are some potential issues on depending on a centralised resolver, although OpenDNS&#8217;s servers are geographical isolated in US and Europe.</p>
<p>I think &#8220;single point of failure&#8221; is still the biggest issue, especially when your servers are not running in North America. If an earth quake occurs and cuts off all pipes between Sydney and Palo Alto, my Sydney VPS will fail to resolve any domain name, although a routing change shift queries to other OpenDNS locations might take place. Whereas with the typical non-forwarding recursive DNS setup, it will still be able to get to other root servers so only the domains in the effected area will fail to resolve.</p>
<p>It will gradually be less an issue when OpenDNS deploys more servers around the world. Hong Kong is planned from what I&#8217;ve read, so Asia/Oceania would be better covered. Until then, I&#8217;ll have my finger crossed :)</p>
]]></content:encoded>
			<wfw:commentRss>http://hostingfu.com/article/fast-domain-name-resolution-with-opendns-local-cache/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How OpenDNS Saved My Day</title>
		<link>http://hostingfu.com/article/how-opendns-saved-my-day</link>
		<comments>http://hostingfu.com/article/how-opendns-saved-my-day#comments</comments>
		<pubDate>Thu, 21 Dec 2006 12:32:18 +0000</pubDate>
		<dc:creator>scotty</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[gplhost]]></category>
		<category><![CDATA[opendns]]></category>

		<guid isPermaLink="false">http://hostingfu.com/?p=78</guid>
		<description><![CDATA[Just read the latest post on OpenDNS blog, How OpenDNS saved Caio&#8217;s job &#8212; Caio from Brazil used OpenDNS when his ISP&#8217;s DNS server was down, and was able to complete his job. Similar event happened to me today. No, it did not save my job &#8212; it was not work related. Let&#8217;s just say [...]]]></description>
			<content:encoded><![CDATA[<p>Just read the latest post on OpenDNS blog, <a href="http://blog.opendns.com/2006/12/20/how-opendns-saved-caios-job/">How OpenDNS saved Caio&#8217;s job</a> &#8212; Caio from Brazil used OpenDNS when his ISP&#8217;s DNS server was down, and was able to complete his job.</p>
<p>Similar event happened to me today. No, it did not save my job &#8212; it was not work related. Let&#8217;s just say that OpenDNS has saved my day.</p>
<p><span id="more-78"></span></p>
<h3 id="toc-what-happened">What Happened?</h3>
<p>Earlier today when I logged onto my VPS at <a href="http://hostingfu.com/tag/gplhost">GPLHost</a>, the server somehow <em>did not feel right</em>. It did not take long to figure out that my VPS cannot resolve any domain name. Bigger surprise was when I discovered that my mail server has a <strong>huge</strong> queue of emails spooled because it could not figure out where to send those emails to. From the log it appeared that domain name resolution has stopped working for more than 12 hours!</p>
<p>It turned out that the recursive DNS server at GPLHost&#8217;s Sydney facility was no longer contactable, and it was the DNS server pre-configured for my VPS. So I quickly fired an email to GPLHost about the situation, and tried to figure out whether there is any remedy.</p>
<p><strong>OpenDNS!!</strong></p>
<p>It was the first public recursive DNS service that pops up in my head. So I quickly updated my <code>resolv.conf</code> to point to OpenDNS&#8217;s 2 name servers. <strong>Bingo!</strong> Problem solved, and domains were resolving again. It did take a while to clear the queue in my mail spool, but I was happy.</p>
<p>OpenDNS saved my day.</p>
<p>I actually used OpenDNS for all my US-based servers. You can now claim IP networks/addresses that belong to your account, and then customise the resolving behaviour. For servers I just want fast resolution &#8212; no need for phishing protection or other goodies &#8212; and I can easily turn them off from my account page in OpenDNS once I have claimed those IP addresses.</p>
<p>I did not use OpenDNS for my Australian VPS initially as I was afraid of the high latency. It turned out it was not too bad at all. It automatically picked up their DNS servers at Palo Alto, which is around 160ms return trip from my Sydney VPS. Combining that with a local cache/forward-only DNS server (I use <a href="http://www.thekelleys.org.uk/dnsmasq/doc.html">Dnsmasq</a> for its light weight), DNS resolution can be very fast from this end of planet (<em>note to myself: need to write a how to on this one</em> <b>Update</b>: <a href="http://hostingfu.com/article/fast-domain-name-resolution-with-opendns-local-cache">done</a>).</p>
<p>They have also recently <a href="http://blog.opendns.com/2006/12/19/cachecheck/">announced CacheCheck</a>, which allows you to force OpenDNS to refresh its DNS records even before TTL expires. It allows you to quickly test DNS changes. You usually have to restart local recursive server after you have made some changes to flush the cache. Now you can just set your recursive server to always forward requests to OpenDNS, and flush the zone from their web interface.</p>
<p>Thanks OpenDNS.</p>
]]></content:encoded>
			<wfw:commentRss>http://hostingfu.com/article/how-opendns-saved-my-day/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
