Hi all,
I've just installed BIND and DHCP onto my server as my router wasn't dealing very well with either role.
Here's how I did it on, yes, Ubuntu 10.04.
First, install BIND and DHCP3 (You can either sudo or switch to root).
apt-get install bind9 && apt-get install dhcp3-serverLets sort out bind9 first.
nano /etc/bind/named.confMake a quick note of the include statements. As you can see these files of config are added to keep things simple. Anyway, on the end of this file add these lines:
controls {
inet 127.0.0.1 allow {localhost; } keys { "rndc-key";};
};
This is for later so DHCP can update DNS. Save it and lets do the next one, it's one on the include list.
nano /etc/bind/named.conf.optionsStick your forwarders in here. Cunningly where it says forwarders. Here is my setting with my ISPs 2 DNS servers in:
forwarders {
87.194.255.154;
87.194.255.155;
};
Save it, lets do the next one. Again its in the includes list from earlier.
nano /etc/bind/named.conf.localBit more difficult this one. You need to create some zones. Mine isn't visible from the internet so bugger it, you can have mine.
zone "newburytechinfo.co.uk"{
type master;
file "/etc/bind/zones/newburytechinfo.co.uk.db";
allow-update { key "rndc-key"; };
//allow-update { localhost; localnets; };
notify yes;
};
See what I've done? All you have to do is replace my domain name, with your internal domain name. // = comment. This is while I was debugging. If you don't care what on your network can update your DNS use that line instead of the key line.
Next up, reverse DNS. Stay where you are and create a new zone like this(again this is mine):
zone "1.168.192.in-addr.arpa"{
type master;
file "/etc/bind/zones/rev.1.168.192.in-addr.arpa";
allow-update { key "rndc-key"; };
notify yes;
};
Ok? Nice and simple this. For the zone, if your computers IP is (for example) 192.168.1.15, chop the last number and dot off, then reverse it. Then add ".in-addr.arpa" on the end. If your computers IP is 10.242.192.24, it'll end up looking like this: "192.242.10.in-addr.arpa".
Obviously change the "file" line up there too to match the zone. Last bit, stick this line on the end:
include "/etc/bind/rndc.key";
Save it.
Ok, next bit. Create a zones directory:
mkdir /etc/bind/zonesgo in it
cd /etc/bind/zonesYou know the 2 filenames referenced above in that script I gave you?
create a new file with your domain name, like this:
nano newburytechinfo.co.uk.dbYou'll notice this file is referenced above in the zone config. Now we need to put the A records in. These I will clean. Cut and paste this. Change example.com to your domain name and the IP for the A record on the last line.
$ORIGIN .
$TTL 38400 ; 10 hours 40 minutes
example.com IN SOA example.com. admin.example.com. (
2007031009 ; serial
28800 ; refresh (8 hours)
3600 ; retry (1 hour)
604800 ; expire (1 week)
38400 ; minimum (10 hours 40 minutes)
)
NS example.com.
MX 10 example.com.
$ORIGIN example.com.
mail A 192.168.1.1
Right. Oh, by the by, that last line? If you want to give another server a fixed DNS name, chuck it in, in the same way. Save and exit.
Bounce the bind9 service:
service bind9 restartWant to do a quick test? On your PC type this:
nano /etc/resolv.confdelete everything (or put it somewhere else, write it down, back up your file, I'm not your mum), and put this in:
nameserver [your DNS server IP]
save it, now try and go to a website.
Have a coffee, you've just done your first DNS server.
Tell you what, I'll do DHCP as a seperate article!
Thanks for reading
Trev