启动后,为什么我必须运行 /etc/init.d/networking restart 才能使网络正常工作?

启动后,为什么我必须运行 /etc/init.d/networking restart 才能使网络正常工作?

我刚刚修复了 grub 安装,发现有线网络连接无法正常工作。我最终让它正常工作了,但每次重新启动时,我都必须手动重新启动网络服务才能启动网络。如何让网络自动启动?

这是相关信息。

跑步ifup给了:

$sudo ifup eth0
Unknown interface eth0=eth0

dhclient,也没有用。我最终看了一下/etc/network/interfaceseth0发现缺少:

auto lo
iface lo inet loopback

我将其改为:

auto eth0
iface eth0 inet dhcp
#auto lo
#iface lo inet loopback

产生的错误ifup消失了,但dhclient仍然不会给我一个 ip,但重新启动网络接口就可以了:

$ sudo /etc/init.d/networking restart
 * Reconfiguring network interfaces...                                          RTNETLINK answers: No such process
There is already a pid file /var/run/dhclient.eth0.pid with pid 1421
killed old client process, removed PID file
Internet Systems Consortium DHCP Client V3.1.3
Copyright 2004-2009 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/6c:f0:49:e3:26:fd
Sending on   LPF/eth0/6c:f0:49:e3:26:fd
Sending on   Socket/fallback
DHCPRELEASE on eth0 to 192.168.1.1 port 67
send_packet: Network is unreachable
send_packet: please consult README file regarding broadcast address.
Internet Systems Consortium DHCP Client V3.1.3
Copyright 2004-2009 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/6c:f0:49:e3:26:fd
Sending on   LPF/eth0/6c:f0:49:e3:26:fd
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 6
DHCPOFFER of 192.168.1.101 from 192.168.1.1
DHCPREQUEST of 192.168.1.101 on eth0 to 255.255.255.255 port 67
DHCPACK of 192.168.1.101 from 192.168.1.1
bound to 192.168.1.101 -- renewal in 37830 seconds.
ssh stop/waiting
ssh start/running, process 1801

syslog以下是系统启动、以及重启网络后的相关条目:

Sep  3 13:38:50 storm-rider kernel: [   15.490593] type=1505 audit(1283535469.269:2):  

operation="profile_load" pid=735 name="/sbin/dhclient3"
Sep  3 13:38:50 storm-rider kernel: [   15.490754] type=1505 audit(1283535469.269:3):  operation="profile_load" pid=735 name="/usr/lib/NetworkManager/nm-dhcp-client.action"
Sep  3 13:38:50 storm-rider kernel: [   15.490833] type=1505 audit(1283535469.269:4):  operation="profile_load" pid=735 name="/usr/lib/connman/scripts/dhclient-script"
Sep  3 13:38:50 storm-rider kernel: [   15.670581] ACPI: resource piix4_smbus [0xb00-0xb07] conflicts with ACPI region SOR1 [0xb00-0xb0f]
Sep  3 13:38:50 storm-rider kernel: [   15.670581] ACPI: If an ACPI driver is available for this device, you should use it instead of the native driver
Sep  3 13:38:50 storm-rider kernel: [   15.674793] EDAC MC: Ver: 2.1.0 Aug 19 2010
Sep  3 13:38:50 storm-rider kernel: [   15.680588] EDAC amd64_edac:  Ver: 3.2.0 Aug 19 2010
Sep  3 13:38:50 storm-rider kernel: [   15.681182] EDAC amd64: This node reports that Memory ECC is currently disabled, set F3x44[22] (0000:00:18.3).
Sep  3 13:38:50 storm-rider kernel: [   15.681196] EDAC amd64: ECC disabled in the BIOS or no ECC capability, module will not load.
Sep  3 13:38:50 storm-rider kernel: [   15.681196]  Either enable ECC checking or force module loading by setting 'ecc_enable_override'.
Sep  3 13:38:50 storm-rider kernel: [   15.681196]  (Note that use of the override may cause unknown side effects.)
Sep  3 13:38:50 storm-rider kernel: [   15.681224] amd64_edac: probe of 0000:00:18.2 failed with error -22
Sep  3 13:38:50 storm-rider kernel: [   15.769839]   alloc irq_desc for 16 on node 0
Sep  3 13:38:50 storm-rider kernel: [   15.769844]   alloc kstat_irqs on node 0
Sep  3 13:38:50 storm-rider kernel: [   15.769860] HDA Intel 0000:00:14.2: PCI INT A -> GSI 16 (level, low) -> IRQ 16
Sep  3 13:38:50 storm-rider kernel: [   15.823915] Console: switching to colour frame buffer device 80x30
Sep  3 13:38:50 storm-rider kernel: [   15.917876] nvidia 0000:01:00.0: PCI INT A -> GSI 18 (level, low) -> IRQ 18
Sep  3 13:38:50 storm-rider kernel: [   15.917890] nvidia 0000:01:00.0: setting latency timer to 64
Sep  3 13:38:50 storm-rider kernel: [   15.917899] vgaarb: device changed decodes: PCI:0000:01:00.0,olddecodes=io+mem,decodes=none:owns=io+mem
Sep  3 13:38:50 storm-rider kernel: [   15.918099] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  195.36.24  Thu Apr 22 19:10:14 PDT 2010
Sep  3 13:38:50 storm-rider kernel: [   16.561300] r8169: eth0: link down
Sep  3 13:38:50 storm-rider kernel: [   16.561648] ADDRCONF(NETDEV_UP): eth0: link is not ready
Sep  3 13:38:50 storm-rider kernel: [   17.444914] EXT4-fs (sda3): mounted filesystem with ordered data mode
Sep  3 13:38:50 storm-rider init: smbd main process (1038) terminated with status 1
Sep  3 13:38:50 storm-rider init: smbd main process ended, respawning
Sep  3 13:38:50 storm-rider init: smbd main process (1045) terminated with status 1
Sep  3 13:38:50 storm-rider init: smbd main process ended, respawning
Sep  3 13:38:50 storm-rider init: smbd main process (1050) terminated with status 1
Sep  3 13:38:50 storm-rider init: smbd main process ended, respawning
Sep  3 13:38:50 storm-rider init: smbd main process (1055) terminated with status 1
Sep  3 13:38:50 storm-rider init: smbd main process ended, respawning
Sep  3 13:38:50 storm-rider avahi-daemon[957]: Network interface enumeration completed.
Sep  3 13:38:50 storm-rider avahi-daemon[957]: Registering HINFO record with values 'X86_64'/'LINUX'.
Sep  3 13:38:50 storm-rider avahi-daemon[957]: Server startup complete. Host name is storm-rider.local. Local service cookie is 49883856.
Sep  3 13:38:50 storm-rider init: smbd main process (1060) terminated with status 1
Sep  3 13:38:50 storm-rider init: smbd main process ended, respawning
Sep  3 13:38:50 storm-rider init: smbd main process (1067) terminated with status 1
Sep  3 13:38:50 storm-rider init: smbd main process ended, respawning
Sep  3 13:38:50 storm-rider init: smbd main process (1072) terminated with status 1
Sep  3 13:38:50 storm-rider init: smbd main process ended, respawning
Sep  3 13:38:50 storm-rider init: smbd main process (1077) terminated with status 1
Sep  3 13:38:50 storm-rider init: smbd main process ended, respawning
Sep  3 13:38:50 storm-rider init: smbd main process (1082) terminated with status 1
Sep  3 13:38:50 storm-rider init: smbd main process ended, respawning
Sep  3 13:38:50 storm-rider init: smbd main process (1087) terminated with status 1
Sep  3 13:38:50 storm-rider init: smbd respawning too fast, stopped
Sep  3 13:38:50 storm-rider NetworkManager:    SCPlugin-Ifupdown: update_connection_setting_from_if_block: name:eth0, type:802-3-ethernet, id:Ifupdown (eth0), uuid: 681b428f-beaf-8932-dce4-687ed5bae28e
Sep  3 13:38:50 storm-rider NetworkManager:    SCPlugin-Ifupdown: autoconnect
Sep  3 13:38:50 storm-rider NetworkManager:    SCPluginIfupdown: management mode: unmanaged
Sep  3 13:38:50 storm-rider NetworkManager:    SCPlugin-Ifupdown: devices added (path: /sys/devices/pci0000:00/0000:00:0a.0/0000:03:00.0/net/eth0, iface: eth0)
Sep  3 13:38:50 storm-rider NetworkManager:    SCPluginIfupdown: locking wired connection setting
Sep  3 13:38:50 storm-rider NetworkManager:    Ifupdown: get unmanaged devices count: 1
Sep  3 13:38:50 storm-rider NetworkManager:    SCPlugin-Ifupdown: (37841184) ... get_connections.
Sep  3 13:38:50 storm-rider NetworkManager:    SCPlugin-Ifupdown: (37841184) ... get_connections (managed=false): return empty list.
Sep  3 13:38:50 storm-rider NetworkManager:    Ifupdown: get unmanaged devices count: 1
Sep  3 13:38:50 storm-rider NetworkManager:    SCPlugin-Ifupdown: devices added (path: /sys/devices/virtual/net/lo, iface: lo)
Sep  3 13:38:50 storm-rider NetworkManager:    SCPlugin-Ifupdown: device added (path: /sys/devices/virtual/net/lo, iface: lo): no ifupdown configuration found.
Sep  3 13:38:50 storm-rider NetworkManager:    SCPlugin-Ifupdown: end _init.
Sep  3 13:38:50 storm-rider NetworkManager: Loaded plugin ifupdown: (C) 2008 Canonical Ltd.  To report bugs please use the NetworkManager mailing list.
Sep  3 13:38:50 storm-rider NetworkManager: Loaded plugin keyfile: (c) 2007 - 2008 Red Hat, Inc.  To report bugs please use the NetworkManager mailing list.
Sep  3 13:38:50 storm-rider NetworkManager: <info>  WiFi enabled by radio killswitch; enabled by state file
Sep  3 13:38:50 storm-rider NetworkManager: <info>  WWAN enabled by radio killswitch; enabled by state file
Sep  3 13:38:50 storm-rider NetworkManager: <info>  (eth0): carrier is OFF
Sep  3 13:38:50 storm-rider NetworkManager: <info>  (eth0): new Ethernet device (driver: 'r8169')
Sep  3 13:38:50 storm-rider NetworkManager: <info>  (eth0): exported as /org/freedesktop/NetworkManager/Devices/0
Sep  3 13:38:50 storm-rider NetworkManager: <info>  modem-manager is now available
Sep  3 13:38:50 storm-rider NetworkManager: <WARN>  default_adapter_cb(): bluez error getting default adapter: The name org.bluez was not provided by any .service files
Sep  3 13:38:50 storm-rider NetworkManager: <info>  Trying to start the supplicant...
Sep  3 13:38:51 storm-rider dhclient: No DHCPOFFERS received.
Sep  3 13:38:51 storm-rider dhclient: No working leases in persistent database - sleeping.
Sep  3 13:38:51 storm-rider avahi-autoipd(eth0)[1103]: Found user 'avahi-autoipd' (UID 103) and group 'avahi-autoipd' (GID 110).
Sep  3 13:38:51 storm-rider avahi-autoipd(eth0)[1103]: Successfully called chroot().
Sep  3 13:38:51 storm-rider avahi-autoipd(eth0)[1103]: Successfully dropped root privileges.
Sep  3 13:38:51 storm-rider avahi-autoipd(eth0)[1103]: Starting with address 169.254.10.181
Sep  3 13:38:52 storm-rider gdm-session-worker[1113]: GLib-GObject-CRITICAL: g_value_get_boolean: assertion `G_VALUE_HOLDS_BOOLEAN (value)' failed
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Sucessfully called chroot.
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Sucessfully dropped privileges.
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Sucessfully limited resources.
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Running.
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Canary thread running.
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Watchdog thread running.
Sep  3 13:38:52 storm-rider polkitd[1203]: started daemon version 0.96 using authority implementation `local' version `0.96'
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Sucessfully made thread 1195 of process 1195 (n/a) owned by '1000' high priority at nice level -11.
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Supervising 1 threads of 1 processes of 1 users.
Sep  3 13:38:52 storm-rider NetworkManager: <info>  Unmanaged Device found; state CONNECTED forced. (see http://bugs.launchpad.net/bugs/191889)
Sep  3 13:38:52 storm-rider NetworkManager: <info>  Unmanaged Device found; state CONNECTED forced. (see http://bugs.launchpad.net/bugs/191889)
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Sucessfully made thread 1241 of process 1195 (n/a) owned by '1000' RT at priority 5.
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Supervising 2 threads of 1 processes of 1 users.
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Sucessfully made thread 1242 of process 1195 (n/a) owned by '1000' RT at priority 5.
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Supervising 3 threads of 1 processes of 1 users.
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Sucessfully made thread 1244 of process 1244 (n/a) owned by '1000' high priority at nice level -11.
Sep  3 13:38:52 storm-rider rtkit-daemon[1197]: Supervising 4 threads of 2 processes of 1 users.
Sep  3 13:38:52 storm-rider pulseaudio[1244]: pid.c: Daemon already running.
Sep  3 13:38:53 storm-rider anacron[1405]: Anacron 2.3 started on 2010-09-03
Sep  3 13:38:53 storm-rider kernel: [   79.823450] CPU0 attaching NULL sched-domain.
Sep  3 13:38:53 storm-rider kernel: [   79.823454] CPU1 attaching NULL sched-domain.
Sep  3 13:38:53 storm-rider kernel: [   79.823456] CPU2 attaching NULL sched-domain.
Sep  3 13:38:53 storm-rider kernel: [   79.823457] CPU3 attaching NULL sched-domain.
Sep  3 13:38:53 storm-rider kernel: [   79.823458] CPU4 attaching NULL sched-domain.
Sep  3 13:38:53 storm-rider kernel: [   79.823460] CPU5 attaching NULL sched-domain.
Sep  3 13:38:53 storm-rider kernel: [   79.903191] CPU0 attaching sched-domain:
Sep  3 13:38:53 storm-rider kernel: [   79.903193]  domain 0: span 0-5 level MC
Sep  3 13:38:53 storm-rider kernel: [   79.903195]   groups: 0 1 2 3 4 5
Sep  3 13:38:53 storm-rider kernel: [   79.903199] CPU1 attaching sched-domain:
Sep  3 13:38:53 storm-rider kernel: [   79.903200]  domain 0: span 0-5 level MC
Sep  3 13:38:53 storm-rider kernel: [   79.903201]   groups: 1 2 3 4 5 0
Sep  3 13:38:53 storm-rider kernel: [   79.903203] CPU2 attaching sched-domain:
Sep  3 13:38:53 storm-rider kernel: [   79.903204]  domain 0: span 0-5 level MC
Sep  3 13:38:53 storm-rider kernel: [   79.903205]   groups: 2 3 4 5 0 1
Sep  3 13:38:53 storm-rider kernel: [   79.903208] CPU3 attaching sched-domain:
Sep  3 13:38:53 storm-rider kernel: [   79.903209]  domain 0: span 0-5 level MC
Sep  3 13:38:53 storm-rider kernel: [   79.903210]   groups: 3 4 5 0 1 2
Sep  3 13:38:53 storm-rider kernel: [   79.903212] CPU4 attaching sched-domain:
Sep  3 13:38:53 storm-rider kernel: [   79.903213]  domain 0: span 0-5 level MC
Sep  3 13:38:53 storm-rider kernel: [   79.903214]   groups: 4 5 0 1 2 3
Sep  3 13:38:53 storm-rider kernel: [   79.903216] CPU5 attaching sched-domain:
Sep  3 13:38:53 storm-rider kernel: [   79.903217]  domain 0: span 0-5 level MC
Sep  3 13:38:53 storm-rider kernel: [   79.903218]   groups: 5 0 1 2 3 4
Sep  3 13:38:53 storm-rider anacron[1405]: Normal exit (0 jobs run)
Sep  3 13:38:56 storm-rider avahi-autoipd(eth0)[1103]: Callout BIND, address 169.254.10.181 on interface eth0
Sep  3 13:38:56 storm-rider avahi-daemon[957]: Joining mDNS multicast group on interface eth0.IPv4 with address 169.254.10.181.
Sep  3 13:38:56 storm-rider avahi-daemon[957]: New relevant interface eth0.IPv4 for mDNS.
Sep  3 13:38:56 storm-rider avahi-daemon[957]: Registering new address record for 169.254.10.181 on eth0.IPv4.
Sep  3 13:39:00 storm-rider avahi-autoipd(eth0)[1103]: Successfully claimed IP address 169.254.10.181
Sep  3 13:39:14 storm-rider init: ssh main process (944) terminated with status 255
Sep  3 13:39:14 storm-rider ntpdate[1514]: can't find host ntp.ubuntu.com
Sep  3 13:39:14 storm-rider ntpdate[1514]: no servers can be used, exiting
Sep  3 13:39:54 storm-rider AptDaemon: INFO: Initializing daemon
Sep  3 13:40:13 storm-rider dhclient: Internet Systems Consortium DHCP Client V3.1.3
Sep  3 13:40:13 storm-rider dhclient: Copyright 2004-2009 Internet Systems Consortium.
Sep  3 13:40:13 storm-rider dhclient: All rights reserved.
Sep  3 13:40:13 storm-rider dhclient: For info, please visit https://www.isc.org/software/dhcp/
Sep  3 13:40:13 storm-rider dhclient: 
Sep  3 13:40:13 storm-rider avahi-autoipd(eth0)[1103]: Got SIGTERM, quitting.
Sep  3 13:40:13 storm-rider avahi-autoipd(eth0)[1103]: Callout STOP, address 169.254.10.181 on interface eth0
Sep  3 13:40:13 storm-rider avahi-daemon[957]: Withdrawing address record for 169.254.10.181 on eth0.
Sep  3 13:40:13 storm-rider avahi-daemon[957]: Leaving mDNS multicast group on interface eth0.IPv4 with address 169.254.10.181.
Sep  3 13:40:13 storm-rider avahi-daemon[957]: Interface eth0.IPv4 no longer relevant for mDNS.
Sep  3 13:40:13 storm-rider dhclient: Listening on LPF/eth0/6c:f0:49:e3:26:fd
Sep  3 13:40:13 storm-rider dhclient: Sending on   LPF/eth0/6c:f0:49:e3:26:fd
Sep  3 13:40:13 storm-rider dhclient: Sending on   Socket/fallback
Sep  3 13:40:17 storm-rider dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
Sep  3 13:40:25 storm-rider dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 12
Sep  3 13:40:39 storm-rider dhclient: There is already a pid file /var/run/dhclient.eth0.pid with pid 1421
Sep  3 13:40:39 storm-rider dhclient: killed old client process, removed PID file
Sep  3 13:40:39 storm-rider dhclient: Internet Systems Consortium DHCP Client V3.1.3
Sep  3 13:40:39 storm-rider dhclient: Copyright 2004-2009 Internet Systems Consortium.
Sep  3 13:40:39 storm-rider dhclient: All rights reserved.
Sep  3 13:40:39 storm-rider dhclient: For info, please visit https://www.isc.org/software/dhcp/
Sep  3 13:40:39 storm-rider dhclient: 
Sep  3 13:40:39 storm-rider dhclient: Listening on LPF/eth0/6c:f0:49:e3:26:fd
Sep  3 13:40:39 storm-rider dhclient: Sending on   LPF/eth0/6c:f0:49:e3:26:fd
Sep  3 13:40:39 storm-rider dhclient: Sending on   Socket/fallback
Sep  3 13:40:39 storm-rider dhclient: DHCPRELEASE on eth0 to 192.168.1.1 port 67
Sep  3 13:40:39 storm-rider dhclient: send_packet: Network is unreachable
Sep  3 13:40:39 storm-rider dhclient: send_packet: please consult README file regarding broadcast address.
Sep  3 13:40:39 storm-rider dhclient: Internet Systems Consortium DHCP Client V3.1.3
Sep  3 13:40:39 storm-rider dhclient: Copyright 2004-2009 Internet Systems Consortium.
Sep  3 13:40:39 storm-rider dhclient: All rights reserved.
Sep  3 13:40:39 storm-rider dhclient: For info, please visit https://www.isc.org/software/dhcp/
Sep  3 13:40:39 storm-rider dhclient: 
Sep  3 13:40:39 storm-rider NetworkManager: <info>  (eth0): carrier now ON (device state 1)
Sep  3 13:40:39 storm-rider kernel: [  186.096615] r8169: eth0: link up
Sep  3 13:40:39 storm-rider dhclient: Listening on LPF/eth0/6c:f0:49:e3:26:fd
Sep  3 13:40:39 storm-rider dhclient: Sending on   LPF/eth0/6c:f0:49:e3:26:fd
Sep  3 13:40:39 storm-rider dhclient: Sending on   Socket/fallback
Sep  3 13:40:41 storm-rider avahi-daemon[957]: Registering new address record for fe80::6ef0:49ff:fee3:26fd on eth0.*.
Sep  3 13:40:43 storm-rider dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 6
Sep  3 13:40:43 storm-rider dhclient: DHCPOFFER of 192.168.1.101 from 192.168.1.1
Sep  3 13:40:43 storm-rider dhclient: DHCPREQUEST of 192.168.1.101 on eth0 to 255.255.255.255 port 67
Sep  3 13:40:43 storm-rider dhclient: DHCPACK of 192.168.1.101 from 192.168.1.1
Sep  3 13:40:43 storm-rider avahi-daemon[957]: Joining mDNS multicast group on interface eth0.IPv4 with address 192.168.1.101.
Sep  3 13:40:43 storm-rider avahi-daemon[957]: New relevant interface eth0.IPv4 for mDNS.
Sep  3 13:40:43 storm-rider avahi-daemon[957]: Registering new address record for 192.168.1.101 on eth0.IPv4.
Sep  3 13:40:43 storm-rider dhclient: bound to 192.168.1.101 -- renewal in 37830 seconds.

答案1

Ubuntu 现在默认使用 NetworkManager 来处理您的网络。

There is already a pid file /var/run/dhclient.eth0.pid with pid 1421

可能告诉您 NetworkManager 已经为您启动了 dhclient。

你可以通过运行来验证

ps -o ppid= -p 1421

然后

ps -o cmd -p <the number printed by the above command>.

或者使用以下方法一步完成

ps -o cmd -p `ps -o ppid= -p 1421`

将 1421 更改为任何 pid,消息显示“已有一个 pid 文件...”。

要配置 NetworkManager,请右键单击屏幕角落的网络图标,或nm-tool从命令行运行。

谷歌“NetworkManager”以了解更多信息。

并且无论如何,从 /etc/network/interfaces 中删除“lo”对我来说听起来都是一个坏主意。

相关内容