配置Solaris10的DNS,分为2部分,一个为服务器端,另外一部分为客户端(被指向端)。

服务器端:

1、配置/etc/named.conf

2、配置/named.conf中设置的解析配置文件

3、/usr/sbin/named启动DNS服务

客户端:

1、配置/etc/resolv.conf

2、配置/etc/nsswitch.conf 设置解析顺序

其他:

1、nslookup命令测试DNS运行是否正常

2、tail -f /var/adm/messages查看日志文件,排查问题

下面为配置代码的示例:

 

 
  
  1. DNS服务设置  
  2. //服务器端  
  3. -bash-3.00# more /etc/named.conf   
  4.  
  5. options{  
  6.         Directory "/var/named";  
  7. };  
  8. zone "cuug.com"{   //此为顶级域名
  9.         type master;  
  10.         file "named.cuug.com";   //此项的配置文件
  11. };  
  12. zone "15.168.192.in-addr.arpa"{   //指向地址网段,IP反写!
  13.         type master;  
  14.         file "named.rev";  
  15. };  
  16. zone "0.0.127.in-addr.arpa"{   //本地地址
  17.         type master;  
  18.         file "named.local";  
  19. };  
  20. -bash-3.00# more /var/named/*  
  21. ::::::::::::::  
  22. /var/named/named.cuug.com  
  23. ::::::::::::::  
  24. @ IN SOA guan.cuug.com. root.cuug.com.( //主机名,邮箱名,最后是有点的,根域!
  25.         20120723        ;serial  
  26.         3H              ;refresh  
  27.         15M             ;retry  
  28.         1W              ;expire  
  29.         1D              ;minimun  
  30. )  
  31. @       IN      NS      guan.cuug.com.  
  32. www     IN      A       192.168.15.10   //指向www服务器地址
  33. FTP     IN      A       192.168.15.11   //f指向tp服务器地址
  34.  
  35.  
  36.  
  37. ::::::::::::::  
  38. /var/named/named.local  
  39. ::::::::::::::  
  40. @ IN SOA   guan.cuug.com. root.cuug.com.(  
  41.         2012723         ;serial  
  42.         3H              ;refresh  
  43.         15M             ;retry  
  44.         1W              ;expire  
  45.         1D              ;minimum  
  46. )  
  47. @       IN      NS      guan.cuug.com.  
  48. 1       IN      PTR     localhost   //指向本地地址
  49. ::::::::::::::  
  50. /var/named/named.rev  
  51. ::::::::::::::  
  52. @ IN SOA guan.cuug.com. root.cuug.com.(  
  53.         2012723         ;serial  
  54.         3H              ;refresh  
  55.         15M             ;retry  
  56.         1W              ;expire  
  57.         1D              ;minimum  
  58. )  
  59. @       IN      NS      guan.cuug.com.  
  60. 11      IN      PTR     FTP.cuug.com.   //反向解析是为了做虚拟主机用
  61. 10      IN      PTR     WWW.cuug.com.  
  62.  
  63. //客户端  
  64. -bash-3.00# more /etc/resolv.conf  
  65. nameserver 192.168.15.10   //填写DNS服务器地址
  66. -bash-3.00# more /etc/nsswitch.conf   
  67. #  
  68. # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.  
  69. # Use is subject to license terms.  
  70. #  
  71. # ident "@(#)nsswitch.files     1.14    06/05/03 SMI"  
  72.  
  73. #  
  74. # /etc/nsswitch.files:  
  75. #  
  76. # An example file that could be copied over to /etc/nsswitch.conf; it  
  77. # does not use any naming service.  
  78. #  
  79. # "hosts:" and "services:" in this file are used only if the  
  80. # /etc/netconfig file has a "-" for nametoaddr_libs of "inet" transports.  
  81.  
  82. passwd:     files  
  83. group:      files  
  84. hosts:      files       dns   //在此添加dns 解析顺序为先hosts,后dns
  85. ipnodes:    files  
  86. networks:   files  
  87. protocols:  files  
  88. rpc:        files  
  89. ethers:     files  
  90. netmasks:   files  
  91. bootparams: files  
  92. publickey:  files  
  93. # At present there isn't a 'files' backend for netgroup;  the system will   
  94. #   figure it out pretty quickly, and won't use netgroups at all.  
  95. netgroup:   files  
  96. automount:  files  
  97. aliases:    files  
  98. services:   files  
  99. printers:       user files  
  100.  
  101. auth_attr:  files  
  102. prof_attr:  files  
  103. project:    files  
  104.  
  105. tnrhtp:     files  
  106. tnrhdb:     files 

上文中,有些文件是系统中不存在的,需要自己手动创建!