Add to Favourites Add to Favourites    Print this Article Print this Article

How to add a 3rd name server (ns3)

The DirectAdmin interface currently only allows for 2 nameservers to be entered.  You can add a 3rd namesevrer to all old and new domains, but requires some simple file editing.

We'll assume that the 3rd nameserver is called and that the user domains are called

1) First, setup the default ns template so that any newly created domains have the 3rd nameserver.

cd /usr/local/directadmin/data/templates/custom
cp ../dns_ns.conf .

Then edit the copied dns_ns.conf and add the following line to the bottom of it:|DOMAIN|.

Make sure you add the periods to the end of each value, they're very important.  This will now add a 3rd namesever for all domains created after this point.

2) Next, to change the existing domains, we need to edit the named.db template temporarily. Type

cd /usr/local/directadmin/data/templates

(without the /custom).  Edit the named.db file.  At the very bottom of the file, add:

|DOMAIN|.       14400   IN      NS

Again paying special attention to the periods at the end of the values.   Now, any rewrite done by DirectAdmin will add that line, so let's now issue a full dns rewrite

echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq d400

At this point, all domains will have the ns3 value, but we don't want them to have multiple ns3 values after each rewrite (adding a subdomain, etc), so we have to now remove the last line you've added from the named.db.  Edit the named.db and remove your entry.   You're done.

If you want the ns3 value to vary per Reseller, you can use if-then-else type statements in the dns_ns.conf, since all templates support scripting, eg:

|*if NS1=""||DOMAIN|.

Was this answer helpful?

Also Read