ok lets say you have a domain name example.com taht you paid for. You must tell your registra that you domain name server is your box (if you have someone like godaddy you can add entries into the domain server list). Assuming u have all that worked out, you have to create a zone file for the domain and you'll have to add an entry in your named.conf file:
in your named.conf file, you'll need atleast the following:
Code:
zone "example.com" {
type master;
file example.com.zone;
};
the named.conf file is located usually in /etc/ or in my case /etc/bind/
and the zone files in /var/named/ or in my case /var/bind/pri and /var/bind/sec
(i use gentoo and it does things different )
if you are unsure about the location, there is an options block in the /etc/named.conf file that has a line that tells you where it looks for zone files
the 1st part of the zone file looks tricky at first but when you look at the finished product it starts to make sense.
the 1st line is usually a TTL statement (time to live). I think this tells servers that cache your servers responses how long to hold on to them before it should query your server again for the ip address of you domain name.
$TTL 3h ; (3 hours)
after that is the SOA recored (Statement of Authority i think).
This has a bunch of numbers (times and stuff, the comments here help out)
my SOA looks like this
Code:
gigahurts.net. IN SOA ns.gigahurts.org. hostmaster.gigahurts.net. (
1 ; serial
3h; refresh after 3 hours
1h; retry after 1 hour
1w; expire after 1 week
1h ; negative cachint TTL of 1 hour
)
the 1st line has the followin form your.domain. IN SOA master.name.server. email.address. (
the nameserver part will be the actual machine itself, i call mine ns.gigahurts.org.
because i own gigahurts.net and gigahurts.org but ns.gigahurts.org is an acutal registered domain name server. the email address part has to contain all "dots" ( . ) no @ symbols. The @ symbol is a special character in zone files. So if the email address is
hostmaster@gigahurts.net then it would be hostmaster.gigahurts.net. in the SOA record.
Make usre you put those extra .'s on the end like i have them gigahurts.net.
if you dont, you'll end up with example.com.example.com . The dot tells bind not to append the domain name on the end. This is a common mistake (i've made it a few times).
the rest of the SOA record can be used verbatim. I wont go into what they mean but sometimes you'll see the times in seconds rather than in hours and days or weeks.
the very next thing after the SOA record should be NS records. This tells BIND what the name servers are for your domain. Usualy u want 2, a master (what u are createing) and a slave or secondary server incase your server crashes.
Code:
example.com. IN NS ns.example.com. ;NOTICE THE DOTS ON THE END
example.com. IN NS secondary.server.com. ; AGAIN NOTICE THE DOTS
this tells bind what your authoritative nameservers are. one should match what u put in the SOA record. the one in the SOA record is the master.
now you may look at that and say "ns.example.com doesnt exsist". Well just hold on, it's comming

.
Address Records (A records). this is where you list hostnames and the IPs to give for them.
Code:
example.com. IN A 192.168.1.1 ; put your ip address here
ns.example.com. IN A 192.168.1.1 ; put your ip address here
ftp.example.com. IN A 192.168.1.1 ;again , your ip here NOTICE THE DOTS ON THE END
www.example.com. IN A 192.168.1.1 ; ....you get it now
this is really all you need unless u want to do some email stuff. I dont use CNAMES because those cause double lookups and for my small zone, it isnt necessary but a CNAME record is an alias for something that already has an A record like...
pimp.example.com. IN CNAME www.example.com.
when someone on the net tries to get the ip address for pimp.example.com it will cause a lookup of the ip address of
www.exmple.com. I just go ahead and give pimp the same IP as www and make it an A record but in some cases a CNAME is better, especially if the IP address changes a lot of you dont know what the ip is (maybe the CNAME is for a computer not owned by u or something).
like you may be able to do this...
yahoo.example.com IN CNAME www.yahoo.com.
but, why the hell would u wanna do that?
anyway, the finished product:
Code:
example.com. IN SOA ns.example.com. hostmaster.example.com. (
1 ; serial
3h; refresh after 3 hours
1h; retry after 1 hour
1w; expire after 1 week
1h ; negative cachint TTL of 1 hour
)
example.com. IN NS ns.example.com. ;NOTICE THE DOTS ON THE END
example.com. IN NS secondary.server.com. ; AGAIN NOTICE THE DOTS
ns.example.com. IN A 192.168.1.1 ; put your ip address here
ftp.example.com. IN A 192.168.1.1 ;again , your ip here NOTICE THE DOTS ON THE END
www.example.com. IN A 192.168.1.1 ; ....you get it now
how to clean up the file....
remeber how leaving off the "DOTS" will append "example.com", well this is actally helpful. You can create your records by doing this....
www IN A 192.168.1.1 ; by leaving off the dot, it becomes www.example.com
ftp IN A 192.168.1.23; same here, it becomes ftp.example.com
but if you put www.example.com and leave off the " . " you'll get www.example.com.example.com so becarefule.
also everytime you change your zone file you MUST add 1 to the serial number in the SOA and reload the zone files (i use killall -1 named ) -1 re-reads in the config file.
If you dont increment the serial number, your slaves wont be notified of the changes.
if you want to run a mail server, you'll need MX records:
i usually make 2 MX records ... mail.examle.com and exmaple.com
my mail server is setup to recieve mail for the domain mail.gigahurts.net but my DNS will take anything that is gigahurts.net or mail.gigahurts.net here is the setup.
mail.example.com. IN A 192.168.1.234
mail.example.com. IN MX 10 mail.example.com.
example.com. IN MX 20 mail.example.com.
so if email is sent to root@example.com , it is sent to [email]root@mail.example.com
and if mail is sent to root@mail.examle.com , same thing, this way you can get
email from both names but your mail server gets it's own hostname (mail)
any questions, ask and i'll try to explain more. i get all this from the book DNS and BIND by Paul Albitz and Cricket Liu (4th Edition covers bind 9).