|
DJBDNS: The Pieces By Bri Hatch. Summary: DJBDNS is only as effective as the sum of its parts. Understanding the different pieces that constitute DJBDNS is the first step to effectively deploying it.
DJBDNS has many separate pieces, not all of which you necessarily need. The separate pieces include:
You may have noticed above that dnscache and tinydns both want to listen on UDP port 53. That means that you cannot have both of these processes listening on the same IP address. DJB's official retort is that you should be using separate machines for this purpose anyway, which is pretty much true. However, if you want to run both on the same machine, then you can run each on it's own virtual IP address (eth0:0 vs eth0:1, etc...) or you could run dnscache on localhost (available only to that machine) and tinydns on the external interface. The network setup you pick will depend on your needs. Each of these servers are run through the supervise/svscan processes we installed earlier. These processes require a special directory layout to define the programs to run; however, you can run configuration programs to handle the grunt work. Let's start off by setting up dnscache:
# dnscache-conf dnscache dnslog /etc/dnscache 127.0.0.5 The arguments are:
For now I'm setting the IP address to be 127.0.0.5 because it's a convenient way to test things.[1] If you already have BIND listening on localhost (127.0.0.1) then using 127.0.0.5 won't conflict and we can verify all is well before turning off BIND. This creates the following directories inside /etc/dnscache:
All DJBDNS software uses this same directory layout. However the stuff that is in root differs from application to application. In the case of dnscache, the root directory contains files that function as follows:
Now we need to tell svscan to start dnscache:
# ln -s /etc/dnscache /service In five seconds, svscan should start up dnscache. (Remember, it's watching that /service directory.) It's now time to see if things are working correctly. First, do a quick lookup of your favorite hostname against your current DNS server[4]:
$ host example.com example.com has address 192.0.34.72 Then verify that dnscache is providing the same data:
$ host example.com 127.0.0.5 example.com has address 192.0.34.72 This time I hard-coded the 127.0.0.5 address to query against our local dnscache process. Make sure to check any internal domains, including reverse lookups. If you're only using BIND for a DNS cache, not serving local DNS data, then you can turn BIND off and put dnscache into production. Just make sure to change the env/IP file to have the correct IP address on which dnscache should listen, and be sure to add the appropriate files in root/ip to make sure local clients can connect. If you are serving DNS data with BIND, then you may be able to separate things by having dnscache listen on an IP address not in use by BIND (set BIND's listen-on directive in /etc/named.conf) until you can configure tinydns to serve up the data, at which point you can be BIND free. Worst case scenario, you should be able to have BIND listen only on your external IP address:
listen-on { IP.AD.DR.ES; }; and have dnscache on localhost
# echo 127.0.0.1 > /etc/dnscache/env/IP and point this machine to dnscache instead of BIND:
$ cat /etc/resolv.conf search domain.dom nameserver 127.0.0.1 So, let's restart BIND:
# killall -HUP named and then stop/restart the dnscache program on the new IP address.
# svc -d /etc/dnscache # svc -u /etc/dnscache That's it. Next week: tinydns.
NOTES: [1] Although folks usually think of localhost as 127.0.0.1, all of the 127.x.y.z network is locally usable as well, without any additional configuration or ifconfig commands. Cool, eh? [2] Examples: If you had an internal zone 'inside.example.com' that is served by 192.168.1.1 and 192.168.1.2, then create a file named 'inside.example.com' with those two IP addresses each on their own line. If you want to point to those machines for the reverse DNS entries for the 192.168.1.x network, put those IP addresses in a file named 1.168.192.in-addr.arpa. If you've administered DNS before, this backwards notation should look familiar. [3] Assuming you have appropriate kernel ACLs in place (ipchains/iptables) to disallow connections to localhost from external interfaces. This is a *really* good idea.... [4] example.com's IP address may change by the time you read this, or they delete the A record entirely. I don't know why they ever gave it one in the first place....
Bri Hatch is Chief Hacker at Onsight, Inc, and author of Hacking Linux Exposed and Building Linux VPNs. He has a hard time believing all these folks who say you don't need air conditioning in Seattle, when his apartment was still 91 degrees at 2am. Bri can be reached at bri@hackinglinuxexposed.com. Copyright Bri Hatch, 2002. This article was first published here in ITworld.com Inc., 118 Turnpike Rd., Southborough, MA 01772 on 30-Jul-2002.
|