如何在不通过SSH重启的情况下成功重启网络?

Modified on: Sat, 09 Jun 2018 12:23:23 +0800

在Ubuntu 14.04中,sudo service networking restartsudo /etc/init.d/networking restart都不再做任何事情。他们也都用代码1退出。有些东西明显改变了(或者一半改变了)但我找不到什么。这显然会导致远程网络重新配置和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

在Ubuntu 14.04服务器中远程重启网络的正确方法是什么?

最佳答案

原来这是一个“功能”。 唯一支持在Ubuntu服务器中重新启动接口的方法是sudo ifdown eth0 &amp;&amp; sudo ifup eth0

https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug / 1301015


相关问答

添加新评论