Setting up a nameserver - Any good tutorials about?

Associate
Joined
18 Nov 2008
Posts
2,430
Location
Liverpool
I'm trying to setup my new dedicated server as a nameserver, but haven't got a clue how to do it! I've looked at many tutorials but most are outdated.

I'm trying to get my site (For the sake of this topic lets call it example.com) to work with ns1.example.com and ns2.example.com. I've setup the glue records and set the nameservers of the domain, but don't know what to do next?

I have webmin and BIND to hand if that helps, and am running CentOS.

Much Appreciated!
 
it helps if you know abit about how dns works.

i assume u already have some domains ?

there are 2 things u have to do to get the dns working, first is to setup the records on your dns server.

its pretty easy in webmin, althou i prefer editing the config files manually
just create the domain name as a master server, and add the records you need to use.

main one being the A record for the ip address you want the domain to point to.

for example, you can setup an A record for example.com to point to your ip address of the server, and a cname for www.example.com to point to example.com

the 2nd is to change the nameserver records of your domain to point to your dns server. This is usually done via the provider of the domain, how you do this depends on the provider, and u'll need to specify 2 dns server, primary and secondary.

this means u'll need 2 dns server, on seperate ip addresses, if you only have 1, u can get someone else to host the secondary, ie zoneedit is pretty good to use. Setting the secondary is easy, you just need to specify the address of the primary, and it'll connect to the primary and update all the required settings
 
Hi Cycrow, cheers for the advice, much appreciated!

I actually have access to 5 IP addresses with my dedi, so I assume I can use two for 2 different nameservers? If so, that's what I'm doing at the moment.

I've set up the A records to point to the IP, setup the NS records to point to the name servers, but I'm not sure what you meant about C records?

Also, with regards to changing the nameserver records of my domain, I assume that's done in the form of glue records? If so, I've done them also.

And yet...still no correct redirect! I have a feeling my config file is not right, because it seems to have very little in it, it appears as follows:

Code:
options {
	directory "/etc";
	pid-file "/var/run/named/named.pid";
	};

zone "." {
	type hint;
	file "/etc/db.cache";
	};

zone "example.co.uk" {
	type master;
	file "/var/named/example.co.uk.hosts";
	};

Your time is much appreciated! Thanks for your input so far.

EDIT: Just pinged my nameservers and they get a response, but the main domain doesn't, does this mean I've setup the records for the nameservers correctly (They get the right IP!) but not the domains records?
 
Last edited:
If you using bind/named use named-checkconf and named-checkzone to check your config.

Having two named servers on the same server is a little pointless assuming your 5 IP's point to the same server.
 
Both of those files seem to be a massive file of @'s and other computer read symbols. I assume that's not supposed to be read by humans as there's little legible text in there?

And yeah I know having two nameservers on one server is pointless, the only reason I'm doing it is because you have to have two for most things. I'm not bothered about redundancy at this point.
 
nothing wrong with running them both on the same server with seperate ip's for testing/learning purposes.

as for the cnames, these allow you point other names to existing a records.

so if you setup an A record for example.com, then when u try to resolve example.com then it will return the ip your set.

however, if you try to use something like www.example.com, it wont resolve as you need to have each name setup seperatly.

so you can create a new A record for www.example.com, or, use a cname, so instead of specifying the ip, you specify the name to point to.

so when you resolve www.example.com, it checks its cname and returns the resolve for example.com.

also for your config, the files are actually split up seperatly.
the one u posted is the main conf file, this has the settings for the nameserver itself, and it defines each zone.
as the nameserver can be used any number of zones (domains) that you like.

the important one here is

Code:
zone "example.co.uk" {
	type master;
	file "/var/named/example.co.uk.hosts";
	};

this creates a record for your domain "example.co.uk" and its a master server
then the next line, specifies the file for the config for that zone.

so if you look, u should have the file, /var/named/example.co.uk.hosts
in that file, u will find all the settings for your domain, like the ns records, a records, cname, etc.

also remember to setup an mx record if you plan to use the domain for mail as well.


have you setup your servers ip at ur domain provider so its pointing to your dns server ?

u can do a whois on the name to find out.
if your just doing it as a test internally, then u dont need to bother about that, thats for when u have ur own domain and want everyone to be able to resolve ur host
 
Wow thanks mate that's a lot of useful info for me, much appreciated!

My version of BIND doesn't seem to have C records, but I do have an A record set up for the domain with and without www. on it, so I assume this is fine?

I suppose it's easier if I tell you that the domain is cyphergaming.co.uk, which I own. A WHOIS does indeed point to the correct IP address of my server.

The file cyphergaming.co.uk.hosts contains the following

Code:
$ttl 38400
cyphergaming.co.uk.     IN      SOA     ns1.cyphergaming.co.uk. <REMOVED>. (
                        2010081807
                        10800
                        3600
                        604800
                        38400 )
cyphergaming.co.uk.     IN      NS      ns1.cyphergaming.co.uk.
cyphergaming.co.uk.     IN      NS      ns2.cyphergaming.co.uk.
ns1.cyphergaming.co.uk. IN      A       213.5.180.95
ns2.cyphergaming.co.uk. IN      A       213.5.180.96
cyphergaming.co.uk.     IN      A       213.5.180.95
www.cyphergaming.co.uk. IN      A       213.5.180.95

This is why I'm confused, as far as I can tell everything is pointing around how it should do. Even the WHOIS points to the correct IP, and yet it doesn't work!
 
Last edited:
cnames are usually just easier to manage than A records, althou they dont make a lot of difference.

for your conf, a cname would look like

Code:
ns1.cyphergaming.co.uk. IN      A       213.5.180.95
ns2.cyphergaming.co.uk. IN      A       213.5.180.96
cyphergaming.co.uk.     IN      A       213.5.180.95
www.cyphergaming.co.uk. IN      CNAME      cyphergaming.co.uk.

it seems to be working fine, what problems are you having ?
your whois looks fine, it has the nameservers with the correct ips.
i've also done a lookup, and its returning the correct ip, so its defiantlly working.

also remember, that changes arn't instant u have to wait for the TTL to expire before your changes take effect, think of is as like a cache, when a lookup is done, it stores the result in cache, then any other lookups done, it returns the cached address, then the TTL expires, the cache is reset and does a full lookup again

EDIT: not sure if you know this, if you are making changes manually, ie editing the files directly, remember to change the serial number, its the first number in the SOA records, 2010081807, this needs to be different each update you do, the common convention is to use the date (YYYYMMDD) followed by a 2 digit update number, so for today u would have 2010081801 then if you update again today, change the 01 to 02, and so on. If your just doing it via webmin, it'll do it for u fine
 
Last edited:
Yeah I've set it to YYYYMMDD via Webmin earlier on this evening.

The problem I'm having is that it doesn't...work? Accessing cyphergaming.co.uk doesn't redirect to anything when presumably it should redirect to the default apache page?

Thanks for the extra info on CNAME's, I'll change them once it's working. But till I get it working I'll leave it as it is or I won't be able to manage that record via Webmin!
 
well, your named server is running fine, as i can resolve the host fine.

the problem must be elsewhere, most likly in your apache config.

i assume apache is running ?
from the server itself, can you view http://127.0.0.1

if its command line only, u can install lynx to test it

also, can you view the page locally, if you have a local address, try that, otherwise try the ip directly, http://213.5.180.95.

actually i just tryed, and its working for me too, http://www.cyphergaming.co.uk is displaying the apache test page.

so if its not working for you, then the problem is most likly your local lookup.
this will depend on your network configuration.
an easy fix is to use your new dns server to resolve locallaly. Ie, if you using windows, goto your network connection propetries and add the dns server address as your primary dns.

however, be aware, then if your running under nat, then u might not be able to view the page locally.
this is because not all routers port forward from internal address.

so when you try to view www.cyphergaming.co.uk it resolves to your address that goes to your router, and the router doesn't forward to the correct server so basically its trying to view the webpage of the router.

but without knowing how your network and servers are setup its difficult to know
 
Thanks Cycrow, my cache must have reset int he last few minutes, upon my last post it didn't work, but when you said it worked I checked and sure enough, it's fine!

Thank you so much for your help, I'm extremely grateful! If adding to your trust for help on the forum was allowed then I would!

Much appreciated!

EDIT: Just found out that it was BIND that refreshed :) That's what caused it to start working!
 
Sorry to jump into your thread but I have a DNS related question. can you have anything.domain.com as a cname? if so why would I pay 123-reg (my provider) £10 a year for a subdomain for my domain when I could just set a cname for the subdomain (or an A record if I want it pointed to a different IP)? Or am I thinking of cnames and sub domains wrong?
 
Redgie, No Problem :)

Dist, i guess it depends what u want to do. I only use 123-reg to register my names and dont use thier dns service so dont know what the subdomain might contain.

however, cnames allow you to setup any number of different names pointing at the same places.

but u can also have each name controled by a seperate dns server.

for example, u could have ur main dns server that controls the domain.com, and setup a sub domain for anything.domain.com and have that controlled by a seperate server.

then the serpate server will have control over anything.domain.com, so u setup things like more.anything.domain.com.

im guessing the sub domain option gives you more control over something like that, but its just a guess.

if all you want is different names for your servers, then cnames will be the best approach, its pretty common for things like www, main, ftp etc being cnames, especially if they are all on the same ip address.

one more thing about sub domains vs cnames, with sub domains u can also have seperate mx records for mail servers.

the fee u pay is most likly just to have them host and control the dns for you on thier servers, if you do it yourself on your own server, there really is no limit to what u can do
 
Back
Top Bottom