Chinaunix首页 | 论坛 | 博客
  • 博客访问: 321291
  • 博文数量: 50
  • 博客积分: 3052
  • 博客等级: 中校
  • 技术积分: 710
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-03 12:13
文章分类
文章存档

2009年(10)

2008年(40)

我的朋友

分类:

2008-05-30 21:04:02

一直也没有机会接触dns,最近终于有机会亲自操刀了,为了到时不至于慌忙,这两天有时间自己安装了一下,简单把我的安装过程记录如下

需求也不是很大:
1,通过这个dns可以解析其他域名
2,通过这个dns解析我自己设定的域名及二级子域名

可以到dns到bind-9.4.2.tar.gz

tar zxvf bind-9.4.2.tar.gz
cd bind-9.4.2
./configure --enable-threads --enable-largefile --disable-openssl-version-check --prefix=/usr/local/named
make && make install

cd /usr/local/named/
sbin/rndc-confgen > etc/rndc.conf
tail -10 rndc.conf |head -9|sed s/#\ //g >named.conf
cd /usr/local/named/var
mkdir named
cd named/

建立localhost.zone,内容如下

$TTL 3h
@ IN SOA @ root (
                20080530      ;序列号
                3h            ;3小时后刷新
                1h            ;1小时后重试
                1w            ;1周后期满
                1h )          ;否定缓存TTL为1小时
        IN NS loaclhost.
        IN A 127.0.0.1

建立ptr.127.0.0文件,内容如下

$TTL 3h
@ IN SOA localhost. root.localhost. (
                        20080530
                        3h
                        1h
                        1w
                        1h )
        IN NS localhost.
1       IN PTR localhost.

接下来是建立我自己的一个域名,mosquito.edu的zone文件
mosquito.edu.zone,内容如下:

$TTL 3h
@ IN SOA linux01 root.mosquito (
                        20080530
                        3h
                        1h
                        1w
                        1h )
        IN NS linux01
www     IN A 192.168.153.130

建立ptr.192.168.153文件,内容如下

$TTL 3h
@ IN SOA linux01.mosquito.edu. root.mosquito.edu. (
        20080530
        3h
        1h
        1w
        1h )
        IN NS linux01.mosquito.edu.
130     IN PTR linux01.mosquito.edu.

接下来建立named.root文件,内容如下

; IMPORTANT:
; do NOT use this file for yourself, please follow the following
; instructions to get a fresher copy of it.
; This file holds the information on root name servers needed to
; initialize cache of Internet domain name servers
; (e.g. reference this file in the "cache . "
; configuration file of BIND domain name servers).
;
; This file is made available by InterNIC registration services
; under anonymous FTP as
; file /domain/named.root
; on server FTP.RS.INTERNIC.NET
; -OR- under Gopher at RS.INTERNIC.NET
; under menu InterNIC Registration Services (NSI)
; submenu InterNIC Registration Archives
; file named.root
;
; last update: May 19, 1997
; related version of root zone: 1997051700
;
;
; formerly NS.INTERNIC.NET
;
. 3600000 IN NS A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
;
; formerly NS1.ISI.EDU
;
. 3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 128.9.0.107
;
; formerly C.PSI.NET
;
. 3600000 NS C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12
;
; formerly TERP.UMD.EDU
;
. 3600000 NS D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET. 3600000 A 128.8.10.90
;
; formerly NS.NASA.GOV
;
. 3600000 NS E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10
;
; formerly NS.ISC.ORG
;
. 3600000 NS F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241
;
; formerly NS.NIC.DDN.MIL
;
. 3600000 NS G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4
;
; formerly AOS.ARL.ARMY.MIL
;
. 3600000 NS H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53
;
; formerly NIC.NORDU.NET
;
. 3600000 NS I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
;
; temporarily housed at NSI (InterNIC)
;
. 3600000 NS J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET. 3600000 A 198.41.0.10
;
; housed in LINX, operated by RIPE NCC
;
. 3600000 NS K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
;
; temporarily housed at ISI (IANA);
. 3600000 NS L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET. 3600000 A 198.32.64.12
;
; temporarily housed at ISI (IANA)
;
. 3600000 NS M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET. 3600000 A 198.32.65.12
; End of File

cd /usr/local/named/etc
vi named.conf添加如下内容

options {
        directory "/usr/local/named/var/named";
        allow-query-cache { any; };
        pid-file "named.pid";
};
 
zone "." IN {
        type hint;
        file "named.root";
};
 
zone "localhost" IN {
        type master;
        file "localhost.zone";
        allow-update{none;};
};
 
zone "0.0.127.in-addr.arpa" IN {
        type master;
        file "ptr.127.0.0";
};
 
zone "mosquito.edu" IN {
        type master;
        file "mosquito.edu.zone";
};


zone "153.168.192.in-addr.arpa" IN {

       type master;

       file "ptr.192.168.153";

};

至此配置文件都准备完毕了,使用/usr/local/named/sbin/named -c /usr/local/named/etc/named.conf 启动dns
可以从/var/log/messages文件中查看dns启动的情况
接下了可以测试了,现在dns上进行
dig @localhost
返回结果如下

;; AUTHORITY SECTION:
sina.com.cn. 86400 IN NS ns1.sina.com.cn.
sina.com.cn. 86400 IN NS ns3.sina.com.cn.
sina.com.cn. 86400 IN NS ns2.sina.com.cn.
 
;; ADDITIONAL SECTION:
ns2.sina.com.cn. 86400 IN A 61.172.201.254
 
;; Query time: 601 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)      由此看到是由本机dns解析的了
;; WHEN: Fri May 30 12:04:16 2008
;; MSG SIZE rcvd: 185

dig @localhost

;; ANSWER SECTION:
www.mosquito.edu. 10800 IN A 192.168.153.130
 
;; AUTHORITY SECTION:
mosquito.edu. 10800 IN NS linux01.mosquito.edu.
 
;; Query time: 29 msec
;; SERVER: 127.0.0.1#53(localhost)      同样可以返回正确的结果
;; WHEN: Fri May 30 12:04:52 2008
;; MSG SIZE rcvd: 72

看来我自己的域名也可以正确的解析了,接下来看看反向情况
host 192.168.153.130

[root@linux01 etc]# host 192.168.153.130
130.153.168.192.in-addr.arpa domain name pointer linux01.mosquito.edu.

然后可以把另外一台电脑的dns改成这台的ip进行测试,经过我自己的测试是正常的,测试返回的结果我就不贴出来了

阅读(1346) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~