Centos5 DNS 安装配置
2009-05-14 11:45
246 查看
[align=left]1 .Centos5环境下相关BIND包[/align]
[align=left][root@localhost ~]# rpm -qa |grep bind
bind-9.3.4-10.P1.el5 \ DNS服务器的主程序
ypbind-1.19-11.el5
bind-libs-9.3.4-10.P1.el5 \ 域名解析功能必备的库文件
bind-utils-9.3.4-10.P1.el5 \ DNS服务器的测试工具程序
bind-chroot-9.3.4-10.P1.el5 \ chroot的模式,提高BIND的安全[/align]
[align=left]caching-nameserver-9.3.4-10.P1.el5 \BIND初始化文件[/align]
[align=left] [/align]
[align=left]2 相关注意[/align]
[align=left]因为现在版本都使用chroot技术,所以BIND的配置文件named.conf还有区域文件都在/var/named/chroot/目录下,如:配置文件named.conf在/var/named/chroot/etc/下,而区域配置文件在/var/named/chroot/var/named/下,另外其文件属性需要修改为root.named,否则会造成DNS解析错误,修改命令为 chown root.named 文件名。[/align]
[align=left] [/align]
[align=left]3 BIND的安装[/align]
[align=left]这里使用rpm包进行安装,安装包在系统DVD光盘中能找到:[/align]
[align=left][root@localhost cdrom]# ls /mnt/cdrom/CentOS/bind*[/align]
[align=left][root@localhost cdrom]# ls /mnt/cdrom/CentOS/cach*[/align]
[align=left][root@localhost cdrom]# rpm -ivh 相关包[/align]
[align=left]rpm包安装完成后,首先来建立named.conf文件和相关区域文件,进入/var/named/chroot/etc下,建立主配置文件:[/align]
[align=left][root@localhost etc]# ls
localtim med.caching-nameserver.conf named.rfc1912.zones rndc.key
[root@localhost etc]# cp named.rfc1912.zones named.conf[/align]
[align=left] [/align]
[align=left]然后进入到/var/named/chroot/var/named/下建立区域文件(假设建立一个test.com的域):[/align]
[align=left][root@localhost named]# ls
localdomain.zone named.127.0.0 named.ca named.local named.root slaves
data localhost.zone named.broadcast named.ip6.local named.localhost named.zero [/align]
[align=left][root@localhost named]# cp localhost.zone test.com \正向解析区域文件
[root@localhost named]# cp named.local 0.168.192.zone \反向解析区域文件[/align]
[align=left] [/align]
[align=left]4 BIND的配置[/align]
[align=left]首先修改/etc/resolv.conf把机器DNS指向自己:[/align]
[align=left][root@localhost named]# vi /etc/resolv.conf[/align]
[align=left] nameserver 192.168.0.8
search localdomain[/align]
[align=left] [/align]
[align=left]配置named.conf:[/align]
[align=left][root@localhost etc]# more named.conf
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {[/align]
[align=left]directory "/var/named";[/align]
[align=left]};[/align]
[align=left]zone "." IN {
type hint;
file "named.ca";
};[/align]
[align=left]zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};[/align]
[align=left]zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};[/align]
[align=left]zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};[/align]
[align=left]zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "named.ip6.local";
allow-update { none; };
};[/align]
[align=left]zone "255.in-addr.arpa" IN {
type master;
file "named.broadcast";
allow-update { none; };
};[/align]
[align=left]zone "0.in-addr.arpa" IN {
type master;
file "named.zero";
allow-update { none; };
};[/align]
[align=left]zone "0.168.192.in-addr.arpa" IN {
type master;
file "0.168.192.zone";
allow-update { none; };
};
zone "test.com" IN {
type master;
file "test.com";
allow-update { none; };
};[/align]
[align=left] [/align]
[align=left]配置正向区域文件test.com:[/align]
[align=left][root@localhost named]# more test.com
$TTL 86400
@ IN SOA ns.test.com. root.test.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum[/align]
[align=left] IN NS ns.test.com.
IN A 192.168.0.8[/align]
[align=left]ns IN A 192.168.0.8[/align]
[align=left]www IN A 192.168.0.8[/align]
[align=left] [/align]
[align=left]配置反向区域文件0.168.192.zone:[/align]
[align=left][root@localhost named]# more .0.168.192.zone
$TTL 86400
0.168.192.in-addr.arpa. IN SOA ns.test.com. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
@ IN NS ns.test.com.
8 IN PTR ns.test.com.[/align]
[align=left] [/align]
[align=left]5 测试[/align]
[align=left]启动named服务进程[/align]
[align=left][root@localhost named]# service named start
[/align]
[align=left][root@localhost named]# host 192.168.0.8[/align]
[align=left]8.0.168.192.in-addr.arpa domain name pointer ns.test.com.
[/align]
[align=left][root@localhost named]# host
www.test.com has address 192.168.0.8[/align]
[align=left] [/align]
[align=left][root@localhost named]# nslookup
> www.test.com
Server: 192.168.0.8[/align]
[align=left]Address: 192.168.0.8#53[/align]
[align=left]Name: www.test.com
Address: 192.168.0.8
> [/align]
[align=left] [/align]
[align=left]6 故障排查[/align]
[align=left]修改完named.conf 或区域数据文件后,一般需要重新启动named服务生效[/align]
[align=left][root@localhost named]# service named restart[/align]
[align=left] [/align]
[align=left]如果不重启named服务的话,那么:
修改了区文件用 rndc reload 区名 更新。
修改了named.conf用 rndc reconfig 更新。
[/align]
[align=left] [/align]
[align=left]在配置完以后可以通过以下命令对配置文件进行检查[/align]
[align=left]root@localhost named]# named-checkconf 主配置文件
root@localhost named]# named-checkzone 区域文件[/align]
[align=left] [/align]
[align=left]BIND的日志文件中的记录 [/align]
[align=left][root@localhost named]# tail /var/log/message/named*
[/align]
[align=left] [/align]本文出自 “流星 ” 博客,请务必保留此出处http://lsscto.blog.51cto.com/779396/157779
[align=left][root@localhost ~]# rpm -qa |grep bind
bind-9.3.4-10.P1.el5 \ DNS服务器的主程序
ypbind-1.19-11.el5
bind-libs-9.3.4-10.P1.el5 \ 域名解析功能必备的库文件
bind-utils-9.3.4-10.P1.el5 \ DNS服务器的测试工具程序
bind-chroot-9.3.4-10.P1.el5 \ chroot的模式,提高BIND的安全[/align]
[align=left]caching-nameserver-9.3.4-10.P1.el5 \BIND初始化文件[/align]
[align=left] [/align]
[align=left]2 相关注意[/align]
[align=left]因为现在版本都使用chroot技术,所以BIND的配置文件named.conf还有区域文件都在/var/named/chroot/目录下,如:配置文件named.conf在/var/named/chroot/etc/下,而区域配置文件在/var/named/chroot/var/named/下,另外其文件属性需要修改为root.named,否则会造成DNS解析错误,修改命令为 chown root.named 文件名。[/align]
[align=left] [/align]
[align=left]3 BIND的安装[/align]
[align=left]这里使用rpm包进行安装,安装包在系统DVD光盘中能找到:[/align]
[align=left][root@localhost cdrom]# ls /mnt/cdrom/CentOS/bind*[/align]
[align=left][root@localhost cdrom]# ls /mnt/cdrom/CentOS/cach*[/align]
[align=left][root@localhost cdrom]# rpm -ivh 相关包[/align]
[align=left]rpm包安装完成后,首先来建立named.conf文件和相关区域文件,进入/var/named/chroot/etc下,建立主配置文件:[/align]
[align=left][root@localhost etc]# ls
localtim med.caching-nameserver.conf named.rfc1912.zones rndc.key
[root@localhost etc]# cp named.rfc1912.zones named.conf[/align]
[align=left] [/align]
[align=left]然后进入到/var/named/chroot/var/named/下建立区域文件(假设建立一个test.com的域):[/align]
[align=left][root@localhost named]# ls
localdomain.zone named.127.0.0 named.ca named.local named.root slaves
data localhost.zone named.broadcast named.ip6.local named.localhost named.zero [/align]
[align=left][root@localhost named]# cp localhost.zone test.com \正向解析区域文件
[root@localhost named]# cp named.local 0.168.192.zone \反向解析区域文件[/align]
[align=left] [/align]
[align=left]4 BIND的配置[/align]
[align=left]首先修改/etc/resolv.conf把机器DNS指向自己:[/align]
[align=left][root@localhost named]# vi /etc/resolv.conf[/align]
[align=left] nameserver 192.168.0.8
search localdomain[/align]
[align=left] [/align]
[align=left]配置named.conf:[/align]
[align=left][root@localhost etc]# more named.conf
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {[/align]
[align=left]directory "/var/named";[/align]
[align=left]};[/align]
[align=left]zone "." IN {
type hint;
file "named.ca";
};[/align]
[align=left]zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};[/align]
[align=left]zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};[/align]
[align=left]zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};[/align]
[align=left]zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "named.ip6.local";
allow-update { none; };
};[/align]
[align=left]zone "255.in-addr.arpa" IN {
type master;
file "named.broadcast";
allow-update { none; };
};[/align]
[align=left]zone "0.in-addr.arpa" IN {
type master;
file "named.zero";
allow-update { none; };
};[/align]
[align=left]zone "0.168.192.in-addr.arpa" IN {
type master;
file "0.168.192.zone";
allow-update { none; };
};
zone "test.com" IN {
type master;
file "test.com";
allow-update { none; };
};[/align]
[align=left] [/align]
[align=left]配置正向区域文件test.com:[/align]
[align=left][root@localhost named]# more test.com
$TTL 86400
@ IN SOA ns.test.com. root.test.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum[/align]
[align=left] IN NS ns.test.com.
IN A 192.168.0.8[/align]
[align=left]ns IN A 192.168.0.8[/align]
[align=left]www IN A 192.168.0.8[/align]
[align=left] [/align]
[align=left]配置反向区域文件0.168.192.zone:[/align]
[align=left][root@localhost named]# more .0.168.192.zone
$TTL 86400
0.168.192.in-addr.arpa. IN SOA ns.test.com. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
@ IN NS ns.test.com.
8 IN PTR ns.test.com.[/align]
[align=left] [/align]
[align=left]5 测试[/align]
[align=left]启动named服务进程[/align]
[align=left][root@localhost named]# service named start
[/align]
[align=left][root@localhost named]# host 192.168.0.8[/align]
[align=left]8.0.168.192.in-addr.arpa domain name pointer ns.test.com.
[/align]
[align=left][root@localhost named]# host
www.test.com has address 192.168.0.8[/align]
[align=left] [/align]
[align=left][root@localhost named]# nslookup
> www.test.com
Server: 192.168.0.8[/align]
[align=left]Address: 192.168.0.8#53[/align]
[align=left]Name: www.test.com
Address: 192.168.0.8
> [/align]
[align=left] [/align]
[align=left]6 故障排查[/align]
[align=left]修改完named.conf 或区域数据文件后,一般需要重新启动named服务生效[/align]
[align=left][root@localhost named]# service named restart[/align]
[align=left] [/align]
[align=left]如果不重启named服务的话,那么:
修改了区文件用 rndc reload 区名 更新。
修改了named.conf用 rndc reconfig 更新。
[/align]
[align=left] [/align]
[align=left]在配置完以后可以通过以下命令对配置文件进行检查[/align]
[align=left]root@localhost named]# named-checkconf 主配置文件
root@localhost named]# named-checkzone 区域文件[/align]
[align=left] [/align]
[align=left]BIND的日志文件中的记录 [/align]
[align=left][root@localhost named]# tail /var/log/message/named*
[/align]
[align=left] [/align]本文出自 “流星 ” 博客,请务必保留此出处http://lsscto.blog.51cto.com/779396/157779
相关文章推荐
- Centos5 DNS 安装配置
- centos5下安装配置oracle数据库
- dns安装与配置,以及基本用法。
- RHEL5下安装配置DNS服务
- 部署和调优 3.3 dns安装配置-3
- 为DC配置独立DNS服务器之①安装DNS组件服务
- 详解在Linux下DNS的安装及配置
- dnsmasq轻量级DNS安装配置
- IT基础结构-4.BDNS-安装与配置
- CentOS5 安装vsFtpd软件及配置
- Centos系统dns安装及配置
- DNS安装及配置
- linux DNS安装配置
- DNS服务器的安装 和配置
- DNS for linux 安装配置
- Redhat linux9下安装DNS配置文档
- DNS(bind)服务器的安装与配置
- DNS基本的理论知识以及简单的安装配置你掌握了吗?
- k8s dns 服务安装配置说明
- 一起学DNS系列(四)DNS服务器、客户端安装及配置