配置bind
1、确定已经安装bind软件,需要安装3 个bind、bind-chroot、bind-util
[root@localhost wj]# yum install –y bind bind-chroot bind-util
2、修改配置文件“/etc/named.conf”
[root@localhost pub]# gedit /etc/named.conf
options {
# listen-on port 53 { 127.0.0.1; };
# listen-on-v6 port 53 { ::1; };
directory "/var/named";
。。。
};
。。。。
zone "david.cn" IN{ //正向解析配置
type master;
file "david.cn"; //注意名字,后面要用到这个名字
allow-update {none;};
};
zone "0.168.192.in-addr.arpa" IN{ //反向解析配置
type master;
file "192.168.0"; //注意名字,后面要用到这个名字
allow-update {none;};
};
3、编辑正向配置文件“/var/named/david.cn”,这个文件不存在,用户需要自己创建
[root@localhost pub]# gedit /var/named/david.cn
$TTL 86400
@ IN SOA bind.david.cn. root.david.cn. (
2011071001
3600
1800
604800
86400
)
IN NS bind.david.cn.
IN A 192.168.0.113 //这个是本机ip
IN MX 10 mailsrv.david.cn.
bind IN A 192.168.0.113
mailsrv IN A 192.168.0.250
www IN CNAME bind.david.cn.
4、编辑反向配置文件“/var/named/192.168.0”,这个文件不存在,用户需要自己创建
[root@localhost pub]# gedit /var/named/192.168.0
$TTL 86400
@ IN SOA bind.david.cn. root.david.cn. (
2011071001
3600
1800
604800
86400
)
IN NS bind.david.cn.
IN PTR david.cn.
IN A 255.255.255.0
113 IN PTR bind.david.cn.
250 IN PTR mailsrv.david.cn
5、重启服务(确保防火墙的53端口已经打开)
[root@localhost wj]# service named restart
停止 named: [确定]
启动 named: [确定]
[root@localhost wj]#
6、测试
[root@localhost wj]# nslookup
> server 192.168.0.113 //切换dns服务器为上面配置好的
Default server: 192.168.0.113
Address: 192.168.0.113#53
> bind.david.cn //正向解析A类型
Server: 192.168.0.113
Address: 192.168.0.113#53
Name: bind.david.cn
Address: 192.168.0.113
> mailsrv.david.cn //正向解析A类型
Server: 192.168.0.113
Address: 192.168.0.113#53
Name: mailsrv.david.cn
Address: 192.168.0.250
> set q=mx //正向解析MX类型
> david.cn
Server: 192.168.0.113
Address: 192.168.0.113#53
david.cn mail exchanger = 10 mailsrv.david.cn.
> www.david.cn //正向解析CNAME类型
Server: 192.168.0.113
Address: 192.168.0.113#53
www.david.cn canonical name = bind.david.cn.
> 192.168.0.113 //反向解析
Server: 192.168.0.113
Address: 192.168.0.113#53
113.0.168.192.in-addr.arpa name = bind.david.cn.
> 192.168.0.250 //反向解析
Server: 192.168.0.113
Address: 192.168.0.113#53
250.0.168.192.in-addr.arpa name = mailsrv.david.cn.0.168.192.in-addr.arpa.
>
1、确定已经安装bind软件,需要安装3 个bind、bind-chroot、bind-util
[root@localhost wj]# yum install –y bind bind-chroot bind-util
2、修改配置文件“/etc/named.conf”
[root@localhost pub]# gedit /etc/named.conf
options {
# listen-on port 53 { 127.0.0.1; };
# listen-on-v6 port 53 { ::1; };
directory "/var/named";
。。。
};
。。。。
zone "david.cn" IN{ //正向解析配置
type master;
file "david.cn"; //注意名字,后面要用到这个名字
allow-update {none;};
};
zone "0.168.192.in-addr.arpa" IN{ //反向解析配置
type master;
file "192.168.0"; //注意名字,后面要用到这个名字
allow-update {none;};
};
3、编辑正向配置文件“/var/named/david.cn”,这个文件不存在,用户需要自己创建
[root@localhost pub]# gedit /var/named/david.cn
$TTL 86400
@ IN SOA bind.david.cn. root.david.cn. (
2011071001
3600
1800
604800
86400
)
IN NS bind.david.cn.
IN A 192.168.0.113 //这个是本机ip
IN MX 10 mailsrv.david.cn.
bind IN A 192.168.0.113
mailsrv IN A 192.168.0.250
www IN CNAME bind.david.cn.
4、编辑反向配置文件“/var/named/192.168.0”,这个文件不存在,用户需要自己创建
[root@localhost pub]# gedit /var/named/192.168.0
$TTL 86400
@ IN SOA bind.david.cn. root.david.cn. (
2011071001
3600
1800
604800
86400
)
IN NS bind.david.cn.
IN PTR david.cn.
IN A 255.255.255.0
113 IN PTR bind.david.cn.
250 IN PTR mailsrv.david.cn
5、重启服务(确保防火墙的53端口已经打开)
[root@localhost wj]# service named restart
停止 named: [确定]
启动 named: [确定]
[root@localhost wj]#
6、测试
[root@localhost wj]# nslookup
> server 192.168.0.113 //切换dns服务器为上面配置好的
Default server: 192.168.0.113
Address: 192.168.0.113#53
> bind.david.cn //正向解析A类型
Server: 192.168.0.113
Address: 192.168.0.113#53
Name: bind.david.cn
Address: 192.168.0.113
> mailsrv.david.cn //正向解析A类型
Server: 192.168.0.113
Address: 192.168.0.113#53
Name: mailsrv.david.cn
Address: 192.168.0.250
> set q=mx //正向解析MX类型
> david.cn
Server: 192.168.0.113
Address: 192.168.0.113#53
david.cn mail exchanger = 10 mailsrv.david.cn.
> www.david.cn //正向解析CNAME类型
Server: 192.168.0.113
Address: 192.168.0.113#53
www.david.cn canonical name = bind.david.cn.
> 192.168.0.113 //反向解析
Server: 192.168.0.113
Address: 192.168.0.113#53
113.0.168.192.in-addr.arpa name = bind.david.cn.
> 192.168.0.250 //反向解析
Server: 192.168.0.113
Address: 192.168.0.113#53
250.0.168.192.in-addr.arpa name = mailsrv.david.cn.0.168.192.in-addr.arpa.
>