Ubuntu重启网络/etc/init.d/networking restart报错

Linux版本:Ubuntu 12.04

配置网口后重启网络,提示/etc/init.d/networking restart is deprecated。

$ sudo /etc/init.d/networking restart
* Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
* Reconfiguring network interfaces...          [ OK ]

在网上搜了半天,找到几种方法试了下。

一种说法是/etc/init.d/networking restart已被废弃,只保留/etc/init.d/networking start|stop,但测试结果表明stop|start可用性更差。
执行sudo /etc/init.d/networking stop后,除了loopback其它网卡都被停掉(有时会直接死机……),而且无法通过sudo /etc/init.d/networking start再启动,只能重启系统。

一种方法是先更新iptables再重启网卡

$ sudo iptables-save
$ sudo /etc/init.d/networking restart

但结果依然报错,跟直接执行/etc/init.d/networking restart一样。

还有一种方法是用命令service networking restart替代/etc/init.d/networking restart。

[email protected]:/etc/init.d$ service networking restart
stop: Unknown instance:
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.94" (uid=1000 pid=3847 comm="start networking ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
[email protected]:/etc/init.d$ sudo service networking restart
stop: Unknown instance:
networking stop/waiting

区别是报错信息不同了,但目测也不起作用。

只好撸起袖子自己干了,打开/etc/init.d/networking看了看,这是个shell脚本,对restart的处理实际用的命令是ifdown -a和ifup -a。

case "$1" instart)        /lib/init/upstart-job networking start        ;;stop)        check_network_file_systems     -------略过-------

force-reload|restart)
         process_options

         log_warning_msg "Running $0 $1 is deprecated because it may not enable again some interfaces"
         log_action_begin_msg "Reconfiguring network interfaces"         ifdown -a --exclude=lo || true
         if ifup -a --exclude=lo; then
             log_action_end_msg $?
         else
             log_action_end_msg $?
         fi
         ;;

man一下ifdown和ifup,ifdown可以停止正在运行的网口,而ifup可以启动在/etc/network/interfaces文件中配置并标有auto的网口,auto表示开机自动启动。

ifdown -a
       Bring down all interfaces that are currently up.
ifup -a
       Bring up all the interfaces defined with auto in /etc/network/interfaces

于是试了试sudo ifdown -a,sudo ifup -a,网卡重启成功。

所以,对需要重启的网口,先确认/etc/network/interfaces配置中有auto标识,然后用ifdown -a | ifup -a实现重启。
比如eth0的配置

auto eth0
iface eth0 inet dhcp----下略----

严重吐槽:一个小小的网卡重启功能,被Ubuntu改得鸡飞狗跳!

参考资料
http://www.jscto.net/html/109.html
http://comments.gmane.org/gmane.linux.debian.user/390797

时间: 2024-08-29 08:21:56

Ubuntu重启网络/etc/init.d/networking restart报错的相关文章

ubuntu重启网络报错

执行:[email protected]:/$ /etc/init.d/networking restart 报错:stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.7" (uid=1000 pid=1201 comm="stop networking ") interface="com.ubuntu.Upstart0_6.Job&q

mysql无法启动问题的解决方案:mysql.sock重启不自动生成,mysqld_safe启动报错

mysql无法启动问题的解决方案:mysql.sock重启不自动生成,mysqld_safe启动报错 - superlucky 时间 2013-08-03 11:55:00 博客园-原创精华区 原文  http://www.cnblogs.com/super-lucky/p/superlucky.html 主题 MySQL 本人还是个菜鸟,下面是我的经验之谈,能解决一些问题,有不对的地方,敬请斧正. 我的是CentOS6.3+MySQL5.1.57. 重启了一次服务器后, 使用> mysql -

ubuntu 重启网络方法--通过杀死进程重启网络

重启网络方法(通过杀死进程方式,达到网络重启) [email protected]:~$sudo NetworkManager restart //查看进程idNetworkManager 已正运行(pid 10254)[email protected]:~$sudo kill 10254 //杀死进程[email protected]:~$sudo NetworkManager restartNetworkManager 已正运行(pid 10582) 原文地址:https://www.cnb

Ubuntu下安装了java但启动eclipse报错说没装java

参考资料:http://blog.csdn.net/happyteafriends/article/details/8290950 一.问题 在Ubuntu下安装了java并在~/.bashrc配置了环境变量,在终端可运行java等命令,但启动eclipse报错说缺少jre或jdk: ”a java runtime environment jre or java development kit jdk....“ 二.解决 在在/etc/environment里补充上jdk bin的路径即可. 三

Centos7网络配置,vsftpd安装及530报错解决

今天在虚拟机安装CentOS7,准备全新安装LTMP,结果又是一堆问题,不过正好因为这些出错,又给自己长了见识. 1,CentOS7网络配置 最小化安装CentOs7后,ifconfig提示command not found,查了一下是ifconfig的net-tools没装,于是yum search ifconfig查找安装包,又是提示Cannot find a valid baseurl for repo: base/7/x86_6,才发现网卡还没配好,查了一下,原来是centos7下ip命

service network restart报错,出现FAILED

在运行service network restart命令时候,显示如下错误 hutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] fgrep: ifcfg-ifcfg-eth0: No such file or directory fgrep: ifcfg-ifcfg-eth0: No such file or directory fgrep: ifcfg-ifcfg-eth0: No suc

Ubuntu下开启php调试模式,显示报错信息

在Ubuntu下php的缺省设置是不显示错误信息的,如果程序出错会显示“无法处理此请求的错误提示”,这在开发环境下非常不方便. 其实我们只要编辑下apache的配置文件就好 1.我的apache 配置文件目录是/etc/apache2/apache2.conf sudo vim /etc/apache2/apache2.conf 再最后加入以下两行 php_flag display_errors        on php_value error_reporting       2039 2.重

【已解决】安装Ubuntu时怎样分区--利用EasyBCD在win7下进行ubuntu安装(双系统)时遇到报错:没有根文件系统,请回到分区菜单以修正此错误

由于我们离不开Windows操作,并且因为不熟悉而不习惯ubuntu的操作方式,固采用Win7和Ubuntu双系统方式比较合理.在Win7基础上安装Ubuntu,Ubuntu会自动建立一个启动菜单,让我们在开机时自行选择启动Win7还是Ubuntu. 1.在win7上安装EasyBCD后进行配置,并复制启动文件到C盘.此步具体过程可见http://teliute.org/linux/Ubsetup/jichu3/jichu3.html中的步骤一下载安装 EasyBCD,以及步骤二复制启动文件:

【Linux】Ubuntu vi 上下左右变ABCD及 apt-get install报错问题解决方法

新装的ubuntu12.04,本人绝对新手,在使用VI编辑器编辑文本时觉得实在是难用,因此找了几个解决方法如下: 1. 安装vim full版本 由于Ubuntu预安装的是tiny版本,就会导致我们在使用上的产生不便.所以我们要安装vim的full版本. 首先,先卸掉旧版的vi,输入以下命令: sudo apt-get remove vim-common 然后安装full版的vim,输入命令:sudo apt-get install vim 这样安装好了之后的VI就没有那么难用了. 此方法是我自