配置域名服务器(DOMAIN NAME SERVER)是直接连入Internet不可缺少的步骤。
主要包括两个方面:修改或建立/etc目录下nsswitch.conf、resolv.conf、
named.boot以及相应目录下named.local等文件。
1.建立文件/etc/resolv.conf
建立RESOLV.CONF的目的是通过解析程序(RESOL.VER PROGRAM)来和域名建立联系
的同时寻找名字服务器的IP地址。
格式为:
[DOMAIN 域名];注解
[NAMESERVER名字服务器IP地址];注解
内容为:
domain sti.ac.cn;(域名)
nameserver 168.169.18.36;(名字服务器)
2.修改/etc/nsswitch.conf文件
找到下行:HOST FILES 改为:HOSTS DNS FILES
关键字DNS的目的是通过解析程序去查找主机信息。
3.建立文件/etc/named.boot
这是一个根文件(BOOT FILES),包含了有关数据文件目录及和域
名服务器相关的数据文件信息。
格式为:
DIRECTORY数据文件目录
CACHE.文件名(这个文件包含了名字服务器和其他域名转发一个
请求到根域名服务器的信息。)
PRIMARY 域名 文件名(有关该域的信息)。
SECONDARY 域名 该域的名字服务器IP地址文件名(可选)
本例的内容为:
;
; boot file for name server
;
directory /var/name
; type domain source host/file backup file
cache . named.ca
primary sti.cn.net named.stinet
primary 0.0.127.IN-ADDR.ARPA named.local
primary 160.168.IN-ADDR.ARPA named.rev
secondary istic.ac.cn 168.160.17.1 ist
4.建立文件/var/name/named.stinet
格式为
IN SOA主机名EMAIL地址 版本号 DEFAULT值;对域名服务器授权
IN NS 主机名;增加一个主机名
反序IP地址 IN PTR主机名;增加一个有关目标存储信息的指针,注意:IP地址反序
,如:21.19.112.102
$ORIGIN 域名;建立数据文件的数据源
主机名IN A IP地址;主机名和IP地址映射
综合以上各项,本处内容为:
$ORIGIN cn.net.
sti IN SOA ns.sti.cn.net. hostmaster.sti.cn.net (
98071803 ; Serial
28800 ; Refresh 8 hours
7200 ; Retry 2 hours
604800 ; Expire 7 days
86400  ; Minimum TTL 1 day
IN NS ns.sti.cn.net.
ns.sti.cn.net. IN A 168.160.1.25
$ORIGIN sti.cn.net.
ns IN A 168.160.1.25
5.建立文件/var/name/named.local,内容为:
;
; BIND data file for local loopback interface.
;
@ IN SOA netserver.istic.ac.cn. postmaster.netserver.istic.ac.cn.
(
3 ; Serial
300 ; Refresh
60 ; Retry
1209600 ; Expire
43200  ; Minimum
IN NS netserver.istic.ac.cn.
1 IN PTR localhost.istic.ac.cn.
1.17.160.168.IN-ADDR.ARPA IN PTR netserver.istic.ac.cn.
经过上述步骤配置以后,DNS配置到此结束,输入in.named命令启动域名服务,同时可以
用NSLOOKUP命令测试域名配置情况。
--------------------------------------------------------------------------------
系统需要建立的文件:
/etc/resolv.conf
/etc/named.boot
/var/name/named.stinet
/var/name/named.ca
/var/name/named.local
/var/name/named.rev
如何加入一个新的主机名(例如ppp.sti.cn.net)
加入一行:
$ORIGIN cn.net.
sti IN SOA ns.sti.cn.net. hostmaster.sti.cn.net (
98071803 ; Serial
28800 ; Refresh 8 hours
7200 ; Retry 2 hours
604800 ; Expire 7 days
86400  ; Minimum TTL 1 day
IN NS ns.sti.cn.net.
ns.sti.cn.net. IN A 168.160.1.25
$ORIGIN sti.cn.net.
ns IN A 168.160.1.25
www IN A 168.160.1.98
ppp IN A 168.160.1.100
如何加入一个新的域名(例如iol.com.cn)
在/etc/named.boot中加入一行:
primary iol.com.cn named.iol.com.cn
建立文件/vae/name/named.iol.com.cn
$ORIGIN com.cn.
sdcmt IN SOA ns.sti.ac.cn. hostmaster.sti.ac.cn. (
97050402 ; Serial
28800 ; Refresh 8 hours
7200 ; Retry 2 hours
604800 ; Expire 7 days
86400  ; Minimum TTL 1 day
IN NS ns.sti.ac.cn.
ns.sti.ac.cn. IN A 168.160.1.25
$ORIGIN iol.com.cn.
connet IN A 168.160.158.1
www IN A 168.160.158.2
public IN A 168.160.158.5
进程重新启动,执行:
public% ps -e|grep name
115 ? 0:00 in.named
public% kill -1 115
测试域名是否工作
public% /usr/sbin/nslookup
Default Server: public.sti.net.cn
Address: 168.160.66.5
> http://www.iol.com.cn
Server: public.sti.net.cn
Address: 168.160.66.5
Name: http://www.iol.com.cn
Address: 168.160.1.25
> exit
public%
--------------------------------------------------------------------------------
1 /etc/resolv.conf
domain sti.net.cn
nameserver 168.160.66.5
nameserver 168.160.1.25
--------------------------------------------------------------------------------
2 /etc/named.boot
;
; boot file for name server
;
directory /var/name
; type domain source host/file backup file
cache . named.ca
primary sti.cn.net named.stinet
primary 0.0.127.IN-ADDR.ARPA named.local
primary 160.168.IN-ADDR.ARPA named.rev
secondary istic.ac.cn 168.160.17.1 istic.name
--------------------------------------------------------------------------------
3 /var/name/named.stinet
$ORIGIN cn.net.
sti IN SOA ns.sti.cn.net. hostmaster.sti.cn.net (
98071803 ; Serial
28800 ; Refresh 8 hours
7200 ; Retry 2 hours
604800 ; Expire 7 days
86400  ; Minimum TTL 1 day
IN NS ns.sti.cn.net.
ns.sti.cn.net. IN A 168.160.1.25
$ORIGIN sti.cn.net.
ns IN A 168.160.1.25
www IN A 168.160.1.98
--------------------------------------------------------------------------------
4 /var/name/named.ca
; This file holds the information on root name servers needed to
; initialize cache of Internet domain name servers
; (e.g. reference this file in the "cache . <file>"
; configuration file of BIND domain name servers).
;
; This file is made available by InterNIC registration services
; under anonymous FTP as
; file /domain/named.root
; on server FTP.RS.INTERNIC.NET
; -OR- under Gopher at RS.INTERNIC.NET
; under menu InterNIC Registration Services (NSI)
; submenu InterNIC Registration Archives
; file named.root
;
; last update: Aug 22, 1997
; related version of root zone: 1997082200
;
;
; formerly NS.INTERNIC.NET
;
. 3600000 IN NS A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
;
; formerly NS1.ISI.EDU
;
. 3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 128.9.0.107
;
; formerly C.PSI.NET
;
. 3600000 NS C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12
;
; formerly TERP.UMD.EDU
;
. 3600000 NS D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET. 3600000 A 128.8.10.90
;
; formerly NS.NASA.GOV
;
. 3600000 NS E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10
;
; formerly NS.ISC.ORG
;
. 3600000 NS F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241
;
; formerly NS.NIC.DDN.MIL
;
. 3600000 NS G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4
;
; formerly AOS.ARL.ARMY.MIL
;
. 3600000 NS H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53
;
; formerly NIC.NORDU.NET
;
. 3600000 NS I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
;
; temporarily housed at NSI (InterNIC)
;
. 3600000 NS J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET. 3600000 A 198.41.0.10
;
; housed in LINX, operated by RIPE NCC
;
. 3600000 NS K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
;
; temporarily housed at ISI (IANA)
;
. 3600000 NS L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET. 3600000 A 198.32.64.12
;
; housed in Japan, operated by WIDE
;
. 3600000 NS M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33
; End of File
--------------------------------------------------------------------------------
5 /etc/name/named.local
;
; BIND data file for local loopback interface.
;
@ IN SOA netserver.istic.ac.cn. postmaster.netserver.istic.ac.cn.
(
3 ; Serial
300 ; Refresh
60 ; Retry
1209600 ; Expire
43200  ; Minimum
IN NS netserver.istic.ac.cn.
1 IN PTR localhost.istic.ac.cn.
1.17.160.168.IN-ADDR.ARPA IN PTR netserver.istic.ac.cn.
--------------------------------------------------------------------------------
6 /etc/name/named.rev
;
; Data file for reverse address to hostname.
;
@ IN SOA netserver.istic.ac.cn. root.netserver.istic.ac.cn. (
24 ; Serial
300 ; Refresh - 5 minutes
60 ; Retry - 1 minute
1209600 ; Expire - 2 weeks
43200  ; Minimum - 12 hours
IN NS netserver.istic.ac.cn.
;
; %HOSTS_START% - entries added by /etc/namedb/bin/make_hosts
1.17.160.168.in-addr.arpa. IN PTR http://www.istic.ac.cn.
1.17.160.168.in-addr.arpa. IN PTR tj01.istic.ac.cn.
1.17.160.168.in-addr.arpa. IN PTR netserver.istic.ac.cn.
11.24.160.168.in-addr.arpa. IN PTR db.istic.ac.cn.
zy520fxq 回复于:2003-07-27 21:25:55 |
明天我再试一下,我的DNS可以上网,就是nslookup 不行 |
东方蜘蛛 回复于:2003-07-29 20:09:04 |
能不能将solaris9的DNS配置过程讲讲啊!! |
laoxia 回复于:2003-07-27 23:49:51 |
> 配置域名服务器(DOMAIN NAME SERVER)是直接连入Internet不可缺少的步骤。
非也,你只要指定缺省网关,保证网络畅通,再吧这机器设成你ISP的DNS 客户,就 可以上网。 我的LAB配置 # more /etc/defaultrouter 192.168.0.1 # more /etc/resolv.conf nameserver 24.153.22.67 nameserver 24.153.22.195 |
allonsun 回复于:2003-07-28 09:06:09 |
[quote:1a14324479="laoxia"]> 配置域名服务器(DOMAIN NAME SERVER)是直接连入Internet不可缺少的步骤。
非也,你只要指定缺省网关,保证网络畅通,再吧这机器设成你ISP的DNS 客户,就 可以上网。 我的LAB配置 # more /etc/default..........[/quote:1a14324479] 没看太懂能具体解释一下吗? |
laoxia 回复于:2003-07-28 09:08:22 |
[quote:58c52f0e0b="allonsun"] 没看太懂能具体解释一下吗?[/quote:58c52f0e0b] 我是说你要上INTERNET不必要配成DNS 服务器,配成DNS客户即可 |
sunSolaris 回复于:2003-07-29 18:01:08 |
[quote:9aaf8410eb="swwin"]ER名字服务器IP地址];注解
内容为: domain sti.ac.cn;(域名) nameserver 168.169.18.36;(名字服务器) 2.修改/etc/nsswitch.conf文件 找到下行:HOST FILES 改为:HOSTS DNS FILES 关键字DNS的目的是通过..........[/quote:9aaf8410eb] |
小豆冰棍 回复于:2003-07-29 19:16:10 |
版本有点老吧?
好象现在都是named.conf文件配置的了。 是不是啊?! |
你来也 回复于:2003-07-29 20:40:47 |
laoxia 正解
就是还要改下 nsswitch.conf DNS 优先 |
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/