RedHat Linux AS 5.3 下DNS的配置与RedHat Linux AS 4.5的有很多地方不太一样,这里我把在RedHat Linux AS 5.3 下DNS配置步骤做了一个笔记,操作如下:
创新互联公司2013年至今,是专业互联网技术服务公司,拥有项目成都网站建设、做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元平凉做网站,已为上家服务,为平凉各地企业和个人服务,联系电话:18982081108
一、检查BIND包,缺少bind、bind-chroot包
[root@mydb ~]# service named status
rndc: connect failed: 127.0.0.1#953: connection refused
named is stopped
说明DNS没有配好,接下来就开始配置DNS。
三、配置DNS
1、 安装caching-nameserver
[root@mydb~]# yum install caching-nameserver
Loaded plugins: rhnplugin, security This system is not registered with RHN. RHN support will be disabled. Setting up Install Process Parsing package install arguments Resolving Dependencies --> Running transaction check ---> Package caching-nameserver.x86_64 30:9.3.4-10.P1.el5 set to be updated --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================== Package Arch Version Repository Size ========================================================================================================================== Installing: caching-nameserver x86_64 30:9.3.4-10.P1.el5 base 58 k Transaction Summary ========================================================================================================================== Install 1 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 58 k Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : caching-nameserver [1/1] Installed: caching-nameserver.x86_64 30:9.3.4-10.P1.el5 Complete!
2、 安装完成会在/etc/下生成named.caching-nameserver.conf,查看其内容如下:
[root@mydb~]# cat /etc/named.caching-nameserver.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 { 127.0.0.1; }; 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"; // Those options should be used carefully because they disable port // randomization // query-source port 53; // query-source-v6 port 53; allow-query { localhost; }; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; view localhost_resolver { match-clients { localhost; }; match-destinations { localhost; }; recursion yes; include "/etc/named.rfc1912.zones"; };
3、拷贝/etc/named.caching-nameserver.conf到/var/named/chroot/etc/named.conf
[root@mydb ~]# cp /etc/named.caching-nameserver.conf /var/named/chroot/etc/named.conf
4、 编辑/var/named/chroot/etc/named.conf
[root@mydb ~]# vi/var/named/chroot/etc/named.conf
options { listen-on port 53 { 0.0.0.0/0; }; 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"; // Those options should be used carefully because they disable port // randomization // query-source port 53; // query-source-v6 port 53; allow-query { any; }; //allow-query-cache { any; }; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; #view localhost_resolver { # match-clients { localhost; }; # match-destinations { localhost; }; # recursion yes; # include "/etc/named.rfc1912.zones"; #}; # # ----添加以下这一段 zone "example.com."{ type master; file "example.file"; };
5、 修改named.conf权限
[root@mydb~]# cd /var/named/chroot/etc/
[root@mydbetc]# ll
total 20
-rw-r--r--1 root root 405 Sep 26 22:10 localtime
-rw-r-----1 root named 1195 Jan 6 2009 named.caching-nameserver.conf
-rw-r-----1 root root 1371 Nov 27 10:19 named.conf
-rw-r-----1 root named 955 Jan 6 2009named.rfc1912.zones
-rw-r-----1 root named 113 Nov 27 09:53 rndc.key
[root@mydbetc]# chown .named named.conf
[root@mydbetc]# ll
total 20
-rw-r--r--1 root root 405 Sep 26 22:10 localtime
-rw-r-----1 root named 1195 Jan 6 2009 named.caching-nameserver.conf
-rw-r-----1 root named 1371 Nov 27 10:19 named.conf
-rw-r-----1 root named 955 Jan 6 2009named.rfc1912.zones
-rw-r----- 1 root named 113 Nov 27 09:53 rndc.key
6、 配域名
root@mydbnamed]# pwd
/var/named/chroot/var/named
[root@mydbnamed]# ls -l
total 36
drwxrwx---2 named named 4096 Aug 26 2004 data
-rw-r-----1 root named 198 Jan 6 2009 localdomain.zone
-rw-r-----1 root named 195 Jan 6 2009 localhost.zone
-rw-r-----1 root named 427 Jan 6 2009 named.broadcast
-rw-r-----1 root named 1892 Jan 6 2009named.ca
-rw-r-----1 root named 424 Jan 6 2009 named.ip6.local
-rw-r-----1 root named 426 Jan 6 2009 named.local
-rw-r-----1 root named 427 Jan 6 2009 named.zero
drwxrwx--- 2 named named 4096 Jul 27 2004 slaves
[root@mydb named]# cplocaldomain.zone example.file
7、 编辑example.file
[root@mydb named]# vi /var/named/chroot/var/named/example.file
$TTL 86400 @ IN SOA guoyjoe.example.com. root ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS guoyjoe.example.com guoyjoe IN A 192.168.153.129 mydb IN A 192.168.153.129
四、启动DNS服务
[root@mydbnamed]# service named restart
Stoppingnamed: [ OK ]
Starting named: [ OK ]
五、客户端的DNS指定
[root@mydb ~]# more /etc/resolv.conf
; generated by /sbin/dhclient-script
search localdomain
nameserver 192.168.153.129