bind9 DNS配置

1. master server configure
# domain: test.com
# ip: 192.168.1.107

1.1 install bind9
aptitude install bind9

1.2 configure /etc/bind/name.conf
#bakup named.conf
cp /etc/bind/named.conf /etc/bind/named.conf.default

add next
# 正向解析
zone "test.com" {
        type master;
        file "/etc/bind/db.test";
     allow-transfer { 192.168.1.109 ; }; #update slave server 192.168.1.109 db.test
        notify yes;
        also-notify { 192.168.1.109 ; };

};

#反向解析
zone "1.168.192.in-addr.arpa"{
        type master;
        file "/etc/bind/db.192.168.1";
    allow-transfer { 192.168.1.109 ; }; #update slave server 192.168.1.109 db.test
        notify yes;
        also-notify { 192.168.1.109 ; };
};


1.3 add /etc/bind/db.test db.192.168.1
vim /etc/bind/db.test

#db.test
$TTL    86400
$ORIGIN test.com.
@       IN      SOA     test.com.    root.test.com. (
                         20090201         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                          86400 )       ; Negative Cache TTL
@ IN NS test.com. 
www IN A 192.168.1.136
ftp IN A 192.168.1.107

#db.192.168.1
$TTL    86400
@       IN      SOA     test.com.  root.test.com. (
                         20090201         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                          86400 )       ; Negative Cache TTL
@ IN NS test.com.
136 IN PTR www.test.com. #其中“.”必须加上


1.4 restart bind9 or reload named.conf config
/etc/init.d/bind9 restart
or
rndc reload

2. slave server configure
# ip: 192.168.1.109

 2.1 install bind9
 aptitude install bind9

 2.2 config /etc/bind/named.conf
#add next
zone "test.com" {
        type slave;  #slave server
        file "/etc/bind/db.test";
        masters {192.168.1.107;}; #master server is 192.168.1.107
};

zone "1.168.192.in-addr.arpa"{
        type master;   #slave server
        file "/etc/bind/db.192.168.1";
    masters {192.168.1.107;}; #master server is 192.168.1.107
};

 2.3 add /etc/bind/db.test /etc/bind/db.192.168.1
#copy there form master server 192.168.1.107
#if you want update slave server config, the "serial" must < serial on master server

 2.4 change /etc/bind proteries
 chown bind /etc/bind
 #if you do not change, slalve can not update successfull.  permission denied
 
 2.5 restart bind

 
3. test dns

# 正向测试
aptitude install dnsutils
dig -x 192.168.1.107

# 反向测试

windows xp tools: nslookup
 

你可能感兴趣的:(linux,dns,反向,bind9,正向)