FreeBSD DNS
Introduction
This guide takes you through the setup of DNS (bind) on a FreeBSD machine.
This guide assumes you know some basics about DNS. If you don't have a clue what
DNS is about or how it operates please goto the library and get the book: 'Orielly:
DNS/Bind' book. It is the definitive guide that most DNS admins should be
familiar with.
A D V E R T I S E M E N T
FreeBSD DNS Concepts
It is important to understand DNS as it is core in a
system like FreeBSD. In fact, FreeBSD comes with a stock with full blown DNS
server and client. You don't need to install any 3rd party software to get it
going. Setting up DNS on FreeBSD is trivial and shouldn't take long to get
going.
Enabling DNS
First off, let's get your FreeBSD box ready for setup.
This includes making sure your hostname is setup properly and running the
necessary make script. First off, set your hostname:
# hostname foo.bar.com
Now time to run the prepacked make shell script to install
the proper configuration files:
# cd /etc/namedb
# sh make-localhost
You'll notice that I cd'd into /etc/namedb. This is where
the name server config files sit on FreeBSD. The make-localhost script comes
with FreeBSD and should set everything up properly. By default, it sets up a
caching-only name server on your machine. The main config file is /etc/namedb/named.conf.
If you need to add zones or do any slave work set it up in that file.
FreeBSD also comes with some stock reload and restart
scripts:
To reload the nameserver (without clearing cache):
# named.reload
To completely restart the nameserver:
# named.restart
Verify that it's running by using 'netstat -an' and 'sockstat':
From netstat -an:
.
.
.
tcp4 0 0 127.0.0.1.53 *.* LISTEN
tcp4 0 0 205.238.129.221.53 *.* LISTEN
.
.
.
udp4 0 0 127.0.0.1.53 *.*
udp4 0 0 205.238.129.221.53 *.*
.
.
.
Yep, something is listening on udp and tcp port 53. Lets look at sockstat to see
who it is:
root named 20693 20 udp4 205.238.129.221:53 *:*
root named 20693 21 tcp4 205.238.129.221:53 *:*
root named 20693 22 udp4 127.0.0.1:53 *:*
root named 20693 23 tcp4 127.0.0.1:53 *:*
Yep, named is running
That's all it takes to get it running!!! God bless
FreeBSD! Anyhow, we need to make it start up everytime you boot up the machine.
To do this, once again, edit /etc/rc.conf and add:
named_enable="YES"
If you wish to use your nameserver for resolution on your
local box. You need to edit /etc/resolv.conf and add the following lines:
search bar.com
nameserver 127.0.0.1
Now test it out:
# nslookup
Default Server: localhost.bar.com
Address: 127.0.0.1
> yahoo.com.
Server: localhost.bar.com
Address: 127.0.0.1
Name: yahoo.com
Address: 66.218.71.198
> exit
#
WOW! It's actually working. How bout that! And that's all
she wrote. To add zones and other DNS information consult your favorite DNS book
and add your stuff to the files in /etc/namedb.
|