在CentOS上安装BIND

BIND在CentOS上安装

什么是绑定

BIND是将域名转换为IP地址的替代软件。 因为域名是字母,它们更容易记住。 所以如果我们浏览互联网,我们不需要记住IP地址。 例如,域名www.yourdomain.com可能会转换为192.168.0.1

你可以检查BIND数据包

[root@server named]# rpm -qa bind*
bind-libs-9.2.4-2
bind-utils-9.2.4-2
bind-9.2.4-2

2.使用IP 192.168.0.1设置计算机NS1作为域名服务器和域名yourdomain.com

[root@server ~]# cat /etc/resolv.conf
nameserver 192.168.0.1

3.设置文件/etc/named.conf

[root@server ~]# nano /etc/named.conf
//
// named.conf for Red Hat caching-nameserver
//
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;
};

//
// a caching only nameserver config
//
controls {
 inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};

zone "localhost" IN {
   type master;
   file "localhost.zone";
   allow-update { none; };
};

zone "yourdomain.com" IN {
   type master;
   file "/var/named/yourdomain.com.zone";
   allow-update { none; };
};

zone "0.168.192.in-addr.arpa" IN {
   type master;
   file "/var/named/0.168.192.rev";
   allow-update { none; };
};

include "/etc/rndc.key";

4.设置文件/var/named/yourdomain.com.zone

首先你必须创建文件yourdomain.com.zone ; 您可以使用以下语法:

[root@server ~]# nano /var/named/yourdomain.com.zone
$TTL            86400
@                 IN SOA            yourdomain.com.  root.yourdomain.com. (
100     ; serial
1H      ; refresh
1M      ; retry
1W      ; expiry
1D )    ; minimum
@                    IN NS             ns1.yourdomain.com.
@                    IN A                 192.168.0.1
ns1                 IN A                 192.168.0.1
@                    IN MX   10      mail.yourdomain.com.
mail                IN A                 192.168.0.1
WWW               IN A                 192.168.0.1

5.设置文件/var/named/0.168.192.rev

首先你必须创建文件0.168.192.rev ; 您可以使用以下语法:

[root@server ~]# nano /var/named/0.168.192.rev
$TTL    86400
@                 IN SOA          yourdomain.com. root.yourdomain.com. (
100     ; serial
1H      ; refresh
1M      ; retry
1W      ; expiry
1D)     ; minimum
@                IN NS            ns1.yourdomain.com.
1                 IN PTR          binggo.yourdomain.com.

nslookup yourdomain.com

[root@server ~]# nslookup yourdomain.com
Server:         192.168.0.1
Address:        192.168.0.1#53
Name:   yourdomain.com
Address: 192.168.0.1

挖掘yourdomain.com

[root@server ~]# dig yourdomain.com
; DiG 9.2.4 yourdomain.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10576
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;yourdomain.com.             IN      A
;; ANSWER SECTION:
yourdomain.com.      86400   IN      A       192.168.0.1
;; AUTHORITY SECTION:
yourdomain.com.      86400   IN      NS      ns1.yourdomain.com.
;; ADDITIONAL SECTION:
ns1.yourdomain.com.  86400   IN      A       192.168.0.1
;; Query time: 8 msec
;; SERVER: 192.168.0.1#53(192.168.0.1)
;; WHEN: Sat Aug  2 10:56:16 2008
;; MSG SIZE  rcvd: 85

NS 1的配置完成

如果看到错误,可以尝试更改/ var / named文件夹的权限。

[root@server ~]# chmod 777 -Rvf /var/named/
mode of `/var/named/’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.zero’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/localhost.zone’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/198.99.208.rev’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/data’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.local’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.ca’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.ip6.local’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/localdomain.zone’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/yourdomain.com.zone’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/named.broadcast’ changed to 0777 (rwxrwxrwx)
mode of `/var/named/slaves’ changed to 0777 (rwxrwxrwx)

9.检查/ var / log / messages日志以找出是否存在错误

[root@server ~]# tail /var/log/messages
Aug  2 10:53:57 server named[20094]: listening on IPv4 interface venet0:0, 192.168.0.1#53
Aug  2 10:53:57 server named[20094]: command channel listening on 127.0.0.1#953
Aug  2 10:53:57 server named[20094]: zone 0.168.192.in-addr.arpa/IN: loaded serial 100
Aug  2 10:53:57 server named[20094]: zone yourdomain.com/IN: loaded serial 100
Aug  2 10:53:57 server named[20094]: zone localhost/IN: loaded serial 42
Aug  2 10:53:57 server named[20094]: running
Aug  2 10:53:57 server named[20094]: zone yourdomain.com/IN: sending notifies (serial 100)
Aug  2 10:53:57 server named[20094]: zone 0.168.192.in-addr.arpa/IN: sending notifies (serial 100)
Aug  2 10:53:57 server named[20094]: received notify for zone ‘yourdomain.com’
Aug  2 10:53:57 server named[20094]: received notify for zone ‘0.168.192.in-addr.arpa’
赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏