Ubuntu 启动时出现网络错误,需要重启才能解决

Ubuntu 启动时出现网络错误,需要重启才能解决

最近,在系统重启时,我们被迫通过手动输入命令来激活网络

/etc/init.d/networking restart

否则 eth0 未定义或者未处于活动状态。

有人能从中找出问题所在以及我们该如何解决这个问题吗?


日志输出:(cat /var/log/messages | grep eth0请注意,一旦登录失败,我就会手动打开它以进行此项设置)

Aug 17 13:05:48 sugarbackup-desktop kernel: [    4.216762] eth0: Tigon3 [partno(BCM95784M) rev 5784100 PHY(5784)] (PCI Express) 10/100/1000Base-T Ethernet 00:21:9b:72:90:ac
Aug 17 13:05:48 sugarbackup-desktop kernel: [    4.216766] eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[0] WireSpeed[1] TSOcap[1]
Aug 17 13:05:48 sugarbackup-desktop kernel: [    4.216768] eth0: dma_rwctrl[76180000] dma_mask[64-bit]
Aug 17 13:05:49 sugarbackup-desktop kernel: [   16.814063] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 17 13:05:49 sugarbackup-desktop kernel: [   16.814066] tg3: eth0: Flow control is on for TX and on for RX.
Aug 17 14:10:15 sugarbackup-desktop kernel: [    4.228756] eth0: Tigon3 [partno(BCM95784M) rev 5784100 PHY(5784)] (PCI Express) 10/100/1000Base-T Ethernet 00:21:9b:72:90:ac
Aug 17 14:10:15 sugarbackup-desktop kernel: [    4.228761] eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[0] WireSpeed[1] TSOcap[1]
Aug 17 14:10:15 sugarbackup-desktop kernel: [    4.228763] eth0: dma_rwctrl[76180000] dma_mask[64-bit]
Aug 17 14:10:16 sugarbackup-desktop kernel: [   16.805430] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 17 14:10:16 sugarbackup-desktop kernel: [   16.805433] tg3: eth0: Flow control is on for TX and on for RX.
Aug 17 15:05:58 sugarbackup-desktop kernel: [    4.244599] eth0: Tigon3 [partno(BCM95784M) rev 5784100 PHY(5784)] (PCI Express) 10/100/1000Base-T Ethernet 00:21:9b:72:90:ac
Aug 17 15:05:58 sugarbackup-desktop kernel: [    4.244603] eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[0] WireSpeed[1] TSOcap[1]
Aug 17 15:05:58 sugarbackup-desktop kernel: [    4.244605] eth0: dma_rwctrl[76180000] dma_mask[64-bit]
Aug 17 15:05:59 sugarbackup-desktop kernel: [   16.738952] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 17 15:05:59 sugarbackup-desktop kernel: [   16.738955] tg3: eth0: Flow control is on for TX and on for RX.
Aug 17 15:07:05 sugarbackup-desktop kernel: [  114.555430] ADDRCONF(NETDEV_UP): eth0: link is not ready
Aug 17 15:07:07 sugarbackup-desktop kernel: [  116.152273] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 17 15:07:07 sugarbackup-desktop kernel: [  116.152278] tg3: eth0: Flow control is on for TX and on for RX.
Aug 17 15:07:07 sugarbackup-desktop kernel: [  116.152889] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Aug 17 15:20:27 sugarbackup-desktop kernel: [    4.212747] eth0: Tigon3 [partno(BCM95784M) rev 5784100 PHY(5784)] (PCI Express) 10/100/1000Base-T Ethernet 00:21:9b:72:90:ac
Aug 17 15:20:27 sugarbackup-desktop kernel: [    4.212751] eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[0] WireSpeed[1] TSOcap[1]
Aug 17 15:20:27 sugarbackup-desktop kernel: [    4.212753] eth0: dma_rwctrl[76180000] dma_mask[64-bit]
Aug 17 15:20:27 sugarbackup-desktop kernel: [   16.797888] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 17 15:20:27 sugarbackup-desktop kernel: [   16.797892] tg3: eth0: Flow control is on for TX and on for RX.
Aug 17 15:21:13 sugarbackup-desktop kernel: [   90.723423] ADDRCONF(NETDEV_UP): eth0: link is not ready
Aug 17 15:21:15 sugarbackup-desktop kernel: [   92.258276] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 17 15:21:15 sugarbackup-desktop kernel: [   92.258282] tg3: eth0: Flow control is on for TX and on for RX.
Aug 17 15:21:15 sugarbackup-desktop kernel: [   92.258450] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Aug 17 15:22:46 sugarbackup-desktop kernel: [  183.595465] ADDRCONF(NETDEV_UP): eth0: link is not ready
Aug 17 15:22:48 sugarbackup-desktop kernel: [  185.130353] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 17 15:22:48 sugarbackup-desktop kernel: [  185.130359] tg3: eth0: Flow control is on for TX and on for RX.
Aug 17 15:22:48 sugarbackup-desktop kernel: [  185.130527] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Aug 17 16:42:34 sugarbackup-desktop kernel: [    4.228620] eth0: Tigon3 [partno(BCM95784M) rev 5784100 PHY(5784)] (PCI Express) 10/100/1000Base-T Ethernet 00:21:9b:72:90:ac
Aug 17 16:42:34 sugarbackup-desktop kernel: [    4.228623] eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[0] WireSpeed[1] TSOcap[1]
Aug 17 16:42:34 sugarbackup-desktop kernel: [    4.228626] eth0: dma_rwctrl[76180000] dma_mask[64-bit]
Aug 17 16:42:35 sugarbackup-desktop kernel: [   16.843218] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 17 16:42:35 sugarbackup-desktop kernel: [   16.843221] tg3: eth0: Flow control is on for TX and on for RX.
Aug 17 16:44:40 sugarbackup-desktop kernel: [  171.575406] ADDRCONF(NETDEV_UP): eth0: link is not ready
Aug 17 16:44:42 sugarbackup-desktop kernel: [  173.110268] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 17 16:44:42 sugarbackup-desktop kernel: [  173.110275] tg3: eth0: Flow control is on for TX and on for RX.
Aug 17 16:44:42 sugarbackup-desktop kernel: [  173.110764] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Aug 17 17:00:35 sugarbackup-desktop kernel: [ 1126.999527] ADDRCONF(NETDEV_UP): eth0: link is not ready
Aug 17 17:00:37 sugarbackup-desktop kernel: [ 1128.714587] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 17 17:00:37 sugarbackup-desktop kernel: [ 1128.714593] tg3: eth0: Flow control is on for TX and on for RX.
Aug 17 17:00:37 sugarbackup-desktop kernel: [ 1128.714766] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Aug 18 10:08:33 sugarbackup-desktop kernel: [    4.220739] eth0: Tigon3 [partno(BCM95784M) rev 5784100 PHY(5784)] (PCI Express) 10/100/1000Base-T Ethernet 00:21:9b:72:90:ac
Aug 18 10:08:33 sugarbackup-desktop kernel: [    4.220742] eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[0] WireSpeed[1] TSOcap[1]
Aug 18 10:08:33 sugarbackup-desktop kernel: [    4.220745] eth0: dma_rwctrl[76180000] dma_mask[64-bit]
Aug 18 10:08:34 sugarbackup-desktop kernel: [   16.845252] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 18 10:08:34 sugarbackup-desktop kernel: [   16.845255] tg3: eth0: Flow control is on for TX and on for RX.
Aug 18 10:09:34 sugarbackup-desktop kernel: [   94.511408] ADDRCONF(NETDEV_UP): eth0: link is not ready
Aug 18 10:09:37 sugarbackup-desktop kernel: [   96.046199] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 18 10:09:37 sugarbackup-desktop kernel: [   96.046204] tg3: eth0: Flow control is on for TX and on for RX.
Aug 18 10:09:37 sugarbackup-desktop kernel: [   96.046648] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Aug 18 10:15:25 sugarbackup-desktop kernel: [    4.332749] eth0: Tigon3 [partno(BCM95784M) rev 5784100 PHY(5784)] (PCI Express) 10/100/1000Base-T Ethernet 00:21:9b:72:90:ac
Aug 18 10:15:25 sugarbackup-desktop kernel: [    4.332753] eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[0] WireSpeed[1] TSOcap[1]
Aug 18 10:15:25 sugarbackup-desktop kernel: [    4.332755] eth0: dma_rwctrl[76180000] dma_mask[64-bit]
Aug 18 10:15:26 sugarbackup-desktop kernel: [   17.798590] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 18 10:15:26 sugarbackup-desktop kernel: [   17.798594] tg3: eth0: Flow control is on for TX and on for RX.
Aug 18 10:17:36 sugarbackup-desktop kernel: [  172.483750] ADDRCONF(NETDEV_UP): eth0: link is not ready
Aug 18 10:17:38 sugarbackup-desktop kernel: [  174.081384] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 18 10:17:38 sugarbackup-desktop kernel: [  174.081390] tg3: eth0: Flow control is on for TX and on for RX.
Aug 18 10:17:38 sugarbackup-desktop kernel: [  174.081815] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Aug 18 14:32:47 sugarbackup-desktop kernel: [    3.500752] eth0: Tigon3 [partno(BCM95784M) rev 5784100 PHY(5784)] (PCI Express) 10/100/1000Base-T Ethernet 00:21:9b:72:90:ac
Aug 18 14:32:47 sugarbackup-desktop kernel: [    3.500756] eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[0] WireSpeed[1] TSOcap[1]
Aug 18 14:32:47 sugarbackup-desktop kernel: [    3.500758] eth0: dma_rwctrl[76180000] dma_mask[64-bit]
Aug 18 14:32:48 sugarbackup-desktop kernel: [   16.803614] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 18 14:32:48 sugarbackup-desktop kernel: [   16.803617] tg3: eth0: Flow control is on for TX and on for RX.
Aug 18 14:33:37 sugarbackup-desktop kernel: [   91.987489] ADDRCONF(NETDEV_UP): eth0: link is not ready
Aug 18 14:33:38 sugarbackup-desktop kernel: [   93.522265] tg3: eth0: Link is up at 100 Mbps, full duplex.
Aug 18 14:33:38 sugarbackup-desktop kernel: [   93.522271] tg3: eth0: Flow control is on for TX and on for RX.
Aug 18 14:33:38 sugarbackup-desktop kernel: [   93.522597] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

root@sugarbackup-desktop:~# find /etc/rc*.d/*Netw*
/etc/rc2.d/S28NetworkManager
/etc/rc3.d/S28NetworkManager
/etc/rc4.d/S28NetworkManager
/etc/rc5.d/S28NetworkManager

root@sugarbackup-desktop:~# find /etc/rc*.d/*netw*
/etc/rc0.d/S35networking
/etc/rc6.d/S35networking
/etc/rcS.d/S40networking    

> 
# aptitude reinstall network-manager
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information      
Initializing package states... Done
The following packages will be REINSTALLED:
  network-manager 
The following packages will be REMOVED:
  libbsd-resource-perl{u} linux-headers-2.6.27-7{u} 
  linux-headers-2.6.27-7-generic{u} 
0 packages upgraded, 0 newly installed, 1 reinstalled, 3 to remove and 209 not upgraded.
Need to get 0B of archives. After unpacking 52.2MB will be freed.
Do you want to continue? [Y/n/?] y
E: I wasn't able to locate file for the network-manager package. This might mean you need to manually fix this package.
Writing extended state information... Done
E: I wasn't able to locate file for the network-manager package. This might mean you need to manually fix this package.
E: Internal error: couldn't generate list of packages to downloa

答案1

您可以检查以下事项: - 检查通过 DHCP 获取 IP 是否存在问题。 - 在我的 ubuntu-9.04 上,它是 eth1(没有创建 eth0。) - 启动期间可能发生竞争条件……因此,在启用网络后可能会创建接口。

答案2

显然,更多细节会有所帮助,检查你的日志中是否有任何关于 eth0 的提及

# cat /var/log/messages | grep eth0

如果您可以将 /etc/init.d/networking restart 命令的输出添加到您的问题中,这也会有所帮助。正如 sudeshpawar 所说,这可能是由于 DHCP 未能及时分配地址。


可能是 NetworkManager 服务未启动,但如果没有 log/dmesg 输出就很难判断。

在 GNU/Linux 启动时启用和禁用服务

Ubuntu / Debian Linux:服务配置工具来启动/停止系统服务

使用以下命令检查 NetworkManager 服务是否在启动时启动:

 # find /etc/rc*.d/Network
/etc/rc2.d/S50NetworkManager
/etc/rc3.d/S50NetworkManager
/etc/rc4.d/S50NetworkManager
/etc/rc5.d/S50NetworkManager


从 /var/log/messages 输出中我们可以看到 eth0 在启动过程中 16 秒后启动。我假设下一个活动是重新启动网络服务。

 Aug 18 14:32:47 sugarbackup-desktop kernel: [ 3.500752] eth0: Tigon3 [partno(BCM95784M) rev 5784100 PHY(5784)] (PCI Express) 10/100/1000Base-T Ethernet 00:21:9b:72:90:ac
 Aug 18 14:32:47 sugarbackup-desktop kernel: [ 3.500756] eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[0] WireSpeed[1] TSOcap[1] 
 Aug 18 14:32:47 sugarbackup-desktop kernel: [ 3.500758] eth0: dma_rwctrl[76180000] dma_mask[64-bit] 
 Aug 18 14:32:48 sugarbackup-desktop kernel: [ 16.803614] tg3: eth0: Link is up at 100 Mbps, full duplex. 
 Aug 18 14:32:48 sugarbackup-desktop kernel: [ 16.803617] tg3: eth0: Flow control is on for TX and on for RX.
 Aug 18 14:33:37 sugarbackup-desktop kernel: [ 91.987489] ADDRCONF(NETDEV_UP): eth0: link is not ready 
 Aug 18 14:33:38 sugarbackup-desktop kernel: [ 93.522265] tg3: eth0: Link is up at 100 Mbps, full duplex. 
 Aug 18 14:33:38 sugarbackup-desktop kernel: [ 93.522271] tg3: eth0: Flow control is on for TX and on for RX. 
 Aug 18 14:33:38 sugarbackup-desktop kernel: [ 93.522597] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

find 命令的输出看起来也正确,与我自己的唯一区别是 28 只是用于指示所有 init 脚本的启动顺序。

root@sugarbackup-desktop:~# find /etc/rc*.d/Netw*
/etc/rc2.d/S28NetworkManager 
/etc/rc3.d/S28NetworkManager 
/etc/rc4.d/S28NetworkManager
/etc/rc5.d/S28NetworkManager

剩下要检查的唯一区域是 GUI 网络管理器工具。如果您使用 GNOME,请右键单击网络管理器图标,选择编辑连接,突出显示 eth0 并选择编辑,并确保勾选了自动连接框。

在此处输入图片描述


如果这仍然不能解决问题,请在启动后立即发布以下命令的输出。

# ifconfig eth0 
# ifup eth0
# ifconfig eth0

输出

root@sugarbackup-desktop:~# ifconfig eth0 
eth0    Link encap:Ethernet HWaddr 00:21:9b:72:90:ac 
        BROADCAST MULTICAST MTU:1500 Metric:1 
        RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
        collisions:0 txqueuelen:1000
        RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
        Interrupt:16

root@sugarbackup-desktop:~# ifup eth0 ifup: interface eth0 already configured exactly the same output for: ifconfig eth0

您可以重新安装网络管理器或者安装类似 WICD 的替代品。

要重新安装网络管理器,请运行以下命令

 # sudo aptitude reinstall network-manager

如果你正在运行 Ubuntu 9.04 (Jaunty),只需运行此命令即可安装 WICD

 # sudo apt-get install wicd 

否则请按照指南操作这里

答案3

当您尝试重新启动网络堆栈时会发生什么?

/etc/init.d/networking restart

另外,由于您配置了静态 IP,您是否连接到了试图传递 DHCP 地址的路由器?如果是这样,您可以在路由器上禁用 DHCP,并让它仅充当网关吗?

这可能是您无法获得任何流量的原因之一。至于为什么您无法启动卡,请确保已安装驱动程序。将modprobe驱动程序放入内核并尝试ifconfig eth0 static 192.168.0.X up。(x是一个表示不同 IP 地址的变量)。

不要使用网络管理器,它不起作用,也没有必要。事实上,网络管理器往往无法正确配置直接负责管理网络堆栈的 Linux 子系统。

相关内容