分类: LINUX
2010-04-13 20:26:31
由于毕业设计需要弄DNS软件bind的扩展。其实关于bind的安装偶早就实现过,现在记下来算是对当时的一种记录吧。
[root@localhost Downloads]# pwd /root/Downloads [root@localhost Downloads]# wget -c ftp://ftp.isc.org/isc/bind9/9.2.3/bind-9.2.3.tar.gz |
[root@localhost Downloads]# tar xvf bind-9.2.3.tar.gz |
[root@localhost Downloads]# cd bind-9.2.3 [root@localhost bind-9.2.3]# pwd /root/Downloads/bind-9.2.3 [root@localhost bind-9.2.3]# more README #--->这步知道它是如何安装的。 [root@localhost bind-9.2.3]# ./configure --help|more #--->了解产生Makefile之前的环境,开启哪些开关之类。如下面的--enable-threads. [root@localhost bind-9.2.3]# ./configure --prefix=/usr/local/bind/ --enable-threads #---->安装到/usr/local/bind目录下,-enable-trheads对多核的机器有效,如果是单核的就不要了,因为线程的切换带来的开销会更大。 |
[root@localhost bind-9.2.3]# make #--->编译,并连接 [root@localhost bind-9.2.3]# make install #---->安装,将二进制执行文件、man文档等安装到--prefix指点的目录下。 |
[root@localhost bind-9.2.3]# cd /usr/local/bind [root@localhost bind]# mkdir etc/ [root@localhost bind]# ls bin etc include lib man sbin [root@localhost bind]# ./sbin/rndc-confgen > etc/rndc.conf #--->创建etc/rndc.conf 配置文件,注意etc前面是没有"/"的,即是指:/usr/local/bind/etc这个目录 [root@localhost bind]# cat etc/rndc.conf |tail -10|head -9|sed -e s/#\ //g > etc/named.conf #--->取etc/rndc.conf后面注释的10行,加入到named.conf文件中。 [root@localhost bind]# vim etc/named.conf #--->编辑named.conf文件,加入下面红色的。蓝色的部分在上一部就写进去了的。整个named.conf如下: key "rndc-key" { algorithm hmac-md5; secret "xrnciQrhe33CyXlTYuYAXQ=="; }; controls { inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "rndc-key"; }; }; //加入下面红色部分. options { directory "/usr/local/bind/var/named"; //指定配置文件目录,下面的named.pid, localhost.zone等文件都是相对这个目录. pid-file "named.pid"; }; // a master name server configuration // zone "." { type hint; file "named.root"; //该文件需要从ftp://ftp.internic.org/domain/named.root下载,放到/usr/local/bind/var/named目录下。 }; zone "localhost" IN{ type master; file "localhost.zone"; allow-update{ none; }; }; zone "0.0.127.in-addr.arpa" { type master; file "localhost.rev"; allow-update{ none; }; }; zone "test.com" IN{ type master; file "test.com.zone"; allow-update{ none; }; }; zone "2.22.222.222.in-addr.arpa" IN{ type master; file "test.com.rev"; allow-update{ none; }; }; [root@localhost bind]# pwd /usr/local/bind [root@localhost bind]# mkdir -p var/named [root@localhost bind]# cd var/named/ [root@localhost named]# wget ftp://ftp.internic.org/domain/named.root [root@localhost named]# vim localhost.zone #-->本地正向解析,将localhost解析为127.0.0.1 $TTL 86400 $ORIGIN localhost. //注意后面有个".",后面的也一样 @ 1D IN SOA @ root( 42 ;serial(d.adams) 3H ;refresh 15M ;retry 1W ;expiry 1D) ;minimum 1D IN NS @ 1D IN A 127.0.0.1 [root@localhost named]# vim localhost.rev #--->本地反向解析,127.0.0.1解析为localhost $TTL 86400 @ IN SOA localhost. root.localhost. ( 1997022700 ;Serival 28800 ;Refresh 14400 ;Retry 3600000 ;Expire 86400) ;Minimum IN NS localhost. 1 IN PTR localhost. [root@localhost named]# vim test.com.zone #--->test.com的正向解析,这里解析为222.222.22.2 $TTL 1D @ IN SOA test.com. root.test.com.( 1053891162 3H 15M 1W 1D) IN NS test.com. IN MX 5 test.com. www IN A 222.222.22.2 [root@localhost named]# vim test.com.rev #--->test.com的反向解析 $TTL 86400 @ IN SOA test.com. root.test.com.( 20031001; 7200; 3600; 43200; 86400); @ IN NS test.com 82 IN PTR dns.test.com |
[root@localhost bind]# ./sbin/named -gc ./etc/named.conf Apr 14 03:58:09.487 starting BIND 9.2.3 -gc ./etc/named.conf Apr 14 03:58:09.494 using 1 CPU Apr 14 03:58:09.519 loading configuration from '/usr/local/bind/./etc/named.conf' Apr 14 03:58:09.521 no IPv6 interfaces found Apr 14 03:58:09.521 listening on IPv4 interface lo, 127.0.0.1#53 Apr 14 03:58:09.526 listening on IPv4 interface eth0, 10.14.2.11#53 Apr 14 03:58:09.535 command channel listening on 127.0.0.1#953 Apr 14 03:58:09.535 ignoring config file logging statement due to -g option Apr 14 03:58:09.544 zone 0.0.127.in-addr.arpa/IN: loaded serial 1997022700 Apr 14 03:58:09.548 zone 2.22.222.222.in-addr.arpa/IN: loaded serial 20031001 Apr 14 03:58:09.549 zone test.com/IN: loaded serial 1053891162 Apr 14 03:58:09.552 zone localhost/IN: loaded serial 42 Apr 14 03:58:09.553 running Apr 14 03:58:09.554 zone 2.22.222.222.in-addr.arpa/IN: sending notifies (serial 20031001) 另外开一个终端 [root@localhost ~]# vim /etc/resolv.conf #-->修改DNS服务器,将本机的ip加入,放在第一个nameserver。 # Generated by NetworkManager #domain stu.edu.cn #search stu.edu.cn nameserver 10.14.2.11 nameserver 202.104.245.186 nameserver 202.192.159.2 [root@localhost ~]# nslookup Server: 10.14.2.11 Address: 10.14.2.11#53 Name: Address: 222.222.22.1 #--->成功解析。 Name: Address: 222.222.22.2 [root@localhost ~]# |
《TCP/IP网络管理》 http://blog.chinaunix.net/u3/94024/showart_2148287.html |