免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 4814 | 回复: 12
打印 上一主题 下一主题

[DNS] DNS每次在关机重起之后/resolv.conf项里总是自动加上search!!这是为什么啊? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-04-11 18:08 |只看该作者 |倒序浏览
我的DNS配置如下:

[root@dns root]# 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 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 { localhost; } keys { rndckey; };
};

zone "." IN {
        type hint;
        file "named.ca";
};

zone "localdomain" IN {
        type master;
        file "localdomain.zone";
        allow-update { none; };
};

zone "greatalent.com" IN {
        type master;
        file "db.greatalent.com";
        allow-update{ none;};
};

zone "1.168.192.in-addr.arpa" IN {
        type master;
        file "192.168.1.rev";
        allow-update{ none;};
};

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.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";

[root@dns root]# cat /etc/resolv.conf
domain greatalent.com
nameserver 192.168.1.106
nameserver 202.106.0.20

反向解析:
[root@dns root]# cat /var/named/192.168.1.rev
$TTL    86400
@       IN      SOA    greatalent.com. root.greatalent.com.  (
                                      1997022700 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
              IN      NS      greatalent.com.

111     IN      PTR    ftp.greatalent.com.
112     IN      PTR    www.greatalent.com.

正向解析:
[root@dns root]# cat /var/named/db.greatalent.com
$TTL    86400
$ORIGIN greatalent.com.
@               IN SOA  greatalent.com.       root.greatalent.com. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum

                IN NS           greatalent.com.
                IN A            127.0.0.1
ftp             IN A            192.168.1.111
www             IN A            192.168.1.112
dns             IN A            192.168.1.106

[root@dns root]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain   localhost
192.168.1.106   dns     www.greatalent.com

问题是:
     1.电脑每次重起!DNS都不自动重起,都还需要我手动起动!  为什么?
     2.电脑每次重起"/resolv.conf"总是自动加上(search)项!搞的电脑不能正常上网!  为什么?

还请各位大侠帮我看下!
谢谢先!
谢谢啊!

论坛徽章:
0
2 [报告]
发表于 2006-04-11 18:13 |只看该作者
原帖由 狼性领导原则 于 2006-4-11 18:08 发表
我的DNS配置如下:
[...]
问题是:
     1.电脑每次重起!DNS都不自动重起,都还需要我手动起动!  为什么?
     2.电脑每次重起"/resolv.conf"总是自动加上(search)项!搞的电脑不能正常上网!  为什么?


1. 因為你只是沒有設定 dns 服務每次開機啟動。於 redhat/fedora linux 上,系統帶的 bind/dns package 的話,安裝好後使用 chkconfig 設定每次開機啟動。

  1. chkconfig named on
复制代码


你可以先使用 chkconfig --list named 看一下

2. 你對於 resolv.conf 檔案內的 search 有蠻深的誤解,因為那是設定本身網路程式存取指定主機時,若是只有使用 short hostname 時,所要附加的 domain name 項目。像是:

  1. search foo.com
复制代码


那你於該機器使用 ping ftp 時,實際等於 ping ftp.foo.com,所以這個配置設定與你架設好 dns 要提供其他人服務沒有很直接關係。

至於該檔案會被修改,你的網路卡應該是透過 dhcp 取得 ip 吧?那這時候當然會被修改。

==

论坛徽章:
0
3 [报告]
发表于 2006-04-11 20:31 |只看该作者

回复 2楼 kenduest 的帖子

强!

论坛徽章:
0
4 [报告]
发表于 2006-04-12 11:58 |只看该作者

回复 2楼 kenduest 的帖子

谢谢 kenduest 大哥!
可还有问题!

1.我在使用 chkconfig 是显示:
[root@dns root]# chkconfig --level 235 named
chkconfig 查询只能指定一个运行级别

2.设置好之后是:
[root@dns root]# cat /etc/resolv.conf
domain greatalent.com
nameserver 192.168.1.106
nameserver 202.106.0.20
关机重起之后变成:
[root@dns root]# cat /etc/resolv.conf
domain greatalent.com
nameserver 192.168.1.106
nameserver 202.106.0.20
search dns

问题是:每次自动生成:search dns之后 就不能上网了!!???

IP地址是192.168.1.106 是固定(静态)的! 不是动态IP地址!

所以我就纳闷了!!

论坛徽章:
0
5 [报告]
发表于 2006-04-12 15:24 |只看该作者
原帖由 狼性领导原则 于 2006-4-12 11:58 发表
谢谢 kenduest 大哥!
可还有问题!

1.我在使用 chkconfig 是显示:
[root@dns root]# chkconfig --level 235 named
chkconfig 查询只能指定一个运行级别


若您的 chkconfig 无法指定多个 runlevel,就一一指定吧。

  1. chkconfig --level 3 named on
复制代码
  1. chkconfig --level 5 named on
复制代码

2.设置好之后是:
[root@dns root]# cat /etc/resolv.conf
domain greatalent.com
nameserver 192.168.1.106
nameserver 202.106.0.20
关机重起之后变成:
[root@dns root]# cat /etc/resolv.conf
domain greatalent.com
nameserver 192.168.1.106
nameserver 202.106.0.20
search dns

问题是:每次自动生成:search dns之后 就不能上网了!!???
IP地址是192.168.1.106 是固定(静态)的! 不是动态IP地址!


不会啊,为何多 search 会无法上网?请问你怎样测试的?你该不会存取都使用短的 hostname 吧?你确定把那行 search 设定拿掉立即又可以上网了吗?

另外 domain 与 search 不应该同时出现,因为那是互斥的。都有使用就是最后出现的那设定有效。

所以你的问题不应该会是 search 引起的,但是你要确认应该是:

1. 你的网路环境都是设定 static ip 而没有设定使用 dhcp or ppp 环境?

2. 你用 rh/fedora linux ?可以的话 /etc/sysconfig/network 与 /etc/sysconfig/network-scripts/ifcfg-eth0 贴出来就知道。

==

论坛徽章:
0
6 [报告]
发表于 2006-04-12 17:05 |只看该作者

回复 5楼 kenduest 的帖子

对啊!
kenduest大哥!
每次重起后就变成:
[root@dns root]# cat /etc/resolv.conf
domain greatalent.com
nameserver 192.168.1.106
nameserver 202.106.0.20
search dns
拿掉search dns 把DNS起动起来 就可以上网!
我的IP地址确实是: static ip

[ 本帖最后由 狼性领导原则 于 2006-4-12 17:10 编辑 ]

论坛徽章:
0
7 [报告]
发表于 2006-04-12 17:07 |只看该作者

回复 5楼 kenduest 的帖子

我用的:RED HAT Enterprise Linux3

[root@dns root]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
TYPE=Ethernet
PEERDNS=no
USERCTL=no
IPADDR=192.168.1.106
NETMASK=255.255.0.0
GATEWAY=192.168.1.1

[root@dns root]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain

[ 本帖最后由 狼性领导原则 于 2006-4-12 17:18 编辑 ]

论坛徽章:
0
8 [报告]
发表于 2006-04-12 20:08 |只看该作者
請您貼出這個測試:

1. resolv.conf 內有 search dns 時,執行 ping www.chinaunix.net 畫面

2. resolv.conf 內沒有 search dns 時,執行 ping www.chinaunix.net 畫面

3. /etc/sysconfig/network-scripts/ 內,是否還有其他 ifcfg-* 相關檔案 ?

==

论坛徽章:
0
9 [报告]
发表于 2006-04-13 09:13 |只看该作者

回复 8楼 kenduest 的帖子

/etc/resolv.conf内有 search dns  时:
[root@dns root]# ping www.chinaunix.net
PING www.chinaunix.net (222.36.44. 56(84) bytes of data.
64 bytes from 222.36.44.8: icmp_seq=0 ttl=49 time=16.4 ms
64 bytes from 222.36.44.8: icmp_seq=1 ttl=49 time=16.8 ms

[1]+  Stopped                 ping www.chinaunix.net

/etc/resolv.conf内无 search dns 时:
[root@dns root]# ping www.chinaunix.net
PING www.chinaunix.net (222.36.44. 56(84) bytes of data.
64 bytes from 222.36.44.8: icmp_seq=0 ttl=49 time=16.1 ms
64 bytes from 222.36.44.8: icmp_seq=1 ttl=49 time=16.3 ms

[2]+  Stopped                 ping www.chinaunix.net
[root@dns root]#

这样啊!
那说明不是 search dns 的原因了!!
难道是因为DNS每次在重起后没有自动起动????
我昨天设置了自动起动,今天来的时候DNS就能自动起动了!
虽然search dns 还是自动出来! 但不影响上网!
可domain和search是不能同时存在的啊!?

[root@dns root]# ls /etc/sysconfig/network-scripts
ifcfg-eth0      ifdown-ipv6  ifup          ifup-isdn    ifup-sit
ifcfg-lo        ifdown-isdn  ifup-aliases  ifup-plip    ifup-sl
ifdown          ifdown-post  ifup-ippp     ifup-plusb   ifup-wireless
ifdown-aliases  ifdown-ppp   ifup-ipsec    ifup-post    init.ipv6-global
ifdown-ippp     ifdown-sit   ifup-ipv6     ifup-ppp     network-functions
ifdown-ipsec    ifdown-sl    ifup-ipx      ifup-routes  network-functions-ipv6

非常感谢denduest大哥!

[ 本帖最后由 狼性领导原则 于 2006-4-13 09:31 编辑 ]

论坛徽章:
0
10 [报告]
发表于 2006-04-13 13:54 |只看该作者
....

所以你一直說無法上網?這不是 ....

==
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP