+ -
当前位置:首页 → 问答吧 → 请教关于DNS服务设置的问题

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

时间:2010-05-07

来源:互联网

大家好!我使用的是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开机自启动?

作者: point   发布时间: 2010-05-07

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?

作者: huntxu   发布时间: 2010-05-07

不知道是不是我没看明白,我照着manual的说明运行了:
引用:
dhcpcd -C resolv.conf -C mtu eth0
可是系统重启后我的resolv.conf仍然恢复原样。
请指教我是哪里做得不对吗?谢谢!

作者: point   发布时间: 2010-05-07

you need to add "-C resolv.conf" to $DHCPCD_ARGS in /etc/conf.d/dhcpcd...

作者: huntxu   发布时间: 2010-05-07

wicd里面可以选择只获取ip而手动指定DNS。

作者: xiaohuli1239   发布时间: 2010-05-07

可以把你想用的dns服务器按resolv.conf的格式保存为/etc/resolv.conf.head,然后每次用dhcp的时候就会自动把/etc/resolv.conf.head的内容加到resolv.conf的前面

作者: k_f   发布时间: 2010-05-08

目前我是用这种方式来做的!

引用:
作者: k_f
可以把你想用的dns服务器按resolv.conf的格式保存为/etc/resolv.conf.head,然后每次用dhcp的时候就会自动把/etc/resolv.conf.head的内容加到resolv.conf的前面

作者: point   发布时间: 2010-05-08