心有多大舞台便有多大

Embrace changes, pursue excellence, share niceness.

dhcp client问题

最近家里的电脑除了个怪问题.家里用的是东方有线的网络,系统是ubuntu 6 server,系统开机后一段时间,网络就自动断了.ifconfig查看网卡信息,ip地址是对的.但ping不通外面的网络.然后再过一段时间,网络又重新回复,查看syslog,message等日志,只发现这样的日志:
Apr 20 22:26:10 localhost dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
Apr 20 22:26:10 localhost dhclient: DHCPOFFER from 10.119.16.1
Apr 20 22:26:10 localhost dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
Apr 20 22:26:10 localhost dhclient: DHCPACK from 10.119.16.1
Apr 20 22:26:10 localhost dhclient: bound to xxx.xxx.xxx.xxxx(我的ip地址) -- renewal in 1595 seconds.
初步分析应该是ubuntu的dhclient有问题,暂时解决不了.
先写个脚本解决下问题吧.(bash不怎么熟悉,只好用perl了)
fixnetwork.pl:
#/usr/bin/perl
use Net::Ping;
my $ip = "xxx.xxx.xxx.xxx";#随便写个公网上能ping通的ip地址
my $p = Net::Ping->new("tcp", 4);
while (1) {
if ($p->ping($ip)) {
print "$ip answered\n";
} else {
print "$ip did not answer\n";
system("ifdown eth0");
system("ifup eth0");
}
sleep(1);
}
然后执行:sudo fixnetwork.pl > fixnetwork.log &
现在暂时网络是能用了,但不知道这个dhclient的问题什么时候能解决:(

posted on 2008-04-21 10:27 pony 阅读(2640) 评论(0)  编辑  收藏 所属分类: linux


只有注册用户登录后才能发表评论。


网站导航: