
Important files provided by caching-nameserver:
/var/named/localhost.zone # Forward zone for localhost
/var/named/named.ca # "Hints" file. Contains root servers
/var/named/named.local # Reverse zone for localhost
GUI configuration utility provided by bindconf package.
/etc/named.conf
options {
directory "/var/named"; // Working directory of server
allow-query { any; }; // Specify which hosts are allowed to query this server
allow-transfer { 192.168.1.0/24; }; // Specify hosts that are allowed to receive zone
// transfers from this server
recursion yes; // Enable recursive queries
allow-recursion {192.168.1.0/24; }; // Specify which hosts can perform recursive queries.
version "Surely you must be joking"; // Set version reported by ndc and when querying
// version.bind in the chaos class
};
// The following controls who can access this server using rndc.
// Bind to 127.0.0.1 and allow only localhost access.
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
zone "." IN { // Hints file containing root servers
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "xyz.com" IN { // Forward lookup zone for xyz.com
type master; // This is a master zone
file "db.xyz.com"; // Zone information stored in /var/named/db.xyz.com
allow-update { none; };
};
zone "zyx.com" IN { // Forward lookup zone for zyx.com
type master; // This is a master zone
file "db.zyx.com"; // Zone information stored in /var/named/db.zyx.com
allow-update { none; };
};
zone "somedomain.com" IN { // Forward lookup zone for somedomain.com
type slave; // This is a slave zone
file "db.somedomain.com"; // Optional for slave zones. If set, a copy of the zone
// information is kept locally on disk under /var/named.
};
include "/etc/rndc.key"; // Private key used for secure remote administration
See the end of the named.conf man page for more configuration examples.
SECURITY NOTE:
If the following options are left unspecified, they default to allowing access from all hosts.
allow-query
allow-transfer
allow-recursion
/etc/nsswitch.conf
hosts: files dns
networks: files
protocols: files nisplus
The "hosts" line specifies that we should first check our local files (e.g. /etc/hosts for hostname resolution before consulting DNS services. The "networks" line states that only our local files (e.g. /etc/networks) should be consulted for network information. The "protocols" line says we should first consult our local files (e.g. /etc/protocols) for protocol information, and then consult nisplus services if it isn't found in our local files.
/etc/hosts
/etc/resolv.conf
/etc/named.conf file:
forwarders { 192.168.1.20; };
/etc/named.conf file:
forward only;The "forwarders" option specifies which DNS or DNS servers queries should be forwarded to for resolution.
/etc/named.conf.
zone "somedomain.com" {
type master;
file "db.somedomain.com";
allow-transfer { 192.168.3.4; };
};
zone "somedomain.com" {
type slave;
masters { 192.168.1.50; };
file "db.somedomain.com";
};
masters - Specifies the DNS server that is the "master" of this domain.
file - Not required for slave. If specified, indicates the name of the local file where the zone information is kept.
file directive was used), it will load the information directly from disk reducing network traffic.
options {
...
allow-transfer { 192.168.1.45; };
...
};
Or you can specify the "allow-transfer" directive on a per zone basis as shown above.
.in-addr.arpa is used.
.in-addr.arpa to it.
For example, to provide reverse lookups for all hosts in the IP range 192.168.1.0/24, use the following zone name:
1.168.192.in-addr.arpa
zone "1.168.192.in-addr.arpa" {
type master;
file "db.1.168.192.in-addr.arpa";
};
zone "0.0.127.in-addr.arpa" { # Loopback zone
type master; # Should NEVER be a slave
file "db.0.0.127.in-addr.arpa";
};
zone "." {
type hint;
file "named.ca"; # Contains root DNS servers
}
dig @<rootserver>
dig @a.root-servers.net
support.somedomain.com. IN NS ns.support.somedomain.com.
ns.support IN A 192.168.44.10
development.somedomain.com IN NS ns.development.somedomain.com.
ns.development IN A 192.168.45.10
[domain/@] [ttl] [class] <type> <rdata> [comment]
/etc/named.conf for the zone. Otherwise, any name specified will have the domain appended to it unless it ends in a ".".
Hostnames can only consist of A-Z (case insensitive), 0-9, and -.
@ 1D IN SOA ns root (
2002011201 ; serial
3H ; refresh
15M ; retry
1W ; expire
1D ) ; minimum
@ 1D IN SOA ns.somedomain.com. root.somedomain.com. (
2002011201 ; serial
3H ; refresh
15M ; retry
1W ; expire
1D ) ; minimum
Both of the above two sample SOA RR are identical when the $ORIGIN is somedomain.com. The name server specified in the SOA record must be a machine with an A record. You cannot use machine named defined by a CNAME record in the SOA record.
Component Definitions:
Values for the above entries can be specified in seconds (default), minutes (M), hours(H), days(D), and weeks(W). You must use a capital letter to specify the unit and there can't be a space between the number and the unit.
86400 = 24H = 1D
@ IN NS ns1.somewhere.com.
somewhere.com. IN NS ns2.somewhere.com.
IN NS ns3.somewhere.com.
All 3 lines refer to the same domain. The @ in the first line refers to the origin (specified by the zone directive in /etc/named.conf. The second line explicitly states the domain (notice the trailing ".") The third line doesn't specify the domain or an @ so it defaults to the domain in the RR above it.)
ns1.somewhere.com. IN A 192.168.20.10 # FQDN specified. Notice trailing "."
ns2 IN A 192.168.20.11 # FQDN isn't required. In the last 4 lines,
ns3 IN A 192.168.20.12 # somedomain.com. is appended to ns2, ns3,
www IN A 192.168.20.15 # www, and mail
mail IN A 192.168.20.20
pop IN CNAME mail
imap IN CNAME mail
In this case, both pop and imap refer to the "mail" address (A) record in the previous example.
10 IN PTR ns1.somewhere.com.
11 IN PTR ns2.somewhere.com.
12 IN PTR ns3.somewhere.com.
15.1.168.192.in-addr.arpa. IN PTR www.somewhere.com.
20 IN PTR mail.somewhere.com.
Again, if a FQDN isn't specified, the domain is appended to the entry.
@ IN MX 5 mail.somewhere.com. ### Highest priority
somewhere.com. IN MX 10 mail2.somewhere.com.
IN MX 15 mail3.somewhere.com. ### Lowest priority
mail IN HINFO i686 Linux-2.4.18
www IN HINFO i686 Linux-2.4.17-pre2
/var/named.
$TTL 86400
$ORIGIN xyz.com. ; If not specified, it's taken from named.conf
; ns1 is a nameserver for the domain. root is the
; e-mail address of the owner of the domain. The domain
; is appended to each of these values since they don't
; end with a period. (e.g. they become ns1.xyz.com
; and root.xyz.com);
@ 1D IN SOA ns1 root (
2002011901 ; serial
3H ; refresh
15M ; retry
1W ; expire
1D ) ; minimum
; These two lines specify the same domain.
; @ means take it from the $ORIGIN or the zone
; specified in named.conf
@ IN NS ns1.xyz.com.
xyz.com. IN NS ns2.xyz.com.
ns1 IN A 192.168.1.20
ns2 IN A 192.168.1.21
www IN A 192.168.1.22
kashyyyk IN CNAME www
coruscant IN CNAME kashyyyk # BAD IDEA!!
www1.xyz.com. IN A 192.168.1.23
endor IN CNAME www1
mail IN A 192.168.1.24
backup-mail IN A 192.168.1.25
@ IN MX 5 mail # Both lines reference
xyz.com. IN MX 20 backup-mail # the same domain
support.xyz.com. IN NS ns.support.xyz.com. # Zone delegation
ns.support IN A 192.168.2.20
development.xyz.com. IN NS ns.development.xyz.com. # Zone delegation
ns.development.xyz.com. IN A 192.168.3.20
$TTL 86400
$ORIGIN 1.168.192.in-addr.arpa.
@ 1D IN SOA ns1.xyz.com. root.xyz.com. (
2002011901 ; serial
3H ; refresh
15M ; retry
1W ; expire
1D ) ; minimum
; These two lines specify the same domain.
; @ means take it from the $ORIGIN or the zone specified in named.conf
@ IN NS ns1.xyz.com.
1.168.192.in-addr.arpa. IN NS ns2.xyz.com.
20 IN PTR ns1.xyz.com. # Domain appended to 20
21.1.168.192.in-addr.arpa. IN PTR ns2.xyz.com. # Domain not appended (ends with a "." )
22 IN PTR www.xyz.com.
23.1.168.192.in-addr.arpa. IN PTR www1.xyz.com.
24 IN PTR mail.xyz.com.
25 IN PTR mail-backup.xyz.com.
| ERROR!! |