bluesky IN A 216.183.93.224
darkday IN A 216.183.93.225
The first field in each record is the hostname, followed by the address family ( IN ) and the record type ( A ), and then the IP address.
Next we have MX records for mail exchangers:
IN MX 10 bluesky
IN MX 20 global.proximity.on.ca.
These have a blank first field, followed by the address family ( IN ) and record type ( MX ), followed by the mail server priority (lower numbers are higher priority), and then the mail server hostname.
Note that global.proximity.on.ca is outside of this zone, so the hostname is written as a fully qualified domain name (FQDN) ending with a period.
We also need some aliases for common hostnames:
mail IN CNAME bluesky
ftp IN CNAME darkday
www IN CNAME bluesky
ww IN CNAME bluesky
wwww IN CNAME bluesky
These records are like A records, except that the record type is set to CNAME and the last field contains the canonical (true) hostname.
It is possible to override the default TTL by inserting it between the address family ( IN ) and the record type in each record. For example, you could set the TTL for the last CNAME record to five minutes:
wwww IN 5M CNAME bluesky
Putting this all together and adding some comments gives us the complete zone file:
; Zone file for 'fedorabook.com'
; Default TTL is 1 hour
$TTL 1H
; Start of authority
@ SOA ns1 chris.global.proximity.on.ca. (
2007201705 ; serial number
3D ; refresh
1H ; retry
3D ; expire
1H ) ; minimum
; Nameservers
IN NS bluesky
IN NS darkday
; Addresses of hosts
bluesky IN A 216.183.93.224
darkday IN A 216.183.93.225
; Mail exchangers
IN MX 10 bluesky
IN MX 20 darkday
; Nicknames/aliases
mail IN CNAME bluesky
www IN CNAME bluesky
ww IN CNAME bluesky
wwww IN CNAME bluesky
The filename for this data is /var/named/fedorabook.com.db , to match the file enTRy that we made in /etc/named.conf .
7.3.1.3. Testing DNS entries
Once you have your DNS entries configured, reload the named service. The end of the system message logfile, /var/log/messages , will look something like this:
Mar 4 22:14:58 core5 named[10977]: starting BIND 9.3.2 -u named
Mar 4 22:14:58 core5 named[10977]: found 1 CPU, using 1 worker thread
Mar 4 22:14:58 core5 named[10977]: loading configuration from '/etc/named.conf'
Mar 4 22:14:58 core5 named[10977]: listening on IPv4 interface lo, 127.0.0.1#53
Mar 4 22:14:58 core5 named[10977]: listening on IPv4 interface eth0, 172.16.97.100#53
Mar 4 22:14:58 core5 named[10977]: command channel listening on 127.0.0.1#953
Mar 4 22:14:58 core5 named[10977]: zone 0.in-addr.arpa/IN: loaded serial 42
Mar 4 22:14:58 core5 named[10977]: zone 0.0.127.in-addr.arpa/IN: loaded serial 1997022700
Mar 4 22:14:58 core5 named[10977]: zone 255.in-addr.arpa/IN: loaded serial 42
Mar 4 22:14:58 core5 named[10977]: zone 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa/IN: loaded serial 1997022700
Mar 4 22:14:58 core5 named[10977]: zone fedorabook.com/IN: loaded serial 2007201705
Mar 4 22:14:58 core5 named[10977]: zone localdomain/IN: loaded serial 42
Mar 4 22:14:58 core5 named[10977]: zone localhost/IN: loaded serial 42
Mar 4 22:14:58 core5 named[10977]: running
Mar 4 22:14:58 core5 named[10977]: zone fedorabook.com/IN: sending notifies (serial 2007201705)
If there is an error in your zone file, an error message will appear here. Read the error message carefully, and then edit your zone file to correct the error and try again (the most common errors are simple syntax errors in the configuration or zone files).
Once named has started without errors, test the nameserver using the dig command:
$ dig bluesky.fedorabook.com @localhost any
; <<>> DiG 9.3.2 <<>> bluesky.fedorabook.com @localhost any
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43031
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 1
;; QUESTION SECTION:
;bluesky.fedorabook.com. IN ANY
;; ANSWER SECTION:
bluesky.fedorabook.com. 3600 IN A 216.183.93.224
;; AUTHORITY SECTION:
fedorabook.com. 3600 IN NS bluesky.fedorabook.com.
fedorabook.com. 3600 IN NS darkday.fedorabook.com.
;; ADDITIONAL SECTION:
darkday.fedorabook.com. 3600 IN A 216.183.93.225
;; Query time: 17 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sat Mar 4 22:18:08 2006
;; MSG SIZE rcvd: 108
The argument @localhost tells dig to use the local nameserver instead of the one your machine is normally configured to use. The any argument instructs named to report any information that it finds about the requested server or domain (the default is to show only A records). You can substitute a record type such as soa or mx to see those specific resource records.
The line highlighted in bold the output shows the correct address for the requested hostname, which proves that named is configured correctly.
You can also test the nameserver with the host or nslookup commands (don't include the @ sign in front of the nameserver name localhost when using these commands):
$ host bluesky.fedorabook.com localhost
Using domain server:
Name: localhost
Address: 127.0.0.1#53
Aliases:
bluesky.fedorabook.com has address 216.183.93.224
Using domain server:
Name: localhost
Address: 127.0.0.1#53
Aliases:
$ nslookup bluesky.fedorabook.com localhost
Server: localhost
Address: 127.0.0.1#53
Name: bluesky.fedorabook.com
Address: 216.183.93.224
To test the caching capabilities of the nameserver, look up a hostname that is not in any of your local zones:
$ dig fedora.redhat.com @localhost
; <<>> DiG 9.3.2 <<>> fedora.redhat.com @localhost
; (1 server found)
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41999
Читать дальше