架构根据电信、网通用户自动解析不同IP的DNS服务器

Show All   1 2 3

注:已经提供了免费的DNS解析服务。并且VERYCD已经在使用了。地址:http://www.dnspod.com

/*
* 架构根据电信、网通用户自动解析不同IP的DNS服务器
* 本文介绍了如何让DNS服务器根据用户的IP地址解析出不同的镜像服务器IP

* 版本: 1.1.0
* 作者: 声仔(奶罩)
* 网站: http://wuhongsheng.com
* 版权: (C) 1999-2006 wuhongsheng.com
* 修订: 2006-01-19 23:13
* 原始出处: http://wuhongsheng.com/blog/?p=235
*/

本文档基于FreeBSD、BIND平台,Win用户请回避,没有FreeBSD基础的用户请回避。Linux或者其他Unix用户可以作为参考文档。

修订记录:
2006-01-19 修订了部分网通用户的IP地址,修正了NS部分,修正了一些错误,增加了常见问题。

配置步骤:
1. 前言
2. 软件列表
3. 安装BIND 9
4. 配置BIND 9
5. 测试BIND 9
6. 添加一个NS地址
7. 添加一个域名
8. 测试域名
9. 常见问题

一、 前言
本文假设你有一定的FreeBSD操作经验,懂得日常的FreeBSD操作,有良好的耐心,可以
把文档看完,可以处理突发的问题。
本文再假设你已经有了一个域名,并且已经指向所操作的服务器,服务器的/etc/rc.conf
已经正确的设置此域名。在本文里面,此域名为ns.naizhao.com,IP为219.132.1.1。
/etc/rc.conf如下所设置
hostname=”ns.naizhao.com” #机器的域名,请酌情修改
ifconfig_fxp0=”inet 219.132.1.1 netmask 255.255.255.0″ #此行可能有所不同,
请别照抄。fxp0为我机器上面的网卡。

二、 软件列表
本文所用到的软件可从以下地址获取。连接地址最后更新为2005/12/12

BIND 9.3.1
ftp://ftp.isc.org/isc/bind9/9.3.1/bind-9.3.1.tar.gz

三、 安装BIND 9
我们假设你已经把BIND 9使用fetch或者wget到/root/下,并且已经su为root。
# tar zxvf bind-9.3.1.tar.gz
# cd bind-9.3.1
# ./configure
# make
# make install
# make clean
到此,BIND 9已经安装上了。如果安装过程中出现什么问题,一般不会是你的人品有问题,
请分析错误信息,把缺少的包给安装上。

四、 配置BIND 9
先别急,看看你的BIND版本再说。
# named -v
如果你是FreeBSD 4,估计你看到的提示类似下面的
named 8.3.7-REL Sun Dec 12 04:15:36 CST 2004
如果你是FreeBSD 5,估计你不会看到上面的信息。然后我们再来输入
# /usr/local/sbin/named -v
这次,不管你是FreeBSD 4还是FreeBSD 5,都会看到下面的信息
BIND 9.3.1
所以在这里,我们统一使用/usr/local/sbin/named
废话少说,开始配置吧。
# cd /etc/namedb
# chmod +x make-localhost
# ./make-localhost
会在当前目录生成一个localhost.rev和localhost-v6.rev。后者是用于IPv6
生成rndc的key
# /usr/local/sbin/rndc-confgen >rndc.conf
打开rndc.conf,把
# Use with the following in named.conf, adjusting the allow list as needed:
……
# End of named.conf
之间的内容,去掉注释#,添加到named.conf中
编辑named.conf
# ee named.conf
找到
zone “.” {
type hint;
file “named.root”;
};

zone “0.0.127.IN-ADDR.ARPA” {
type master;
file “localhost.rev”;
};

// RFC 3152
zone “1.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” {
type master;
file “localhost-v6.rev”;
};

// RFC 1886 — deprecated
zone “1.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.INT” {
type master;
file “localhost-v6.rev”;
};
把上面的内容全部用/**/注释
/*
zone “.” {
type hint;
……
file “localhost-v6.rev”;
};
*/
在named.conf文件的最后,把刚才rndc.conf里面的内容添加进去
key “rndc-key” {
algorithm hmac-md5;
secret “ILzfx8ONk2444ix9jnDfKA==”;
};

controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { “rndc-key”; };
};
(上面的内容只供参考)
接下来的,就是文章里面的重头戏了。

Show All   1 2 3
Category: 其他技术
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
3 Responses
  1. 红薯 says:

    其实bind的配置远不需要这么复杂,里面的很多东西都是没必要的,例如对localhost的解析以及IP地址反解析等等

  2. Michael says:

    [Comment ID #24324 Will Be Quoted Here]

    bind的确有些臃肿,djbdns和tinydns都挺好使的。

  3. xwl says:

    功能不难实现,难的是如何动态,实时更新IP表。

  4. minecraft says:

    First of all I would like to say terrific blog! I had a quick question which I’d
    like to ask if you do not mind. I was curious to know how you center
    yourself and clear your head prior to writing.
    I have had trouble clearing my mind in getting my ideas out there.
    I truly do take pleasure in writing but it just seems like the first 10 to 15 minutes tend to be
    wasted just trying to figure out how to begin. Any recommendations or hints?
    Many thanks!

  5. minecraft says:

    It’s going to be end of mine day, but before finish I am reading this impressive
    piece of writing to increase my knowledge.

  6. minecraft says:

    Do you mind if I quote a couple of your posts
    as long as I provide credit and sources back to
    your blog? My blog is in the very same niche as yours and
    my visitors would truly benefit from a lot of the information you present here.
    Please let me know if this alright with you.
    Cheers!

  7. minecraft says:

    Does your website have a contact page? I’m having a tough time locating it but, I’d like
    to send you an e-mail. I’ve got some creative
    ideas for your blog you might be interested in hearing.
    Either way, great blog and I look forward to seeing it
    grow over time.

  8. Hello, i think that i saw you visited my blog thus i came to
    “return the favor”.I’m trying to find things to enhance
    my site!I suppose its ok to use some of your ideas!!

  9. I was excited to uncover this great site. I need to
    to thank you for your time for this particularly wonderful read!!

    I definitely enjoyed every little bit of it and i also have you book-marked to see new stuff
    on your website.

  10. I was curious if you ever considered changing
    the page layout of your blog? Its very well written; I love what youve
    got to say. But maybe you could a little more in the way
    of content so people could connect with it better. Youve got
    an awful lot of text for only having 1 or 2 images. Maybe you could space it out better?

  11. I don’t even know the way I stopped up here, however I
    assumed this put up was once great. I do not understand who
    you’re but definitely you’re going to a well-known blogger
    when you are not already. Cheers!

  12. I have been surfing online more than three hours today, yet I never
    found any interesting article like yours. It
    is pretty worth enough for me. Personally, if all website owners and bloggers made good content as you
    did, the internet will be much more useful than ever before.

  13. Great post. I used to be checking continuously this blog
    and I’m impressed! Very helpful info particularly the closing
    section 🙂 I care for such information a lot.
    I was looking for this certain info for a long time. Thanks and best of luck.

  14. I every time emailed this webpage post page to all my associates, for the reason that if like to read
    it afterward my friends will too.

  15. Admiring the commitment you put into your blog and in depth information you provide.
    It’s awesome to come across a blog every once in a while that isn’t the
    same outdated rehashed information. Wonderful read!
    I’ve saved your site and I’m including your RSS feeds
    to my Google account.

  16. Sling TV says:

    Howdy! I’m at work browsing your blog from my new iphone 4!
    Just wanted to say I love reading through your blog and
    look forward to all your posts! Carry on the outstanding work!

  17. WOW just what I was looking for. Came here by searching for What Equipment is Needed for Sling TV

  18. Sling TV says:

    Hello! I know this is kinda off topic but I’d figured I’d ask.
    Would you be interested in exchanging links or maybe guest authoring a blog post
    or vice-versa? My blog discusses a lot of the same subjects as yours and I think we could greatly benefit from each other.
    If you happen to be interested feel free to send me an e-mail.
    I look forward to hearing from you! Great blog by the way!

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image