dns server 配置

1.apt-get install bind9

2.
看配置文件就懂了

oot@ubuntu:/etc/bind# cat named.conf
// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian.gz for information on the 
// structure of BIND configuration files in Debian, *BEFORE* you customize 
// this configuration file.
//
// If you are just adding zones, please do that in /etc/bind/named.conf.local

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

3.把我们自定义的解析放到第三个文件里

root@ubuntu:/etc/bind# cat named.conf.default-zones 
// prime the server with knowledge of the root servers
zone "." {
    type hint;
    file "/etc/bind/db.root";
};

// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912

zone "localhost" {
    type master;
    file "/etc/bind/db.local";
};

zone "127.in-addr.arpa" {
    type master;
    file "/etc/bind/db.127";
};

zone "0.in-addr.arpa" {
    type master;
    file "/etc/bind/db.0";
};

zone "255.in-addr.arpa" {
    type master;
    file "/etc/bind/db.255";
};

zone "hasee.com" {
    type master;
    file "/etc/bind/hasee.local";
};

zone "2.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/db.192";
};

我们定义了 hasee.com 这个域名下的解析,如果我们解析一个 xx.hasee.com的域名,就会在配置文件中寻找 /etc/bind/hasee.local

4.

root@ubuntu:/etc/bind# cat hasee.local 
;
; BIND data file for local loopback interface
;
$TTL   604800
@   IN  SOA localhost. root.localhost. (
                  2     ; Serial
             604800     ; Refresh
              86400     ; Retry
            2419200     ; Expire
             604800 )   ; Negative Cache TTL
;
@   IN  NS  localhost.
@   IN  A   127.0.0.1
@   IN  AAAA    ::1


ns IN A 192.168.2.104
www IN A 192.168.2.104

看最下面 如果是ns就解析到192.168.2.104

5.看反向解析

其实正向解析就是提取第一个点号前的字符串找匹配。
反向解析的原理也一样
比如 192.168.2.104
我们把它写成 104.2.168.192.in-addr.arpa
这样就可以像正向解析域名一样来提供反向解析了。

root@ubuntu:/etc/bind# cat db.192 
;
; BIND reverse data file for local loopback interface
;
$TTL   604800
@   IN  SOA localhost. root.localhost. (
                  1     ; Serial
             604800     ; Refresh
              86400     ; Retry
            2419200     ; Expire
             604800 )   ; Negative Cache TTL
;
@   IN  NS  localhost.
1.0.0   IN  PTR localhost.

104 IN PTR ns.hasee.com
104 IN PTR www.hasee.com

6.测试


root@ubuntu:/etc/bind# nslookup
> 
> server 127.0.01
Default server: 127.0.01
Address: 127.0.0.1#53
> 
> set type=A
> www.hasee.com
Server:     127.0.01
Address:    127.0.0.1#53

Name:   www.hasee.com
Address: 192.168.2.104
> 
> set type=ptr
> 192.168.2.104
Server:     127.0.01
Address:    127.0.0.1#53

104.2.168.192.in-addr.arpa  name = www.hasee.com.2.168.192.in-addr.arpa.
104.2.168.192.in-addr.arpa  name = ns.hasee.com.2.168.192.in-addr.arpa.
> exit

root@ubuntu:/etc/bind# 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值