Creating a basic DNS Server in Solaris 11

Create a zone (optional)

I created a zone to hold my temporary DNS server so it was quick and easy to remove at the end of the testing

root@sc5acn02-d1:~# zfs create -o mountpoint=/zones rpool/zones
root@sc5acn02-d1:~# zonecfg -z dns-zone
Use 'create' to begin configuring a new zone.
zonecfg:dns-zone> create
create: Using system default template 'SYSdefault'
zonecfg:dns-zone> set zonepath=/zones/dns-zone
zonecfg:dns-zone> commit
zonecfg:dns-zone> exit
root@sc5acn02-d1:~# zoneadm -z dns-zone install
The following ZFS file system(s) have been created:
Progress being logged to /var/log/zones/zoneadm.20140523T153804Z.dns-zone.install
       Image: Preparing at /zones/dns-zone/root.

Boot the zone
# zoneadm -z dns-zone boot

Login to the console and setup the network interfaces
# zlogin -C dns-zone

Configure DNS

Install  the BIND dns package

root@dns-zone:/var/tmp# pkg install service/network/dns/bind

Use the h2n script to convert a host based setup to a bind dns setup (I got my copy from

./h2n -d -n 138.3

Create your named.conf file

options {
        directory       "/etc/namedb/working";
        pid-file        "/var/run/named/pid";
        dump-file       "/var/dump/named_dump.db";         
    statistics-file "/var/stats/named.stats";

zone "" {
        type master;
        file "/etc/namedb/master/load.db";
zone "" {
        type master;
        file "/etc/namedb/master/3.138.db";

root@dns-zone:/var/tmp# mkdir -p /etc/namedb/working
root@dns-zone:/var/tmp# mkdir /var/run/named
root@dns-zone:/var/tmp# mkdir -p /var/dump
root@dns-zone:/var/tmp# mkdir -p /var/stats
root@dns-zone:/var/tmp# mkdir -p /etc/namedb/master
root@dns-zone:/var/tmp# cp db.load /etc/namedb/master/load.db
root@dns-zone:/var/tmp# cp db.138.3 /etc/namedb/master/3.138.db

My files looked like this

# cat /etc/namedb/master/load.db
@ IN  SOA ( 1 10800 3600 604800 86400 )
  IN  NS

localhost            IN  A

dns-zone             IN  A
dns-zone             IN  MX    10

host-17-128          IN  A
host-17-128          IN  MX    10

root@dns-zone:/etc/namedb/master# cat /etc/namedb/master/3.138.db
@ IN  SOA ( 1 10800 3600 604800 86400 )
  IN  NS        IN  PTR      IN  PTR

Setup a client to your dns

svccfg -s /network/dns/client setprop config/nameserver = net_address:
svccfg -s /network/dns/client setprop config/domain = astring: ""
svccfg -s /network/dns/client setprop config/search = astring: ""
svccfg -s /network/dns/client setprop config/ipnodes = astring: '"files dns"'
svccfg -s /network/dns/client setprop config/host = astring: '"files dns"'

Verify the configuration is correct:

root@dns-zone:/etc/namedb/master# svcadm enable dns/client
root@dns-zone:/etc/namedb/master# nslookup host-17-128


root@dns-zone:/etc/namedb/master# nslookup
Address:       name =

Adding new records to your DNS

You have a couple of ways to add new records to your dns.. you can

1) Add the new entries to your host file and re-run h2n
2) Manually add entries to the load.db and 3.138.db files

and then refresh/restart the dns service.

To manually add a new host to the DNS  sc5a02-d2

Add a ‘forwards’ entry to /etc/namedb/master/load.db

sc5a02-d2            IN  A
sc5a02-d2            IN  MX    10

Add a reverse entry to /etc/namedb/master/3.138.db      IN  PTR

refresh and restart the server

root@dns-zone:/etc/namedb/master# svcadm refresh /network/dns/server
root@dns-zone:/etc/namedb/master# svcadm restart /network/dns/server

Test it forwards and backwards.

root@dns-zone:/etc/namedb/master# nslookup
Address:       name =

root@dns-zone:/etc/namedb/master# nslookup sc5a02-d2



Manually creating entries is a bit of a pain though if you have a lot of them. I’ve done a very dumb script here to generate entries..

# quick generate DNS entries script
# accepts host and IP, produces entries for files
#Fixed variables
echo "Forwards entry"
echo "$HOSTER       IN  A             $IPPER"
echo "$HOSTER       IN  MX            10 ${HOSTER}.${DOMAINER}."

echo "Backwards entry"
BACKWARDSIP=`echo $IPPER | awk -F. '{print $4 "." $3 "." $2 "." $1}'`


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s