Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15357690
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类:

2010-03-11 12:35:07

浅析ubuntu 9.10下如何使用bind9配置自己的DNS服务器



如下是域名和ip配置最终期望对应情况
172.16.32.123
trac.gliethttp.com      172.16.32.123
ftp.gliethttp.com       172.16.32.123
ubuntu.gliethttp.com    172.16.32.24
glx.gliethttp.com       172.16.32.54
下面让我们来具体看看怎么实现.

luther@gliethttp:~$ sudo apt-get install bind9
luther@gliethttp:~$ sudo vim /etc/bind/named.conf.local
# 追家如下行
// 正向域
zone "gliethttp.com"{
    type master;
    file "/etc/bind/db.gliethttp.com";
};

// 反向域
zone "32.16.172.in-addr.arpa"{
    type master;
    file "/etc/bind/db.gliethttp.com";
};

luther@gliethttp:~$ sudo vim /etc/bind/db.gliethttp.com
; 追加如下内容
; db.gliethttp.com
;
$TTL    604800
@   IN    SOA    gliethttp.com. root.localhost. (
                  1        ; Serial
             604800        ; Refresh
              86400        ; Retry
            2419200        ; Expire
             604800 )    ; Negative Cache TTL
;有@表示默认值
        IN  NS  dns1    ; 表示使用下面dns1指定的ip作为域名服务器,NS标识一个区的权威服务器
        IN  NS  dns2    ; 表示使用下面dns2指定的ip作为域名服务器,NS标识一个区的权威服务器
@       IN  A   172.16.32.123 ; 用来对ping gliethttp.com返回地址
dns1    IN  A   172.16.13.37
dns2    IN  A   202.106.0.20
www     IN  A   172.16.32.123
ftp     IN  CNAME www
trac    IN  CNAME www
ubuntu  IN  A   172.16.32.24
glx     IN  A   172.16.32.54
; 通过ip获得的域名
123     IN  PTR
24      IN  PTR ubuntu.gliethttp.com.
54      IN  PTR glx.gliethttp.com.

luther@gliethttp:~$ sudo vim /etc/bind/named.conf.options
// 辅助域名服务器地址,在北京,该dns地址常为202.106.0.20
// 如果我们自己的dns服务器找不到域名地址,那么bind9将
// 此次dns请求转发给forwarders中的dns地址,最终bind9获得ip
    forwarders {
        202.106.0.20;
    };

luther@gliethttp:~$ sudo service bind9 restart
luther@gliethttp:~$ sudo vim /etc/resolv.conf 放在文件第一行,作为首选dns
# 将本行放在resolv.conf的第1行,使得本dns为首选dns.
nameserver 172.16.32.123
下面看看我们配置的DNS是否工作起来了
luther@gliethttp:~$ nslookup
>
Server:        172.16.32.123
Address:    172.16.32.123#53

Name:    
Address: 172.16.32.123
> 172.16.32.54
Server:        172.16.32.123
Address:    172.16.32.123#53

54.32.16.172.in-addr.arpa    name = glx.gliethttp.com.
> gliethttp.com
Server:        172.16.32.123
Address:    172.16.32.123#53

Name:    gliethttp.com
Address: 172.16.32.123
>
>
> set type=any
> gliethttp.com
Server:        172.16.32.123
Address:    172.16.32.123#53

gliethttp.com
    origin = gliethttp.com
    mail addr = root.localhost
    serial = 1
    refresh = 604800
    retry = 86400
    expire = 2419200
    minimum = 604800
gliethttp.com    nameserver =

或者
可以在apache2上直接设置
luther@gliethttp:~$ sudo vim /etc/apache2/httpd.conf
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
RewriteEngine on
# 表示当没有输入子目录的情况下使用trac/作为默认访问目录,当然设置完成之后apache restart,同时firefox也需要清空全部Clear Recent history;这样apache设置的效果才能在firefox上体现出来
RedirectMatch ^/$ http:///trac
或者
RedirectMatch ^/$ /trac/  这样输入127.0.0.1时,会自动连接到127.0.0.1/trac/

luther@gliethttp:~$ vim auto.html




luther@gliethttp:~$ firefox auto.html

windows下可以使用如下语句清空dns内容
ipconfig /flushdns
阅读(2332) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~