yum 安装bind

  1. yum install bind 
  2. Loaded plugins: fastestmirror 
  3. Loading mirror speeds from cached hostfile 
  4.  * base: mirrors.linuxfb.org 
  5.  * extras: mirrors.linuxfb.org 
  6.  * updates: mirrors.linuxfb.org 
  7. Setting up Install Process 
  8. Resolving Dependencies 
  9. --> Running transaction check 
  10. ---> Package bind.x86_64 30:9.3.6-16.P1.el5_7.1 set to be updated 
  11. --> Processing Dependency: bind-libs = 30:9.3.6-16.P1.el5_7.1 for package: bind 
  12. --> Processing Dependency: libisccfg.so.1()(64bit) for package: bind 
  13. --> Processing Dependency: libisccc.so.0()(64bit) for package: bind 
  14. --> Processing Dependency: libbind9.so.0()(64bit) for package: bind 
  15. --> Processing Dependency: libdns.so.26()(64bit) for package: bind 
  16. --> Processing Dependency: liblwres.so.9()(64bit) for package: bind 
  17. --> Processing Dependency: libisc.so.15()(64bit) for package: bind 
  18. --> Running transaction check 
  19. ---> Package bind-libs.x86_64 30:9.3.6-16.P1.el5_7.1 set to be updated 
  20. --> Finished Dependency Resolution 
  21.  
  22. Dependencies Resolved 
  23.  
  24. ============================================================================= 
  25.  Package        Arch        Version                       Repository    Size 
  26. ============================================================================= 
  27. Installing: 
  28.  bind           x86_64      30:9.3.6-16.P1.el5_7.1        updates      988 k 
  29. Installing for dependencies: 
  30.  bind-libs      x86_64      30:9.3.6-16.P1.el5_7.1        updates      895 k 
  31.  
  32. Transaction Summary 
  33. ============================================================================= 
  34. Install       2 Package(s) 
  35. Upgrade       0 Package(s) 
  36.  
  37. Total download size: 1.8 M 
  38. Is this ok [y/N]: y 
  39. Downloading Packages: 
  40. (1/2): bind-libs-9.3.6-16.P1.el5_7.1.x86_64.rpm       | 895 kB     00:00     
  41. (2/2): bind-9.3.6-16.P1.el5_7.1.x86_64.rpm            | 988 kB     00:00     
  42. ----------------------------------------------------------------------------- 
  43. Total                                        1.6 MB/s | 1.8 MB     00:01     
  44. Running rpm_check_debug 
  45. Running Transaction Test 
  46. Finished Transaction Test 
  47. Transaction Test Succeeded 
  48. Running Transaction 
  49.   Installing     : bind-libs                                             1/2 
  50.   Installing     : bind                                                  2/2 
  51.  
  52. Installed: 
  53.   bind.x86_64 30:9.3.6-16.P1.el5_7.1                                         
  54.  
  55. Dependency Installed: 
  56.   bind-libs.x86_64 30:9.3.6-16.P1.el5_7.1                                    
  57.  
  58. Complete! 
  1. [root@centos129 opt]# /etc/init.d/named start 
  2. Locating //etc/named.conf failed: 


                                                           [失败]
配置文件必须按照模板来修改,以前的版本在/etc/下有个named.conf 5.5下没有,换成named.caching-nameserver.conf和named.rfc1912.zones,错误没有找到这个文件
是因为centos没有找到named.conf这个文件,解决问题,需要安装caching-nameserver这个包就可以了
 

/DNS缓存服务器文件

 

  1. [root@centos129 opt]# yum install caching-nameserver / 
  2.  
  3. Loaded plugins: fastestmirror 
  4. Loading mirror speeds from cached hostfile 
  5.  * base: mirrors.linuxfb.org 
  6.  * extras: mirrors.linuxfb.org 
  7.  * updates: mirrors.linuxfb.org 
  8. Setting up Install Process 
  9. Resolving Dependencies 
  10. --> Running transaction check 
  11. ---> Package caching-nameserver.x86_64 30:9.3.6-16.P1.el5_7.1 set to be updated 
  12. --> Finished Dependency Resolution 
  13.  
  14. Dependencies Resolved 
  15.  
  16. ============================================================================= 
  17.  Package               Arch      Version                    Repository  Size 
  18. ============================================================================= 
  19. Installing: 
  20.  caching-nameserver    x86_64    30:9.3.6-16.P1.el5_7.1     updates     62 k 
  21.  
  22. Transaction Summary 
  23. ============================================================================= 
  24. Install       1 Package(s) 
  25. Upgrade       0 Package(s) 
  26.  
  27. Total download size: 62 k 
  28. Is this ok [y/N]: y 
  29. Downloading Packages: 
  30. caching-nameserver-9.3.6-16.P1.el5_7.1.x86_64.rpm     |  62 kB     00:00     
  31. Running rpm_check_debug 
  32. Running Transaction Test 
  33. Finished Transaction Test 
  34. Transaction Test Succeeded 
  35. Running Transaction 
  36.   Installing     : caching-nameserver                                    1/1 
  37.  
  38. Installed: 
  39.   caching-nameserver.x86_64 30:9.3.6-16.P1.el5_7.1                           
  40.  
  41. Complete! 

[root@centos129 opt]# service named start
启动 named:                                               [确定]
启动DNS
可以cp -p named.caching-nameserver.conf named.conf 这个文件,也可以直接用这个文件!



修改name.conf和named ,添加forwarders语句使dns成为一个简单的转发查询服务器
 

  1. // 
  2. // named.caching-nameserver.conf 
  3. // 
  4. // Provided by Red Hat caching-nameserver package to configure the 
  5. // ISC BIND named(8) DNS server as a caching only nameserver 
  6. // (as a localhost DNS resolver only). 
  7. // 
  8. // See /usr/share/doc/bind*/sample/ for example named configuration files. 
  9. // 
  10. // DO NOT EDIT THIS FILE - use system-config-bind or an editor 
  11. // to create named.conf - edits to this file will be lost on 
  12. // caching-nameserver package upgrade. 
  13. // 
  14. options { 
  15.         listen-on port 53 { 172.16.148.129; }; 
  16.         listen-on-v6 port 53 { ::1; }; 
  17.         directory       "/var/named"; 
  18.         dump-file       "/var/named/data/cache_dump.db"; 
  19.         statistics-file "/var/named/data/named_stats.txt"; 
  20.         memstatistics-file "/var/named/data/named_mem_stats.txt"; 
  21.         forwarders {202.96.209.5;}; 
  22.         // Those options should be used carefully because they disable port 
  23.         // randomization 
  24.          query-source    port 53;       
  25.         // query-source-v6 port 53; 
  26.  
  27.         allow-query     { any; }; 
  28.         allow-query-cache { any; }; 
  29. }; 
  30. logging { 
  31.         channel default_debug { 
  32.                 file "data/named.run"; 
  33.                 severity dynamic; 
  34.         }; 
  35. }; 
  36. view localhost_resolver { 
  37.         match-clients      { any; }; 
  38.         match-destinations { any; }; 
  39.         recursion yes; 
  40. "named.conf" 41L, 1237C                                    15,2-9       顶端 


客户端测试成功
 

  1. [zhoutao@WorkSpace ~]$ nslookup baidu.com 
  2. Server:         172.16.148.129 
  3. Address:        172.16.148.129#53 
  4.  
  5. Non-authoritative answer: 
  6. Name:   baidu.com 
  7. Address: 220.181.111.86 
  8. Name:   baidu.com 
  9. Address: 123.125.114.144 
  10. Name:   baidu.com 
  11. Address: 220.181.111.85 



 

  1. 一个简单的域名服务器[root@centos129 etc]# tail -20 named.rfc1912.zones 
  2.  
  3. zone "test.com" IN { 
  4.         type master; 
  5.         file "test.zone"; 
  6.         allow-update { none; }; 
  7. }; 
  8. zone "148.16.172.in-addr.arpa" IN { 
  9.         type master; 
  10.         file "test.local"; 
  11.         allow-update { none; }; 
  12. }; 
  13. 在//etc/named.rfc1912.zones添加test域名 



创建test.local.test.zone区域文件
 

  1. [root@centos129 named]# cat test.local 
  2. $TTL    86400 
  3. @       IN      SOA     test.com. root.test.com.  ( 
  4.                                       1997022700 ; Serial 
  5.                                       28800      ; Refresh 
  6.                                       14400      ; Retry 
  7.                                       3600000    ; Expire 
  8.                                       86400 )    ; Minimum 
  9.           IN      NS      test.com. 
  10. 129       IN      PTR     www.test.com. 
  11.  
  12. [root@centos129 named]# cat test.zone 
  13. $TTL    86400 
  14. @               IN SOA  test.com.       root@test.com. ( 
  15.                                         42              ; serial (d. adams) 
  16.                                         3H              ; refresh 
  17.                                         15M             ; retry 
  18.                                         1W              ; expiry 
  19.                                         1D )            ; minimum 
  20.  
  21.         IN NS           test.com. 
  22. test    IN A            172.16.148.129 
  23. www     IN A            172.16.148.129 
  24. ftp     IN CNAME        www 
  25. mail    IN A            172.16.148.129 
  26. mail    IN MX 10        mail.test.com 



客户端修改resolv.conf文件后测试通过
 

  1. [zhoutao@WorkSpace ~]$ nslookup 
  2. > ftp.test.com 
  3. Server:         172.16.148.129 
  4. Address:        172.16.148.129#53 
  5.  
  6. ftp.test.com    canonical name = www.test.com. 
  7. Name:   www.test.com 
  8. Address: 172.16.148.129 
  9. > 172.16.148.129 
  10. Server:         172.16.148.129 
  11. Address:        172.16.148.129#53 
  12.  
  13. 129.148.16.172.in-addr.arpa     name = www.test.com. 
  14. > 
  15. > set type MX 
  16. *** Invalid option: type 
  17. > set type=MX 
  18. > mail.test.com 
  19. Server:         172.16.148.129 
  20. Address:        172.16.148.129#53 
  21.  
  22. mail.test.com   mail exchanger = 10 mail.test.com.test.com. 
  23. >