|
我使用的是DHCP网络,每次开机或者重启的时候,都要在网络那里等待很久,这个时候系统在使用dhcpcd重新向服务器申请一个动态IP.
根据以前的经验,windows xp 和安装了dhcpcd的debian linux 在每次重新启动配置网络的时候,都是采用优先续用dhcp cache里面的IP, 也就是上次的IP ,这样可以提高配置网络的速度。
dhcpcd的manual里面写着dhcpcd默认会自动优先续用cache里面的IP.
- -s [ipaddr]
- Sends DHCP_INFORM message to DHCP server using ipaddr. The optional ipaddr parameter must
- be in the form xxx.xxx.xxx.xxx. If no ipaddr parameter is given on the command line
- dhcpcd will use the IP address currently assigned to the interface. If there is no IP
- address currently assigned to the interface dhcpcd will use previously obtained IP address
- stored in <ConfigDir>/dhcpcd-<interface>.cache file.
复制代码
我检查了一下/etc/rc.d/network ,发现里面在每次启动dhcpcd之前吧它的cache删除掉了。所以才会出现上面提到的那种情况。
解决方法:直接修改一下/etc/rc.d/network就好了
- ifup()
- {
- if [ "$1" = "" ]; then
- echo "usage: $0 ifup <interface_name>"
- return 1
- fi
- # don't bring up an interface that's already up
- [ "`/sbin/ifconfig ${1} 2>/dev/null | grep UP`" ] && return 0
- eval iwcfg="\$wlan_${1}"
- if [ "$iwcfg" != "" ]; then
- /usr/sbin/iwconfig $iwcfg
- /bin/sleep 2
- fi
- eval ifcfg="\$${1}"
- if [ "$ifcfg" = "dhcp" ]; then
- # remove the .pid file if it exists
- [color="Red"]rm -f /etc/dhcpc/dhcpcd-${1}.{pid}[/color] >/dev/null 2>&1
- /sbin/dhcpcd $DHCPCD_ARGS ${1}
- else
- /sbin/ifconfig $ifcfg
- fi
- return $?
- }
复制代码
修改部分就是上面红色那行,修改之前为
rm -f /etc/dhcpc/dhcpcd-${1}.{pid,cache} |
|