Overview
Welcome to the second of my DNS articles. It is more of a prequel to my first article in which I explained the steps in Creating A DNS Entry For A SubDomain.
This article assumes you have already installed bind and it is all running. If not, then you will need to setup bind first.
What is a DNS Zone?
My previously article explained what a zone is so I won’t go into to much detail here, but essentially a zone is the term used to describe a config file a specific domain/subdomain in your DNS server bearing in mind that a DNS server has multiple zones/domains associated to it. Each domain generally has its own zone file however in some situations, you can have multiple domains per zone file. For example, mydomain.com and mydomain.net and mydomain.org could all be in the same zone file as long as they all need to point to the same ip address.
Create the DNS zone file
The zone file we will create for this example will be for the domain example.com. The zone file will tell the DNS server which IP the domain should point to as well as configuring expiry and refresh times for the domain. Generally, the naming format for a zone file is db.example.com.conf where the domain in this case is example.com. Now to create the zone file and add the contents shown in the Sample DNS Domain Zone File
sudo vi /etc/bind/db.example.com.conf
Sample DNS Domain Zone File
In this sample DNS domain zone file, there are a couple changes you need to make to ensure it works in your situation. Firstly, change ns1.exampledns.com and ns2.exampledns.com with your own ns1 and ns2 dns servers. Secondly you can change example.com to the domain you are adding.
Optionally leave out $ORIGIN if you are adding multiple domains to a single zone file. The @ symbol simply means the current zone which is great for when you have multiple domains to a single zone file.
; Zone file for example.com
$TTL 3600
$ORIGIN example.com
@ IN SOA ns1.exampledns.com. root.example.com. (
2012033101 ; Serial
3600 ; Refresh
1800 ; Retry
604800 ; Expire
43200 ) ; Negative Cache TTL
IN NS ns1.exampledns.com.
IN NS ns2.exampledns.com.
@ IN A 192.168.0.2
www IN A 192.168.0.2
Now we add our new domain zone config file to our DNS server
Above we created the zone config file. Now we need to add the zone file to our dns config file which tells our DNS server that it should control and serve requests for this new domain zone.
Open your DNS config file and add a zone in for your domain. I will be using example.com in my example. Here the file is located under /etc/bind/named.conf.local however depending on the way your DNS server was configured, it may be under /etc/bind/named.conf.options or rarely even /etc/bind/named.conf
sudo vi /etc/bind/named.conf.local
Add a zone to your DNS config file
At the end of the file add an entry similar to the following
zone "example.com" {
type master;
file "/etc/bind/db.example.com.conf";
};
As you will see, the type of zone is a master zone. This means that it is the primary holder for dns information regarding this domain.
Darian Brown – Webmaster's Blog and Portfolio
Great beginners guide. Enjoyed the read