Previous |
Home | Next |
Version: | - bind 9.3.2 |
If you are using a dynamic IP address and you would like to host your own website and email servers, then you will also need to review the Dynamic DNS details in Chapter 5. |
[bash]# cp
/etc/resolv.conf /etc/resolv.conf.original [bash]# vi /etc/resolv.conf |
search example.com nameserver 127.0.0.1 |
[bash]# cp
/etc/named.conf /etc/named.conf.original [bash]# vi /etc/named.conf |
options
{ directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; /* * If there is a firewall between you and nameservers you want * to talk to, you might need to uncomment the query-source * directive below. Previous versions of BIND always asked * questions using port 53, but BIND 8.1 uses an unprivileged * port by default. */ //query-source address * port 53; listen-on { 127.0.0.1; 192.168.1.1; }; allow-query { 127.0.0.1; 192.168.1.0/24; }; }; |
query-source address * port 53; |
zone
"." IN { type hint; file "named.ca"; }; |
#Place
INSIDE 'options' forward first; forwarders { xxx.xxx.xxx.xxx; xxx.xxx.xxx.xxx; }; <-- Add your ISP's DNS servers in here (IP addresses ONLY) |
Pay
particular attention to the format of the configuration file, missing
semicolons will
cause the daemon to function irrationally, if at all. |
[bash]# vi
/etc/named.conf |
The "example.com"
domain name must be substituted for your domain in the following
examples. |
zone "example.com" IN { type master; file "data/master-example.com"; allow-update { none; }; }; zone "1.168.192.in-addr.arpa" IN { type master; file "data/reverse-192.168.1"; allow-update { none; }; }; |
[bash]# vi /var/named/chroot/var/named/data/master-example.com |
; ; Zone File for "example.com" - Internal Use ONLY ; $TTL 1D @ IN SOA galaxy.example.com. sysadmin.example.com. ( 10 ; Serial 8H ; Refresh 2H ; Retry 4W ; Expire 1D ) ; Minimum ; IN NS galaxy ; Name Server for the domain IN MX 10 galaxy ; Mail Exchange ; example.com. IN A 192.168.1.1 ; IP address for the domain 'example.com' galaxy IN A 192.168.1.1 ; IP address for 'galaxy' www IN CNAME galaxy ; 'galaxy' is also known as www ftp IN CNAME galaxy ; 'galaxy' is also known as ftp ; wkstn1 IN A 192.168.1.201 ; MANUAL IP address entry for 'wkstn1' wkstn2 IN A 192.168.1.202 ; MANUAL IP address entry for 'wkstn2' |
[bash]# vi /var/named/chroot/var/named/data/reverse-192.168.1 |
; ; Reverse File for network "192.168.1.0/24" - Internal ONLY ; $TTL 1D @ IN SOA galaxy.example.com. sysadmin.example.com. ( 10 ; Serial 8H ; Refresh 2H ; Retry 4W ; Expire 1D ) ; Minimum ; IN NS galaxy.example.com. 1 IN PTR galaxy.example.com. ; 201 IN PTR wkstn1.example.com. ; MANUAL entry for 'wkstn1' reverse delegation 202 IN PTR wkstn2.example.com. ; MANUAL entry for 'wkstn2' reverse delegation |
When configuring the forward and reverse zone
files, ensure the IP addresses and the host names are identical in both
files. Also, DO NOT add DHCP names and addresses into the files, they
will change over time - this can be resolved by using Dynamic DNS below. |
Parameter |
Definition |
$TTL |
Time To Live for the
zone file |
IN |
The Internet system |
SOA |
Start Of Authority to
administer zone |
NS |
Name Server for the zone |
MX |
Mail Exchange for the
zone (needs a priority value) |
A |
Address records for
hosts / network equipment |
CNAME |
Canonical name for an
alias (points to "A" record) |
@ IN SOA galaxy.example.com. sysadmin.example.com. |
The periods "." located
at the end of fully qualified domain names are
required. Failure to use periods for FQDNs will cause irregular name resolution. |
MX 10 galaxy ; Mail Exchange |
[bash]# chown
named.named /var/named/chroot/var/named/data/master-example.com [bash]# ln -s /var/named/chroot/var/named/data/master-example.com /var/named/data/master-example.com [bash]# chown named.named /var/named/chroot/var/named/data/reverse-192.168.1 [bash]# ln -s /var/named/chroot/var/named/data/reverse-192.168.1 /var/named/data/reverse-192.168.1 |
The file naming
convention is typical of Fedora Core and may
differ slightly between Linux distributions. |
[bash]# named-checkconf
/etc/named.conf |
The most common errors for misconfiguration in the named file are missing semicolons ";" after parameter settings. |
[bash]# named-checkzone -d example.com /var/named/data/master-example.com |
loading "example.com"
from "/var/named/master-example.com"
class "IN" zone example.com/IN: loaded serial 10 OK |
[bash]# named-checkzone -d 1.168.192.in-addr.arpa /var/named/data/reverse-192.168.1 |
loading "1.168.192.in-addr.arpa" from "/var/named/data/reverse-192.168.1" class "IN" zone 1.168.192.in-addr.arpa/IN: loaded serial 10 OK |
The most common errors for misconfiguration in zone files are missing periods "." at the end of fully qualified domain names - especially for the SOA line. |
[bash]# chkconfig
--level 2345 named
on [bash]# /etc/init.d/named restart |
[bash]# chkconfig --list
named |
[bash]# grep named
/var/log/messages |
galaxy named[19111]: starting BIND 9.3.2 -u named -t /var/named/chroot galaxy named[19111]: found 2 CPUs, using 2 worker threads galaxy named[19111]: loading configuration from '/etc/named.conf' galaxy named[19111]: listening on IPv4 interface lo, 127.0.0.1#53 galaxy named[19111]: listening on IPv4 interface eth1, 192.168.1.1#53 galaxy named[19111]: command channel listening on 127.0.0.1#953 galaxy named[19111]: zone 0.in-addr.arpa/IN: loaded serial 42 galaxy named[19111]: zone 0.0.127.in-addr.arpa/IN: loaded serial 1997022700 galaxy named[19111]: zone 1.168.192.in-addr.arpa/IN: loaded serial 10 <-- Successful load galaxy named[19111]: zone 255.in-addr.arpa/IN: loaded serial 42 galaxy named[19111]: zone example.com/IN: loaded serial 10 <-- Successful load galaxy named[19111]: zone localdomain/IN: loaded serial 42 galaxy named[19111]: zone localhost/IN: loaded serial 42 galaxy named[19111]: running |
[bash]# dig
www.example.com |
; <<>> DiG 9.3.2 <<>> www.example.com ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48535 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.example.com. IN A ;; ANSWER SECTION: www.example.com. 86400 IN CNAME galaxy.example.com. galaxy.example.com. 86400 IN A 192.168.1.1 <-- Correct IP address returned ;; AUTHORITY SECTION: example.com. 86400 IN NS galaxy.example.com. ;; Query time: 3 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) <-- Query from local server ;; WHEN: Wed May 17 21:16:38 2006 ;; MSG SIZE rcvd: 84 |
[bash]# dig example.com
AXFR @localhost |
; <<>> DiG 9.3.2 <<>> example.com AXFR @localhost ; (1 server found) ;; global options: printcmd example.com. 86400 IN SOA galaxy.example.com. sysadmin.example.com. 10 28800 7200 2419200 86400 example.com. 86400 IN NS galaxy.example.com. example.com. 86400 IN MX 10 galaxy.example.com. example.com. 86400 IN A 192.168.1.1 ftp.example.com. 86400 IN CNAME galaxy.example.com. galaxy.example.com. 86400 IN A 192.168.1.1 wkstn1.example.com. 86400 IN A 192.168.1.201 wkstn2.example.com. 86400 IN A 192.168.1.202 www.example.com. 86400 IN CNAME galaxy.example.com. example.com. 86400 IN SOA galaxy.example.com. sysadmin.example.com. 10 28800 7200 2419200 86400 ;; Query time: 2 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) <-- Query from local server ;; WHEN: Wed May 17 21:17:21 2006 ;; XFR size: 9 records (messages 1) |
[bash]# dig fedora.redhat.org |
; <<>> DiG 9.3.2 <<>> fedora.redhat.org ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2193 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2 ;; QUESTION SECTION: ;fedora.redhat.org. IN A ;; ANSWER SECTION: fedora.redhat.org. 120 IN A 65.38.107.197 ;; AUTHORITY SECTION: redhat.org. 86400 IN NS ns1.ireithost.com. redhat.org. 86400 IN NS ns2.ireithost.com. ;; ADDITIONAL SECTION: ns1.ireithost.com. 156739 IN A 65.38.107.198 ns2.ireithost.com. 156739 IN A 65.38.109.156 ;; Query time: 395 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) <-- Query from local server ;; WHEN: Wed May 17 21:18:36 2006 ;; MSG SIZE rcvd: 132 |
[bash]# host 192.168.1.201 |
201.1.168.192.in-addr.arpa domain name pointer wkstn1.example.com. |
The following configuration adjustments assume you have already configured your ISC DHCP daemon in accordance with Chapter 10; please do this first. |
[bash]# rndc-confgen |
key "rndckey" { <-- Insert first section into /etc/rndc.conf file algorithm hmac-md5; secret "rZvmZb1cOtvkUfacVZ6oKA=="; }; options { default-key "rndckey"; default-server 127.0.0.1; default-port 953; }; <-- End of first section key "rndckey" { <-- Insert second section into /etc/named.conf file algorithm hmac-md5; secret "rZvmZb1cOtvkUfacVZ6oKA=="; }; controls { inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "rndckey"; }; }; <-- End of second section |
Ensure the "include /etc/rndc.key" directive is removed (or commented out) from both the /etc/rndc.conf and /etc/named.conf files, as you have now created a new configuration. Only ensure there is only ONE "controls" directive in /etc/named.conf. |
[bash]# dnssec-keygen -a HMAC-MD5 -b 128 -n USER DYNAMIC_DNS_KEY [bash]# cat Kdynamic_dns_key*.private |
Private-key-format: v1.2 Algorithm: 157 (HMAC_MD5) Key: LBxD9REd0XAEwPYOTZMS0w== <-- Shared MD5 Algorithm |
The "Kdynamic_dns_key*" file generated in the above step is safe to delete after the DNS and DHCP configuration files have been updated. |
[bash]# vi
/etc/named.conf |
key DYNAMIC_DNS_KEY { algorithm hmac-md5; secret LBxD9REd0XAEwPYOTZMS0w==; <-- Shared MD5 Algorithm }; zone "example.com" IN { type master; file "data/master-example.com"; allow-update { key DYNAMIC_DNS_KEY; }; <-- Allow "key" update }; zone "1.168.192.in-addr.arpa" IN { type master; file "data/reverse-192.168.1"; allow-update { key DYNAMIC_DNS_KEY; }; <-- Allow "key" update }; |
[bash]# vi
/etc/dhcpd.conf |
key DYNAMIC_DNS_KEY { algorithm hmac-md5; secret LBxD9REd0XAEwPYOTZMS0w==; <-- Shared MD5 Algorithm } zone example.org. { primary 127.0.0.1; key DYNAMIC_DNS_KEY; <-- Allow "key" update } zone 1.168.192.in-addr.arpa. { primary 127.0.0.1; key DYNAMIC_DNS_KEY; <-- Allow "key" update } |
The secure key must match in both the "/etc/named.conf" and "/etc/dhcpd.conf" files otherwise Dynamic DNS will not work effectively. |
[bash]# vi /etc/dhcpd.conf |
# # DHCP Server Config File # ddns-update-style interim; <--- Change these in /etc/dhcpd.conf allow client-updates; <--- Change these in /etc/dhcpd.conf |
[bash]# vi /etc/sysconfig/named |
OPTIONS=-4 ENABLE_ZONE_WRITE=yes ROOTDIR=/var/named/chroot |
For detailed information about named daemon, type "man named" at the command prompt. |
[bash]# /etc/init.d/dhcpd restart [bash]# /etc/init.d/named restart |
[bash]# grep dhcpd /var/log/messages |
dhcpd: if wkstn3.example.com IN TXT
"3168f50e8140ac8a1c8b84d809c6adbefe" rrset exists
and wkstn3.example.com IN A 192.168.1.200 rrset exists
delete wkstn3.example.com IN A 192.168.1.200: success. dhcpd: if wkstn3.example.com IN A rrset doesn't exist delete wkstn3.example.com IN TXT "3168f50e8140ac8a1c8b84d809c6adbefe": success. dhcpd: removed reverse map on 200.1.168.192.in-addr.arpa. dhcpd: DHCPRELEASE of 192.168.1.200 from 00:13:d4:2e:3b:d6 (wkstn3) via eth1 (found) dhcpd: DHCPDISCOVER from 00:13:d4:2e:3b:d6 via eth1 dhcpd: DHCPOFFER on 192.168.1.200 to 00:13:d4:2e:3b:d6 (wkstn3) via eth1 dhcpd: Added new forward map from wkstn3.example.com to 192.168.1.200 dhcpd: added reverse map from 200.1.168.192.in-addr.arpa. to wkstn3.example.com |
[bash]# grep named /var/log/messages |
named: client 127.0.0.1#32769: updating zone 'example.com/IN': adding an RR at 'wkstn3.example.com' A named: client 127.0.0.1#32769: updating zone 'example.com/IN': adding an RR at 'wkstn3.example.com' TXT named: client 127.0.0.1#32769: updating zone '1.168.192.in-addr.arpa/IN': deleting rrset at '200.1.168.192.in-addr.arpa' PTR named: client 127.0.0.1#32769: updating zone '1.168.192.in-addr.arpa/IN': adding an RR at '200.1.168.192.in-addr.arpa' PTR |
[bash]# host wkstn3.example.com |
wkstn3.example.com has address 192.168.1.200 |
[bash]# host 192.168.1.200 |
200.1.168.192.in-addr.arpa domain name pointer wkstn3.example.com |
Previous |
Home | Next |