Linux基础教程:RHEL5.0 搭建DNS服务器
实验环境: VM 6.0 ,RHEL5.0, 本地YUM源
次环境是把MAIL ,WWW等服务器与DNS 服务器放在一起
-、先检查系统是安装了bind.rpm 与caching-nameserver.rpm包
[[email protected] ~]# rpm -qa bind* caching-*
bind-chroot-9.3.3-7.el5
bind-libs-9.3.3-7.el5
bind-9.3.3-7.el5
bind-libbind-devel-9.3.3-7.el5
bind-utils-9.3.3-7.el5
bind-devel-9.3.3-7.el5
caching-nameserver-9.3.3-7.el5
bind-sdb-9.3.3-7.el5
[[email protected] ~]#
若没有,就安装这些包
二、配置dns的正向和反向解析文件
[[email protected] ~]# cd /var/named/chroot/etc/
[[email protected] etc]# ll
total 24
-rw-r--r-- 1 root root 165 Apr 29 19:42 localtime
-rw-r----- 1 root named 1100 Jan 17 2007 named.caching-nameserver.conf
-rw-r----- 1 root named 614 Apr 30 13:04 named.rfc1912.zones
-rw-r--r-- 1 root named 113 Apr 29 03:36 rndc.key
[[email protected] etc]# cp -p named-caching-nameserver.conf naemed.conf
[[email protected] etc]# vi named.rfc1912.zones
// 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.
//
zone "." IN {
type hint;
file "named.ca";
};
zone "linuxidc.com" IN {
type master;
file "linuxidc.com.zone";
allow-update { none; };
};
zone "1.168.192.in-addr.arpa" IN {
type master;
file "linuxidc.com.local";
allow-update {none;};
};
[[email protected] etc]# vi named.conf
//
// named.caching-nameserver.conf
//
// Provided by Red Hat caching-nameserver package to configure the
// ISC BIND named(8) DNS server as a caching only nameserver
// (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
// DO NOT EDIT THIS FILE - use system-config-bind or an editor
// to create named.conf - edits to this file will be lost on
// caching-nameserver package upgrade.
//
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
query-source port 53;
query-source-v6 port 53;
allow-query { any; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
match-clients { any; };
match-destinations { any; };
recursion yes;
include "/etc/named.rfc1912.zones";
};
# 黄色为修改部分
[[email protected] etc]#
[[email protected] etc]# cd /var/named/chroot/var/named/
查看ll 如下:
drwxrwx--- 2 named named 4096 Apr 30 13:21 data
-rw-r----- 1 root named 198 Jan 17 2007 localdomain.zone
-rw-r----- 1 root named 195 Jan 17 2007 localhost.zone
-rw-r----- 1 root named 427 Jan 17 2007 named.broadcast
-rw-r----- 1 root named 2518 Jan 17 2007 named.ca
-rw-r----- 1 root named 424 Jan 17 2007 named.ip6.local
-rw-r----- 1 root named 426 Jan 17 2007 named.local
-rw-r----- 1 root named 427 Jan 17 2007 named.zero
drwxrwx--- 2 named named 4096 Jul 27 2004 slaves
[[email protected] named]# cp -p localdomain.zone linuxidc.com.zone(一定要加-p参数,否则后面出错。)
[[email protected] named]# cp -p named.local linuxidc.com.local
[[email protected] named]# vi linuxidc.com.local
$TTL 86400
@ IN SOA linuxidc.com. root.linuxidc.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS linuxidc.com.
108 IN PTR www.linuxidc.com.
108 IN PTR mail.linuxidc.com. (邮件反向可有可无。)
正向文件:
[[email protected] named]#vi linuxidc.com.zone
$TTL 86400
@ IN SOA linuxidc.com. root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS linuxidc.com.
IN MX 10 mail.linuxidc.com.
www IN A 192.168.1.108
mail IN A 192.168.1.108
在/etc/resolv.conf里面添加自己的域名ip
nameserver 192.168.1.108
三、启动DNS服务
[[email protected] named]# service named restart
Stopping named: [ OK ]
Starting named: [ OK ]
[[email protected] named]#
四、测试
nslookup 即可!(以上测试完全通过)
次环境是把MAIL ,WWW等服务器与DNS 服务器放在一起
-、先检查系统是安装了bind.rpm 与caching-nameserver.rpm包
[[email protected] ~]# rpm -qa bind* caching-*
bind-chroot-9.3.3-7.el5
bind-libs-9.3.3-7.el5
bind-9.3.3-7.el5
bind-libbind-devel-9.3.3-7.el5
bind-utils-9.3.3-7.el5
bind-devel-9.3.3-7.el5
caching-nameserver-9.3.3-7.el5
bind-sdb-9.3.3-7.el5
[[email protected] ~]#
若没有,就安装这些包
二、配置dns的正向和反向解析文件
[[email protected] ~]# cd /var/named/chroot/etc/
[[email protected] etc]# ll
total 24
-rw-r--r-- 1 root root 165 Apr 29 19:42 localtime
-rw-r----- 1 root named 1100 Jan 17 2007 named.caching-nameserver.conf
-rw-r----- 1 root named 614 Apr 30 13:04 named.rfc1912.zones
-rw-r--r-- 1 root named 113 Apr 29 03:36 rndc.key
[[email protected] etc]# cp -p named-caching-nameserver.conf naemed.conf
[[email protected] etc]# vi named.rfc1912.zones
// 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.
//
zone "." IN {
type hint;
file "named.ca";
};
zone "linuxidc.com" IN {
type master;
file "linuxidc.com.zone";
allow-update { none; };
};
zone "1.168.192.in-addr.arpa" IN {
type master;
file "linuxidc.com.local";
allow-update {none;};
};
[[email protected] etc]# vi named.conf
//
// named.caching-nameserver.conf
//
// Provided by Red Hat caching-nameserver package to configure the
// ISC BIND named(8) DNS server as a caching only nameserver
// (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
// DO NOT EDIT THIS FILE - use system-config-bind or an editor
// to create named.conf - edits to this file will be lost on
// caching-nameserver package upgrade.
//
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
query-source port 53;
query-source-v6 port 53;
allow-query { any; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
match-clients { any; };
match-destinations { any; };
recursion yes;
include "/etc/named.rfc1912.zones";
};
# 黄色为修改部分
[[email protected] etc]#
[[email protected] etc]# cd /var/named/chroot/var/named/
查看ll 如下:
drwxrwx--- 2 named named 4096 Apr 30 13:21 data
-rw-r----- 1 root named 198 Jan 17 2007 localdomain.zone
-rw-r----- 1 root named 195 Jan 17 2007 localhost.zone
-rw-r----- 1 root named 427 Jan 17 2007 named.broadcast
-rw-r----- 1 root named 2518 Jan 17 2007 named.ca
-rw-r----- 1 root named 424 Jan 17 2007 named.ip6.local
-rw-r----- 1 root named 426 Jan 17 2007 named.local
-rw-r----- 1 root named 427 Jan 17 2007 named.zero
drwxrwx--- 2 named named 4096 Jul 27 2004 slaves
[[email protected] named]# cp -p localdomain.zone linuxidc.com.zone(一定要加-p参数,否则后面出错。)
[[email protected] named]# cp -p named.local linuxidc.com.local
[[email protected] named]# vi linuxidc.com.local
$TTL 86400
@ IN SOA linuxidc.com. root.linuxidc.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS linuxidc.com.
108 IN PTR www.linuxidc.com.
108 IN PTR mail.linuxidc.com. (邮件反向可有可无。)
正向文件:
[[email protected] named]#vi linuxidc.com.zone
$TTL 86400
@ IN SOA linuxidc.com. root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS linuxidc.com.
IN MX 10 mail.linuxidc.com.
www IN A 192.168.1.108
mail IN A 192.168.1.108
在/etc/resolv.conf里面添加自己的域名ip
nameserver 192.168.1.108
三、启动DNS服务
[[email protected] named]# service named restart
Stopping named: [ OK ]
Starting named: [ OK ]
[[email protected] named]#
四、测试
nslookup 即可!(以上测试完全通过)
相关推荐
HeKing 2007-10-28
RayDon 2007-09-01
SoarFly00 2007-09-01
adeni 2011-05-16
andyzhaojianhui 2010-12-23
Jiajinjin 2009-05-07
grantlee 2020-05-28
lzzyok 2020-10-10
无情的你无情的雨 2020-06-16
chunianyo 2020-06-04
xjp 2020-05-26
Roka 2020-05-25
天空一样的蔚蓝 2020-05-02
nangongyanya 2020-04-19
shufen0 2020-04-14
humanbeng 2020-03-05
Alanxz 2020-03-04
liwf 2020-02-17
歆萌 2020-02-10