LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1963|回复: 3

Linux网络培训系列[本站原创]

[复制链接]
发表于 2002-4-15 10:55:52 | 显示全部楼层 |阅读模式
[这个贴子最后由pandonny在 2002/04/15 12:40pm 编辑]

从今天开始,本站会陆续发布一些Linux基于网络的培训教程,以帮助大家快速掌握linux网络架站的应用
 楼主| 发表于 2002-4-15 12:12:55 | 显示全部楼层

*#!&*Linux网络培训系列[本站原创]

[这个贴子最后由pandonny在 2002/04/15 12:14pm 编辑]

今天先来讨论一下如何架设DNS:
我们选择的平台是Redhat7.2,bind软件的版本号9.1.3
我们知道,在Linux中,域名服务(DNS)是由柏克莱网间名域(Berkeley Internet Name Domain——BIND)软件实现的。BIND是一个客户/服务系统,它的客户方面称为转换程序(resolver),它产生域名信息的查询,将这类信息发送给服务器,DNS软件回答转换程序的查询。BIND的服务方面是一个称为named(读作“name”“d”)的守护进程。
如果我们只是做单纯的把DNS架起来的话,这个过程其实很简单
首先我们先打开/etc/named.conf,内容如下:
// generated by named-bootconf.pl<p>options {
&nbsp; &nbsp; &nbsp; &nbsp;directory &quot;/var/named&quot;&#59;
&nbsp; &nbsp; &nbsp; &nbsp;/*
&nbsp; &nbsp; &nbsp; &nbsp; * If there is a firewall between you and nameservers you want
&nbsp; &nbsp; &nbsp; &nbsp; * to talk to, you might need to uncomment the query-source
&nbsp; &nbsp; &nbsp; &nbsp; * directive below. &nbsprevious versions of BIND always asked
&nbsp; &nbsp; &nbsp; &nbsp; * questions using port 53, but BIND 8.1 uses an unprivileged
&nbsp; &nbsp; &nbsp; &nbsp; * port by default.
&nbsp; &nbsp; &nbsp; &nbsp; */
&nbsp; &nbsp; &nbsp; &nbsp;// query-source address * port 53&#59;
}&#59;<p>//
// a caching only nameserver config
//
controls {
&nbsp; &nbsp; &nbsp; &nbsp;inet 127.0.0.1 allow { localhost&#59; } keys { rndckey&#59; }&#59;
}&#59;
zone &quot;.&quot; IN { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//定义根区
&nbsp; &nbsp; &nbsp; &nbsp;type hint&#59; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //区类型,也只有根区域会是这个类型
&nbsp; &nbsp; &nbsp; &nbsp;file &quot;named.ca&quot;&#59; &nbsp; &nbsp; //指定解析文件路径<p>
zone &quot;localhost&quot; IN { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//定义本地正向解析
&nbsp; &nbsp; &nbsp; &nbsp;type master&#59; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //类型为主DNS服务器
&nbsp; &nbsp; &nbsp; &nbsp;file &quot;localhost.zone&quot;&#59; &nbsp; //指定解析文件路径
&nbsp; &nbsp; &nbsp; &nbsp;allow-update { none&#59; }&#59; &nbsp;//设置是否允许同步更新
}&#59;<p>zone &quot;0.0.127.in-addr.arpa&quot; IN { &nbsp; &nbsp;//定义本地反向解析
&nbsp; &nbsp; &nbsp; &nbsp;type master&#59; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;file &quot;named.local&quot;&#59;
&nbsp; &nbsp; &nbsp; &nbsp;allow-update { none&#59; }&#59;
}&#59;<p>以上就是bind软件安装好以后系统就已经设置好的内容
现在举例说明如何是DNS解析自己的域名www.mydomain.com,IP是192.168.0.4,初学这只要
把例字中的www.mydomain.com和IP换成你自己的就可以了。<p>********************************************************************************<p>首先编辑/etc/named.conf
在文件最后加上这两段:
zone &quot;www.mydomain.com&quot; IN { &nbsp; &nbsp; //定义www.mydomain.com正向解析文件
&nbsp; &nbsp; &nbsp; &nbsp;type master&#59;
&nbsp; &nbsp; &nbsp; &nbsp;file &quot;www.mydomain.com&quot;&#59;
}&#59;<p>zone &quot;0.168.192.in-addr.arpa&quot; IN { &nbsp; //定义www.mydomain.com的反向解析文件
&nbsp; &nbsp; &nbsp; &nbsp;type master&#59;
&nbsp; &nbsp; &nbsp; &nbsp;file &quot;192.168.0.rev&quot;&#59;<p>********************************************************************************<p>在/var/named/目录下建立正向解析文件www.mydomain.com
内容如下:
$TTL &nbsp; &nbsp;86400 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;注释:定义TTL时间,刚好是1天
$ORIGIN www.mydomain.com. &nbsp; &nbsp; &nbsp; 注释:定义一下记录的来源,注意最后有一个点,千万
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;不要漏掉<p>@ 1D IN SOA @ root.www.mydomain.com. (
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;42 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#59; serial (d. adams)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3H &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#59; refresh
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;15M &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#59; retry
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1W &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#59; expiry
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1D ) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#59; minimum
注释:定义一个SOA记录,@就是相当于前面定义的$ORIGIN的内容,也就是
&nbsp; &nbsp; &nbsp;www.mydomain.com,1D定义了这个记录项的TTL,意思是1 Day,<p>www.mydomain.com. &nbsp;1D IN NS &nbsp; &nbsp; &nbsp; &nbsp;@
注释:定义了www.mydomain.com的名字解析服务器的名称,@含义同上,这里
&nbsp; &nbsp; &nbsp;的意思就是www.mydomain.com名字是又本机解析的
&nbsp; &nbsp; &nbsp; &nbsp;
www.mydomain.com. &nbsp;1D IN A &nbsp; &nbsp; &nbsp; &nbsp; 192.168.0.4
注释:定义了www.mydomain.com的对应IP是192.168.0.4<p>********************************************************************************<p>正向解析完成后,我们再来建立反向解析文件/etc/var/192.168.0.rev
内容如下:
$TTL &nbsp; &nbsp;86400
@ &nbsp; &nbsp; &nbsp; IN &nbsp; &nbsp; &nbsp;SOA &nbsp; &nbsp; www.mydomain.com. root.www.mydomain.com. &nbsp;(
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1997022700 &#59; Serial
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;28800 &nbsp; &nbsp; &nbsp;&#59; Refresh
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;14400 &nbsp; &nbsp; &nbsp;&#59; Retry
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3600000 &nbsp; &nbsp;&#59; Expire
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;86400 ) &nbsp; &nbsp;&#59; Minimum
@ &nbsp; &nbsp; &nbsp; IN &nbsp; &nbsp; &nbsp;NS &nbsp; &nbsp; &nbsp;www.mydomain.com.<p>4 &nbsp; &nbsp; &nbsp; IN &nbsp; &nbsp; &nbspTR &nbsp; &nbsp; www.mydomain.com.
注释:不用多注释了吧,最后一行意思就是www.mydomain.com的IP定义的是4,也就是
&nbsp; &nbsp; &nbsp;192.168.0.4,你一定会觉得奇怪,为什么IP没有打全呢,而是只有一个末尾的
&nbsp; &nbsp; &nbsp;4呢如果你了解DNS的原理的话,你就是知道对于你在/etc/named.conf文件中定
&nbsp; &nbsp; &nbsp;义了反向解析区域0.168.192.in-addr.arpa后,其前面的内用会自动在处理过
&nbsp; &nbsp; &nbsp;程中加以补全的。<p>********************************************************************************<p>好了,最基本的DNS已经架起来了,到/etc/rc.d/init.d目录下运行./named start,
然后在console下运行nslookup -sil检查一下设置是否生效:
输入www.mydomain.com和192.168.0.4看一下结果就知道了,祝你配置成功。<p>下次我将会贴上如何配置ftp服务器的文章,敬请期待!! *^_^*<p>
发表于 2004-6-12 20:03:35 | 显示全部楼层
老帖子,我翻出来了

哥哥
请你检查核对下哦
里面的<p> 这个, 应该是帖子html里面的吧

请吧,一些 内容的各式排版,弄好点,不然会让我们看不懂的,搞错的
发表于 2004-6-13 15:32:11 | 显示全部楼层
学习进步!!!!我是通过图形化配置的,没在图形化下面搞了半天没搞好。郁闷。。结果通过图形来搞几分钟就好了说。。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表