1、DNS服务器的架设实验环境:AS4最小化安装实验目标:架设DNS服务器编辑: crazylinux 2007.03.22联系方式: 大家好!这次我们来学习Linux系统中的DNS服务器的配置。首先我们需要安装bind软件,它位于AS4的第四章光盘中,rootlocalhost # rpm -ivh /media/cdrom/RedHat/RPMS/bind-9.2.4-2.i386.rpmrootlocalhost # rpm -ivh /media/cdrom/RedHat/RPMS/caching-nameserver-7.3-3.noarch.rpmrootlocalhost # rpm
2、 -qa | grep bindbind-utils-9.2.4-2bind-9.2.4-2bind-libs-9.2.4-2ypbind-1.17.2-3rootlocalhost # rpm -qa | grep cachingcaching-nameserver-7.3-3我们架设DNS服务器需要这些软件,实例情况:主域名服务器的地址是192.168.1.2 ,从域名服务器的地址是192.168.1.3 winxpIP地址是192.168.1.174在主域名服务器中添加域名区域下面我们就来架设主域名服务器1,软件安装完后我们修改配置文件rootlocalhost # vi /etc/na
3、med.conf修改完后的named.conf如下:rootlocalhost # cat /etc/named.conf/ named.conf for Red Hat caching-nameserver /options directory /var/named; dump-file /var/named/data/cache_dump.db; statistics-file /var/named/data/named_stats.txt; /* * If there is a firewall between you and nameservers you want * to talk
4、 to, you might need to uncomment the query-source * directive below. Previous versions of BIND always asked * questions using port 53, but BIND 8.1 uses an unprivileged * port by default. */ / query-source address * port 53;/ / a caching only nameserver config/ controls inet 127.0.0.1 allow localhos
5、t; keys rndckey; ;zone . IN type hint; file named.ca;zone localdomain IN type master; file localdomain.zone; allow-update none; ;zone localhost IN type master; file localhost.zone; allow-update none; ;zone IN type master; file .zone;zone 1.168.192.in-addr.arpa IN type master; file 192.168.1.rev;zone
6、 0.0.127.in-addr.arpa IN type master; file named.local; allow-update none; ;zone 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa IN type master; file named.ip6.local; allow-update none; ;zone 255.in-addr.arpa IN type master; file named.broadcast; allow-update none; ;zone 0.in-
7、addr.arpa IN type master; file named.zero; allow-update none; ;include /etc/rndc.key;2建立正向和反向区域文件 rootlocalhost named# cd /var/named/rootlocalhost named# cp localhost.zone .zone 把localhost的摸版cp后修改嘿嘿修改完后的.zone的文件如下rootlocalhost named# cat .zone $TTL 86400 IN SOA . . ( 42 ; serial (d. adams) 3H ; refr
8、esh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS . IN NS .ns1 IN A 192.168.1.2ns2 IN A 192.168.1.3host1 IN A 192.168.1.174mail IN CNAME . IN MX 5 .rootlocalhost named# cp .zone 192.168.1.rev 把修改完后的.zone cp一份作为反向配置文件,修改后如下rootlocalhost named# cat 192.168.1.rev $TTL 86400 IN SOA . . ( 42 ; serial (d.
9、adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS . IN NS .2 IN PTR .3 IN PTR .174 IN PTR .3,对区域文件的测试对named.conf的测试rootlocalhost named# named-checkconf 如没语法错误就没任何信息对区域文件测试rootlocalhost named# named-checkzone /var/named/.zone zone loaded serial 42OKrootlocalhost named# named-checkzone
10、1.168.192.in-addr.arpa /var/named/192.168.1.rev zone 1.168.192.in-addr.arpa/IN: loaded serial 42OK4,rootlocalhost named# cat /etc/resolv.conf 把服务器的DNS地址指向自己nameserver 192.168.1.2search localdomain5,启动named 服务rootlocalhost named# service named restartStopping named: OK Starting named: OK 6,测试主域名服务roo
11、tlocalhost named# host has address 192.168.1.2rootlocalhost named# host has address 192.168.1.3rootlocalhost named# host has address 192.168.1.174rootlocalhost named# host -t mx mail is handled by 5 .rootlocalhost named# host 192.168.1.22.1.168.192.in-addr.arpa domain name pointer .rootlocalhost nam
12、ed# host 192.168.1.33.1.168.192.in-addr.arpa domain name pointer .rootlocalhost named# host 192.168.1.174174.1.168.192.in-addr.arpa domain name pointer .嘿嘿 今天很顺利,一次OK 下面我们就来架设缓存域名服务器缓存服务器的架设很easy,我们只需要安装caching-nameserver软件包就OK下面我们就来架设从域名服务器 (在192.168.1.3中做)首先从服务器设置从主服务器中获取域的正向和反向区域文件,同时他也提供域名解析1, 安
13、装软件包rootlocalhost RPMS# rpm -ivh bind-9.2.4-2.i386.rpm warning: bind-9.2.4-2.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60ePreparing. # 100% 1:bind # 100% rootlocalhost RPMS# rpm -ivh caching-nameserver-7.3-3.noarch.rpm warning: caching-nameserver-7.3-3.noarch.rpm: V3 DSA signature: NOKEY, key I
14、D db42a60ePreparing. # 100% 1:caching-nameserver warning: /etc/named.conf saved as /etc/named.conf.rpmorig# 100%2, 设置named.conf在从域名服务器的named.conf中添加域和其反向解析区域的设置 ,内容如下rootlocalhost RPMS# cat /etc/named.conf/ named.conf for Red Hat caching-nameserver /options directory /var/named; dump-file /var/named
15、/data/cache_dump.db; statistics-file /var/named/data/named_stats.txt; /* * If there is a firewall between you and nameservers you want * to talk to, you might need to uncomment the query-source * directive below. Previous versions of BIND always asked * questions using port 53, but BIND 8.1 uses an
16、unprivileged * port by default. */ / query-source address * port 53;/ / a caching only nameserver config/ controls inet 127.0.0.1 allow localhost; keys rndckey; ;zone . IN type hint; file named.ca;zone localdomain IN type master; file localdomain.zone; allow-update none; ;zone localhost IN type mast
17、er; file localhost.zone; allow-update none; ;zone IN type slave; file slaves/.zone; masters 192.168.1.2 ; ;zone 1.168.192.in-addr.arpa IN type slave; file slaves/192.168.1.rev; masters 192.168.1.2 ; ;zone 0.0.127.in-addr.arpa IN type master; file named.local; allow-update none; ;zone 0.0.0.0.0.0.0.0
18、.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa IN type master; file named.ip6.local; allow-update none; ;zone 255.in-addr.arpa IN type master; file named.broadcast; allow-update none; ;zone 0.in-addr.arpa IN type master; file named.zero; allow-update none; ;include /etc/rndc.key;3, 检测配置文件和启动named服务rootlocalhost RPMS# named-checkconfrootlocalhost RPMS# service named restartStopping named: Starting named: OK rootlocalhost RPMS# ls /var/named/slaves/192.168.1.rev .zone 如看到这2个文件则配置成功 嘿嘿
©2010-2025 宁波自信网络信息技术有限公司 版权所有
客服电话:4008-655-100 投诉/维权电话:4009-655-100