Chinaunix

标题: resolv.conf和dhclient.conf [打印本页]

作者: nogox    时间: 2012-02-16 17:42
标题: resolv.conf和dhclient.conf

弱弱的问个问题:
1. 我这里的centos的网络都是通过dhcp配置,而且dhclient会定时更新resolv.conf
2. 而我们需要用一个内网dns服务器做解析,比如1.1.1.1
3. 我想通过dhclient.conf把1.1.1.1加进去,配置如下:
supersede  domain-name xxx.com ;
prepend domain-name-servers 1.1.1.1 ;

但似乎系统忽略dhclient.conf的配置,resolv.conf怎么都没有1.1.1.1

咋回事呢
作者: chenyx    时间: 2012-02-16 17:45
让你的dhcp直接配置你的dns给你不行吗
作者: dooros    时间: 2012-02-16 18:30
你意思是要在resolv.conf中加入1.1.1.1?
作者: nogox    时间: 2012-02-16 18:57
回复 2# chenyx


    我没法控制dhpc server,你可以认为这条路肯定不行
作者: nogox    时间: 2012-02-16 18:58
回复 3# dooros


    对,我想修改resolv.conf的domain name,并加入自己的dns server
作者: chenyx    时间: 2012-02-16 19:00
那你把1.1.1.1写到resolv.conf中,然后chattr给resolv.conf赋予i位,不让写,测试下
作者: taojie2000    时间: 2012-02-16 19:02
回复 5# nogox


    dhclient.conf   resolv.conf     直接放网上搜
作者: nogox    时间: 2012-02-16 22:32
回复 6# chenyx


    呵呵,我也想过,但不能这么做
作者: chenyx    时间: 2012-02-16 22:39
本帖最后由 chenyx 于 2012-02-16 22:44 编辑

http://hi.baidu.com/allen%C6%A4% ... f968325882ddce.html
参考这个

作者: nogox    时间: 2012-02-16 23:48
试过,还有人说debian下用resolvconf的包,但我没找到centos上有这个包
作者: dooros    时间: 2012-02-17 00:16
他既想保留自己的dns又想通过dhcp client更新resolv.conf
能不能写个脚本,检测resolv.conf更改了就添加自己的进去?
作者: nogox    时间: 2012-02-17 14:55
回复 11# dooros


    当然可以,我只是奇怪为什么dhclient.conf不起作用
作者: nogox    时间: 2012-02-17 16:50
one more:

试了一下dhclient-exit-hooks,centos执行了dhclient-script, 但没执行dhclient-exit-hooks。看man应该肯定会调用:“
After all processing has completed, /sbin/dhclient-script checks for the presence of an executable /etc/dhclient-exit-hooks script, which if present is invoked using the '.' command. The exit status of dhclient-script will be passed to dhclient-exit-hooks in the exit_status shell variable, and will always be zero if the script succeeded at the task for which it was invoked. The rest of the environment as described previously for dhclient-enter-hooks is also present. The /etc/dhclient-exit-hooks script can modify the valid of exit_status to change the exit status of dhclient-script.  





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2