In Ubuntu 14.04 machen weder sudo service networking restart
noch sudo /etc/init.d/networking restart
irgendetwas mehr. Sie beenden sich auch beide mit Code 1. Irgendetwas hat sich offensichtlich geändert (oder halb geändert), aber ich kann nicht herausfinden, was. Dies führt offensichtlich zu Problemen bei der Rekonfiguration von Fernnetzwerken und Tools wie Ansible.
$ sudo bash -x /usr/sbin/service networking restart
[sudo] password for wirehive:
++ basename /usr/sbin/service
+ VERSION='service ver. 0.91-ubuntu1'
++ basename /usr/sbin/service
+ USAGE='Usage: service < option > | --status-all | [ service_name [ command | --full-restart ] ]'
+ SERVICE=
+ ACTION=
+ SERVICEDIR=/etc/init.d
+ OPTIONS=
+ '[' 2 -eq 0 ']'
+ cd /
+ '[' 2 -gt 0 ']'
+ case "${1}" in
+ '[' -z '' -a 2 -eq 1 -a networking = --status-all ']'
+ '[' 2 -eq 2 -a restart = --full-restart ']'
+ '[' -z '' ']'
+ SERVICE=networking
+ shift
+ '[' 1 -gt 0 ']'
+ case "${1}" in
+ '[' -z networking -a 1 -eq 1 -a restart = --status-all ']'
+ '[' 1 -eq 2 -a '' = --full-restart ']'
+ '[' -z networking ']'
+ '[' -z '' ']'
+ ACTION=restart
+ shift
+ '[' 0 -gt 0 ']'
+ '[' -r /etc/init/networking.conf ']'
+ which initctl
+ grep -q upstart
+ initctl version
+ case "${ACTION}" in
+ stop networking
stop: Job failed while stopping
+ :
+ exec start networking
start: Job is already running: networking
Was ist der richtige Weg, um das Netzwerk in Ubuntu 14.04 Server aus der Ferne neu zu starten?
Es stellt sich heraus, dass dies ein "Feature" ist. Die einzige unterstützte Möglichkeit, eine Schnittstelle in Ubuntu Server neu zu starten, ist sudo ifdown eth0 && sudo ifup eth0
.
https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1301015
Was sich geändert hat, ist, dass sie nicht mehr wollen, dass man das Netzwerk "prellt". Anhalten und Starten funktionieren immer noch, aber Neustart funktioniert nicht mehr. Ich habe dieses "Problem" gerade "gelöst", d.h. ich habe das alte Verhalten wiederhergestellt. So kehren Sie zum vorherigen Verhalten zurück: Nehmen Sie eine 13.10 /etc/init/networking.conf Datei und ersetzen Sie die 14.04 Datei damit. (edit: klargestellt, was was ersetzt)
Der Prozess sieht wie folgt aus:
(Just before this, I configured my /etc/network/interfaces for eth1 on a 192.168.117.x address)
"/etc/network/interfaces" 16L, 413C written
root@1404-Anode:~# service networking restart
stop: Job failed while stopping
start: Job is already running: networking
root@1404-Anode:~# echo "hmm, wth?"
hmm, wth?
root@1404-Anode:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:d6:a8:19
inet addr:192.168.115.105 Bcast:192.168.115.255 Mask:255.255.255.0
inet6 addr: 2002:4077:9050:1234:a08c:29c1:ce9b:a57b/64 Scope:Global
inet6 addr: fe80::20c:29ff:fed6:a819/64 Scope:Link
inet6 addr: 2002:4077:9050:1234:20c:29ff:fed6:a819/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:646 errors:0 dropped:0 overruns:0 frame:0
TX packets:531 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:58748 (58.7 KB) TX bytes:75465 (75.4 KB)
(lo removed here)
root@1404-Anode:~# cd /etc/init
root@1404-Anode:/etc/init# diff networking.conf.1310 networking.conf.1404
13c13
< and (stopped udevtrigger or container)) or runlevel [2345]
---
> and (stopped udevtrigger or container)) or runlevel [2345] or stopped networking >RESULT=failed PROCESS=post-stop EXIT_STATUS=100
16a17,20
> if [ "$UPSTART_EVENTS" = "stopped" ] && [ "$UPSTART_JOB" = "networking" ] && [ "$EXIT_STATUS" = "100" ]; then
> exit 0
> fi
>
21a26,31
> if [ -z "$UPSTART_STOP_EVENTS" ]; then
> echo "Stopping or restarting the networking job is not supported."
> echo "Use ifdown & ifup to reconfigure desired interface."
> exit 100
> fi
root@1404-Anode:/etc/init#
Machen Sie das Gleiche für das Skript /etc/init.d/networking, auf das die Datei /etc/init/networking.conf verweist/aufruft.
root@1404-Anode:/etc/init# cp networking.conf.1310 networking.conf
root@1404-Anode:/etc/init# cd ../init.d
root@1404-Anode:/etc/init.d# diff networking.1404 networking.1310
15d14
< STATEDIR="$RUN_DIR/state"
21a21,27
> # Make sure that it's clear to the user that they shouldn't use this
> # script under upstart
> if init_is_upstart; then
> echo "ERROR: Calling a sysvinit script on a system using upstart isn't supported. Please use the 'service' command instead."
> exit 1
> fi
>
52,54d57
< if ! chown root:netdev "$RUN_DIR" ; then
< log_warning_msg "can't chown $RUN_DIR"
< fi
160,162d162
< if init_is_upstart; then
< exit 1
< fi
166c166
< state=$(ifquery --state)
---
> state=$(cat /run/network/ifstate)
root@1404-Anode:/etc/init.d# cp networking.1310 networking
root@1404-Anode:/etc/init.d# service networking restart
networking stop/waiting
networking start/running
root@1404-Anode:/etc/init.d# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:d6:a8:19
inet addr:192.168.115.105 Bcast:192.168.115.255 Mask:255.255.255.0
inet6 addr: 2002:4077:9050:1234:a08c:29c1:ce9b:a57b/64 Scope:Global
inet6 addr: fe80::20c:29ff:fed6:a819/64 Scope:Link
inet6 addr: 2002:4077:9050:1234:20c:29ff:fed6:a819/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3398 errors:0 dropped:0 overruns:0 frame:0
TX packets:2545 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:318654 (318.6 KB) TX bytes:418804 (418.8 KB)
eth1 Link encap:Ethernet HWaddr 00:0c:29:d6:a8:23
inet addr:192.168.117.105 Bcast:192.168.117.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fed6:a823/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:98 errors:0 dropped:58 overruns:0 frame:0
TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:20055 (20.0 KB) TX bytes:1226 (1.2 KB)
(lo removed)
root@1404-Anode:/etc/init.d# echo "hah, it works! *8^)"
Hah, it works! *8^)
root@1404-Anode:/etc/init.d#
(note: the steps where I scp'd the 1310 versions into the 1404 system are omitted for brevity).
Offensichtlich gibt es einen Grund, warum sie dort einen defensiven Exit eingebaut haben, aber sie machen sich nicht die Mühe, wirklich gut auszugeben, was vor sich geht.
Wenn Sie es versuchen, wird ein Eintrag in /var/log/upstart/networking.log erstellt, der wie folgt aussieht:
Stopping or restarting the networking job is not supported.
Use ifdown & ifup to reconfigure desired interface.
Aber sie könnten/sollten das wirklich als Dialogmeldung ausgeben, wenn man den Neustart von service networking versucht. ach ja, ich habe es herausgefunden und sogar einen alten Weg gefunden, es zu umgehen.
EDIT: Ich habe herausgefunden, dass dies ein unbeabsichtigtes Auslösen des Skripts verursacht, das von /etc/init/failsafe.conf gesteuert wird, was unerwünscht ist, da es eine 120 Sekunden lange Timeout-Verzögerung bei jedem Bootvorgang verursacht... und vielleicht auch tatsächliche Fehlkonfigurationen/Netzwerkprobleme maskiert, auf die diese Verzögerung hinweisen würde, aber sie wird bereits die ganze Zeit angezeigt. (z.B. ein nicht eingestecktes Kabel, das den Zugriff auf eine Netzwerkfreigabe ermöglichte, die in /etc/fstab eingetragen ist)
Auf jeden Fall werde ich herausfinden, was die Ursache für die ständige Zeitüberschreitung ist, und eine Lösung posten, sobald ich sie gefunden habe.
In Bezug auf kvm-user420's Antwort, I've vorausgegangen und ein Skript zu ersetzen Ubuntu 14.04's Networking-Skripte mit dem von Ubuntu 13.10
Sie können es hier finden: https://github.com/metral/restore_networking
Viel Spaß damit!