How to setup your name servers (servermatrix)


Setting up your own nameservers can be a nightmare. It never seems that no two hosts do the same things to get them set up. Anyway, this is what we did.

1. Register the domain you're going to use for your nameservers, then register and as nameservers (registries normally have a special facility for doing that). The registry may also have a facility to propagate these nameservers around the foreign registries - if so, you should use this facility.

These registrations may take a few days to propagate (often as many as 3 days).

2. Get an additional IP address. We used the main IP for the server as one name server IP and got an additional IP address to be used for the second name server.

You may also need to get your data centre to enter a reverse DNS pointer for your nameservers. You'll need to let them know each nameserver and its IP address. Sometimes you can suffer non-delivery of mail if you don't so this. Reverse DNS pointers can take a while to propagate.

3. My version of WHM/CPanel came with a broken NDC. To fix this:

SSH into your box as root.

Type: cd /scripts
Type: ./updatenow
Type: ./fixndc

Go back into WHM, go to the Restart Services section in the left menu and click DNS/Nameserver (BIND).

You will need to do this if you start getting 'ndc' errors when you are doing anything DNS related in WHM.

4. Go into WHM (Web Host Manager) and select Edit Setup from the Server Setup menu on the left. Enter in the Primary Nameserver field. Hit 'Assign IP Address', then hit 'Add an A Entry for this nameserver'.

Repeat this process for the Secondary Nameserver field.

5. Go into WHM (Web Host Manager) and select Manage Nameserver IPs from the Server Setup menu on the left. Remove any nameservers you don't recognise. This is just a tidy up exercise in case anyone's set anything up on the box before you.

6. Go into WHM (Web Host Manager) and select Initial NameServer Setup from the Server Setup menu on the left. Run this.

7. Restart BIND (step 7 restarts BIND, but we've known it to need a proper stop and start for it to work) from SSH with:

service named stop
service named start

I don't know what it is about this process, but it doesn't always work, so there are some things you can check manually via SSH.

Check that the nameservers are correctly specified on NS, NS2 etc.

Check that there are nameserver entries for each IP. There may also be one for - this is okay.I'm led to believe (by the 'man' entry for resolv.conf) that this isn't a particularly important file, but I changed mine to read:


Where '' is the main domain of my server, and '' and '' are the IP addresses of my primary and secondary nameservers.

resolv.conf is used to lookup names that are not in FQDN format.

Check that there are entries for each IP acting as a nameserver.[/url]


OK, trying something new...

Not an article, not a tutorial, just a transcript of an AIM session I had earlier today:

Q: Hello Are you there?

A: hello yes, yes I am

Q: you might just be able to save my ***! I've got a celeron box on servermatrix and have setup my nameservers using your guide on the forum.... but...

Q: I can see my ns entries in /etc/nameserverips but not in /etc/wwwacct.conf and /etc/resolv.conf

Q: So I can't set up any accounts, it fobs me off and sends me back to the ns setup

A: ow

A: Did you see any error msg in whm when setting up your NS?

Q: it said something about ndc and it might be using an older version or something? but it said it added the ip's
when i clicked the button next to assign IP
the "A" entry

A: yes

A: hmm

A: you'll have to make sure that both /etc/named.conf and /etc/rndc.conf use 'rndckey' and not 'rndc-key'

Q: key "rndc-key" ?

A: yeah that one is bad

Q: what is it

A: you need key rndckey

A: it's just a key to sync. name servers

A: WHM and RH9 tend to use the wrong key

Q: so how do I change it? and what will I need to do after i've changed it

A: which file contains the wrong key? is it rndc.conf?

Q: no, named.conf

A: ok
pico name.conf then remove the dash sign and save
and rndc.conf
if rndc.conf contains 'rndc' and not 'rndc-key' then it's ok

Q: it contains rndc-key

A: damn
OK, in a nutshell:
edit these 2 files - any instance of rndc-key must be replaced with rndckey

Q: ok

A: You're in a shell session right?

Q: yep

A: ok let me know when you're done

Q: half of named.conf had rndc-key and half rndckey , weird

Q: ok it's done

A: weird and wrong eheh

Q: i don't know whats right and wrong so i can't judge

A: now run:

Q: yep

A: now:
if it complained, then run /scripts/fixndc one more time

Q: Found key in named.conf ..
Found controls in named.conf ..
named.conf has already been fixed!

A: great

A: did you run everything I just wrote?

Q: yep

A: great
try this:
grep "rndc-key" named.conf rndc.conf
did it return anything?

Q: well i wasn't in /etc, but then it just went back to the command line

A: ack

Q: does that search for the rndc-key in the files?

A: silly me you need to run it in /etc

A: absolutely

Q: yeah i done that now and it just goes back to the command line

A: great
now, pico /etc/wwwacct.conf
you'll see lines starting with NS and NS2 and NS3 I guess

A: do you see them?

Q: sorry, putty crashed, just logging back in

A: hehe no problem

Q: ok, i see the ns lines, but they're just ns.localhost.localdomain etc
;NS ns.localhost.localdomain
;NS2 ns2.localhost.localdomain

A: oh well that sure is wrong

A: these are the only lines starting with NS you have in this file?

Q: yep, this is the problem, so i can't add accounts until this is sorted
; NS ()
; This is the name for the SOA and NS dns entires
;NS ns.localhost.localdomain
;NS2 ns2.localhost.localdomain
; HOST (hostname)
; This is the name of the machine

A: ok is hostname ok at least?

Q: but in /etc/nameservers it shows the ones i setup

A: so all is not lost

Q: I haven't defined a hostname so it will just be the default whatever that is

A: ow

A: ok
that may be why whm got confused
you should, using whm, change your hostname

Q: sorry i mean they're in /etc/nameserverips

A: I got it

Q: how do i change my hostname

Q: ah under "hostname" in server setup hehe

A: it's a menu item - yeah

Q: can i set it to any one word or does it have to the a-word.localdomain

Q: like myhostname.localdomain or can it just be myhostname

A: it can be just myhostname

Q: ahh, the box already has a hostname, a default one setup by servermatrix by the looks of it... it's my name
but it isn't setup in server setup...

Q: shall i add that one?

A: well

A: if there's a hostname then it's ok
let's go back to your shell session

Q: ok

A: are you still editing wwwacct.conf?

Q: no, i came out of it

Q: shall i go back?

A: well pico /etc/wwwacct.conf

Q: ok

A: now go to the first NS line

Q: yep

A: you do know which name servers you want to use, of those you have in nameserversips right?

Q: yeah

Q: they're two i setup before, they haven't propogated, but i know the names and ips

A: OK, so replace ns.localhost.localdomain with this nameserver's name
for instance:

Q: and ns2 yeah?

A: absolutely
So now both NS and NS2 are your nameservers

Q: yep

Q: but hostname is still hostname in wwwacct.conf

A: If these line start with a semicolumn, remove it

Q: yeah they do

Q: done

A: yes replace hostname with your host name
now save the file

A: Done?

Q: do i remove the ; on the hostname line too

A: oh yes sorry - yes do that

A: and make sure you have only one hostname line in the file

Q: ah **** there is one under it

A: ah
was it the right value?

Q: no, the localhost.localdomain again, shall i just delete the line

A: yes do that

Q: ok done, there is an ip address field too

Q: with a weird ip
should this be my server IP? it has in it

A: right. replace it with your server's main IP

Q: ok, anything else

A: make sure you don't have extra NS fields in the file

Q: nope, just the two i put in

A: ok now save it

Q: done

A: now to be on the safe side, restart bind:
service named restart

Q: Stopping named: rndc: connection to remote host closed
This may indicate that the remote server is using an older version of
the command protocol, this host is not authorized to connect,
or the key is invalid.
it says it's ok

A: again: service named restart

Q: it said stopping named

A: Does it complain again?

Q: now it's back at the command line

Q: no

A: Fixed, then. The message you saw is because bind had been started with the old rndc key

Q: ok, now what do i do

A: now to be completely covered:
service cpanel restart

Q: it's stopping all the services

Q: done
(i think)

A: well now it's time for you to try adding a new account I guess

Q: ok, let me have a crack

Q: It brings up an error when i log in to whm, saying it was unable to look up an A entry for my hostname??

A: heh yes because it's true

Q: ok, i'll try and add an account now

Q: ooooh new account info page

Q: now i'll just have to see if the domain maps to the account once the nameservers come online
i guess...

A: yup

A: Well, it should though

Q: yeah, well, i created the names and mapped them to the correct ip's so i guess it should, we'll just have to see in a couple of days

Q: thanks a lot man, it's really appreciated

A: yes good luck

Q: why can't they just setup the boxes like this to begin with

A: Oh blame WHM for that