LinuxSir.cn,穿越时空的Linuxsir!

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

请教关于DNS服务设置的问题

[复制链接]
发表于 2010-5-7 12:54:16 | 显示全部楼层 |阅读模式
大家好!我使用的是Archlinux+Lxde环境,使用的无线网络连接路由器,用wicd来管理网络连接,并且是用DHCP服务来自动获取IP和DNS的。

现在我想把DNS服务器换成Google提供的公共服务器,参照wiki的做法是修改/etc/resolv.conf中的nameserver 后的IP地址。为了防止每次网络启动后都用DHCP获取的DNS服务器来修改resolv.conf,参照wiki的做法是在 /etc/conf.d/dhcpcd 中的 DHCPCD_ARGS 中添加 -R 选项。

遗憾的是我用以上方法一直没有成功,每次系统重启后就重置为DHCP获取的DNS服务器。希望大家能够帮我解答这个问题,非常感谢!

我的/etc/rc.conf中的network部分的配置:
# -----------------------------------------------------------------------
# NETWORKING
# -----------------------------------------------------------------------
#
# HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
#
HOSTNAME="host"

# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces.
#
# Interfaces to start at boot-up (in this order)
# Declare each interface then list in INTERFACES
#   - prefix an entry in INTERFACES with a ! to disable it
#   - no hyphens in your interface names - Bash doesn't like it
#
# DHCP:     Set your interface to "dhcp" (eth0="dhcp")
# Wireless: See network profiles below
#

#Static IP example
#eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
eth0="dhcp"
INTERFACES=(!eth0)

# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
#   - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 192.168.0.1"
ROUTES=(!gateway)

# Enable these network profiles at boot-up.  These are only useful
# if you happen to need multiple network configurations (ie, laptop users)
#   - set to 'menu' to present a menu during boot-up (dialog package required)
#   - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This now requires the netcfg package
#
#NETWORKS=(main)


我的/etc/resolv.conf
# Generated by dhcpcd from wlan0
# /etc/resolv.conf.head can replace this line
nameserver 192.168.1.1
# /etc/resolv.conf.tail can replace this line


我的/etc/conf.d/dhcpcd
#
# Arguments to be passed to the DHCP client daemon
#

DHCPCD_ARGS="-R -q"


非常感谢!

另外顺便问一下,我安装了compiz,怎么样能在lxde下让compiz开机自启动?
发表于 2010-5-7 13:36:09 | 显示全部楼层
all in the manual:
     -C, --nohook script
             Don't run this hook script.  Matches full name, or prefixed with 2 numbers optionally ending with .sh.

             So to stop dhcpcd from touching your DNS or MTU settings you would do:-
                   dhcpcd -C resolv.conf -C mtu eth0

the "-R" argument seems no longer available, pls keep pace with the times...
and, isn't there any way for making applications autostart in lxde?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-5-7 14:11:23 | 显示全部楼层
不知道是不是我没看明白,我照着manual的说明运行了:
dhcpcd -C resolv.conf -C mtu eth0

可是系统重启后我的resolv.conf仍然恢复原样。
请指教我是哪里做得不对吗?谢谢!
回复 支持 反对

使用道具 举报

发表于 2010-5-7 14:22:31 | 显示全部楼层
you need to add "-C resolv.conf" to $DHCPCD_ARGS in /etc/conf.d/dhcpcd...
回复 支持 反对

使用道具 举报

发表于 2010-5-7 17:31:38 | 显示全部楼层
wicd里面可以选择只获取ip而手动指定DNS。
回复 支持 反对

使用道具 举报

发表于 2010-5-7 21:57:56 | 显示全部楼层
可以把你想用的dns服务器按resolv.conf的格式保存为/etc/resolv.conf.head,然后每次用dhcp的时候就会自动把/etc/resolv.conf.head的内容加到resolv.conf的前面
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-5-8 13:23:13 | 显示全部楼层
目前我是用这种方式来做的!

Post by k_f;2088586
可以把你想用的dns服务器按resolv.conf的格式保存为/etc/resolv.conf.head,然后每次用dhcp的时候就会自动把/etc/resolv.conf.head的内容加到resolv.conf的前面
回复 支持 反对

使用道具 举报

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

本版积分规则

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