1. Skip to Menu
  2. Skip to Content
  3. Skip to Footer>
Thursday May 2nd     10:00 AM PDT                                  

Configuring DNS Server Part 1

Written by Greg King Friday, 03 July 2009 13:28

The good news is, the DNS server (BIND9), as of version 5.3, is installed by default into a sandbox and is pretty much ready to go out of the box. In this section, all we are going to do is configure  your freebsd box to act as it's own dns server.  This is called a CACHING ONLY Server.   We will cover some more in depth zone files later, but for now let's keep it simple.

Notice that the program is called BIND9, but the service it runs is a name daemon.  The system refers to this process as named.

For now, we need to make the localhost files and add the startup line to rc.conf and configure our resolver.

# cd /var/named/etc/namedb
# sh make-localhost
# echo 'named_enable="YES"' >> /etc/rc.conf

now, edit your resolv.conf file and put your server in as the first name serve

# nano /etc/resolv.conf

The first line should say your domain, if you have one. The second line should point to your loopback address which is 127.0.0.1 if your domain name is wwwpages.com (which yours is not, but mine is, your resolv.conf file would look like this.

domain  wwwpages.com
nameserver 127.0.0.1

save the file (btw, use CTRL-X and then y to save in nano).

Let's check to be sure bind9 is up and running:

# ps -ax|grep named

should output like this: 

574  ??  Ss     0:00.53 /usr/sbin/syslogd -l /var/run/log -l /var/named/var/run/log -s

642  ??  Is     0:01.85 /usr/sbin/named -t /var/named -u bind

23715  p0  D+     0:00.00 grep named

If all you see is the last line (grep named) then your name server is not running, so time to troubleshoot what you did! Assuming it worked, lets give it a test.

# nslookup www.microsoft.com

should output something like this:

Server:         127.0.0.1
Address:        127.0.0.1#53

Non-authoritative answer:
Name:   microsoft.com
Address: 207.46.197.32
Name:   microsoft.com
Address: 207.46.232.182

The first line, Server:         127.0.0.1 means the lookup request was fulfilled by the local server!

Congratulations, you have a caching only name server!


Starting and Stopping the NAMED server

Bind9 v5.3 has added the rndc command to help manage the named server.  It is still under development but check out the # man rndc page for options.  A short list can be viewed by issuing the command without any options (hint: # rndc reload causes named to re-read it's named.conf and zone files).

# rndc

rndc is supposed to allow you to restart the name server which in turn reloads the zone files in the event you made changes via the command

# rndc restart

but, as yet, is not functional.  To restart named, you must first find the process id number the service is running on (called a PID).

# ps -ax|grep named

should output something like this : 

574  ??  Ss     0:00.53 /usr/sbin/syslogd -l /var/run/log -l /var/named/var/run/log -s

642  ??  Is     0:01.85 /usr/sbin/named -t /var/named -u bind

23715  p0  D+     0:00.00 grep named

the first line just means the name service is writing to a log file.  The second line is where the named service is running.  The first number is the process id (PID).  In this example, it is 642.  The last line just means we asked about what jobs were running that included NAMED in the process.

To kill our name server, we will tell the system to kill -9 the named pid.  Remember, in this example, the pid is 642.

# kill -9 642

and issue the complete command line string to start it:

# /usr/sbin/named -u bind -t /var/named

That's it for now!  Keep reading the other articles, you are well on your way to being a FREEBSD admin!

 

  FreeBSD Configuration
eXTReMe Tracker
Content View Hits : 404985