Friday, January 9, 2009

gentoo下的resolv.conf问题

前提:安装gentoo就是用来折腾的.

gentoo好后, 有一个奇问题:
每次/etc/resolv.conf被错误地设置了, 至少是没有被设置对, 如下内容

# Generated by net-scripts for interface lo
domain localhost


有一点蛛丝马迹: Generated by net-scripts for interface lo

好, 折腾开始!

在/etc/runlevels下的boot目录中找到一个net.lo文件, link到/etc/init.d/net.lo

jessinio@nio-laptop ~ $ ls -l /etc/runlevels/boot/net.lo
lrwxrwxrwx 1 root root 18 2008-12-27 11:42 /etc/runlevel /boot/net.lo -> /etc/init.d/net.lo


本想look一把/etc/init.d/net.lo代码的, 但是,一个想法闪出来:
* 有/etc/init.d/net.lo文件, 为什么没有/etc/init.d/net.eth0呢?
有这个想法还是有依据的:
* 因为lo是回流网卡, eth0是我的以太网卡

jessinio@nio-laptop ~ $ sudo ls -l /etc/init.d/net.eth0
lrwxrwxrwx 1 root root 6 2008-12-27 11:42 /etc/init.d/net.eth0 -> net.lo

此文件中存在这样的代码:
* "depend_${iface}

这应该是一个文件, 启动多个网卡的脚本

看了一把/etc/inint.d/net.lo代码, 现在了两点东西:
1. gentoo中的runlevel脚本的依懒关系是通过/etc/init.d/下的脚本的depend函数去处理的.有这样的字键字:
* need
* after
* use
这里的脚本的运行过程是怎么样的呢? 下次折腾吧

这个文件有一句话:
#NB: Config is in /etc/conf.d/net

这就扯到如下三个文件的作用了:
1. /etc/init.d
这是启动脚本的总文件夹!启动脚本是通过/etc/runlevel分开的
2. /etc/conf.d
这里一般是/etc/init.d脚本的配置文件
3. /etc/runlevels
用于分开/etc/init.d脚本

查看/etc/conf.d/net, 已经有如下信息了:
dns_domain_lo="localhost"
config_eth0=( "dhcp" )
dhcp_eth0="nodns nontp nonis"

看到上面的选项, 第一时间是想到man, 但还有例子文件可以看
/etc/conf.d/net.example

config_eth0的作用:
# For a static configuration, use something like this
# (They all do exactly the same thing btw)
config_eth0=( "192.168.0.2/24" )
config_eth0=( "192.168.0.2 netmask 255.255.255.0" )
routes_eth0=("default via 192.168.52.1")

上面的是静态IP的处理方法, dhcp的处理方法:
# Regardless of which DHCP client you prefer, you configure them the
# same way using one of following depending on which interface modules
# you're using.
#config_eth0=( "dhcp" )

看来"dhcp"应该为dhcp协议的程序, 在gentoo中应该使用dhcpcd(当然, dhclient之类的也可以)

dhcp协议程序的参数传递方法:
# For passing custom options to dhcpcd use something like the following. This
# example reduces the timeout for retrieving an address from 60 seconds (the
# default) to 10 seconds.
#dhcpcd_eth0="-t 10"


现在还不知道dhcp_eth0的作用:
# GENERIC DHCP OPTIONS
# Set generic DHCP options like so
#dhcp_eth0="release nodns nontp nonis nogateway nosendhost"

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.