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。

zlf@zlf:/etc/init.d$ service networking restart
stop: Unknown instance:
start: Rejected send message, matched rules; type="method_call", sender=":1.94" (uid= pid= comm="start networking ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="" destination="com.ubuntu.Upstart" (uid= pid= comm="/sbin/init")

zlf@zlf:/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" in
start)
        /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

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

  1. ubuntu重启网络报错

    执行:gw@ubuntu:/$ /etc/init.d/networking restart 报错:stop: Rejected send message, 1 matched rules; type ...

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

    重启网络方法(通过杀死进程方式,达到网络重启) zh@zh:~$sudo NetworkManager restart //查看进程idNetworkManager 已正运行(pid 10254)zh ...

  3. ubuntu 下service php5-fpm restart 报错 stop: Unknown instance: 解决

    问题描述: 在安装完扩展后,重启php-fpm,发现一直停止报错 stop: Unknown instance: 通过查看进程,也查询不到该主进程 解决办法: 干掉现在正在执行的进程 pkill ph ...

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

    参考资料:http://blog.csdn.net/happyteafriends/article/details/8290950 一.问题 在Ubuntu下安装了java并在~/.bashrc配置了 ...

  5. ubuntu安装mysql遇到的坑----解决Mysql报错缺少libaio.so.1

    最近学习大数据,涉及到hive的部分需要安装mysql,于是就在linux环境下尝试安装,对于我这个linux小白来说,中间遇到很多坑爹问题,在这里做一个记录. 我参考的mysql安装博客: http ...

  6. service network restart 报错重启失败

    Job for network.service failed because the control process exited with error code. See “systemctl st ...

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

    今天在虚拟机安装CentOS7,准备全新安装LTMP,结果又是一堆问题,不过正好因为这些出错,又给自己长了见识. 1,CentOS7网络配置 最小化安装CentOs7后,ifconfig提示comma ...

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

    在Ubuntu下php的缺省设置是不显示错误信息的,如果程序出错会显示“无法处理此请求的错误提示”,这在开发环境下非常不方便. 其实我们只要编辑下apache的配置文件就好 1.我的apache 配置 ...

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

    新装的ubuntu12.04,本人绝对新手,在使用VI编辑器编辑文本时觉得实在是难用,因此找了几个解决方法如下: 1. 安装vim full版本 由于Ubuntu预安装的是tiny版本,就会导致我们在 ...

随机推荐

  1. MVC 菜鸟学习记录1

    Asp.Net MVC 模式是一种表现模式.它将web应用程序分成三个主要组件即:    Model.View.Controller M:Model 主要是存储或者是处理数据的组件 Model其实是实 ...

  2. AsyncQueryHandler 和 CursorAdapter的使用

    AsyncQueryHandler A helper class to help make handling asynchronous ContentResolver queries easier. ...

  3. MVC基础知识-持续更新....

    1.如何在自动生成的视图中显示需要的字段名称: 在相应的定义字段中添加Display,例如: [Display(Name = "用户名:")] public string User ...

  4. win7安装office2007出错被中断-已经解决

    觉得雨林木风win7系统本身的office2007不好,但不能卸载,用360强力删除工具,把整个安装的文件夹全部删除,重新用之前能够在另外xp和win7系统成功安装的破解版office2007,安装开 ...

  5. 自学php找工作【二】 PHP计算时间加一天

    最近几天在做一个项目,主要是将SQLserver数据到MySQL数据库,一个url跑一次 同步一次昨天的数据,由于很多数据需要同步,所以做了一个操作界面的,一个单纯跑url的 在其中涉及到了对于时间的 ...

  6. Wim技术之Wim文件的制作

    背景:操作的镜像文件为win8.1 update的ISO里的Wim文件 1.使用如下命令将支持WimBoot的instal.Wim文件转换成可以支持wimboot启动的映像文件 Dism /Expor ...

  7. iOS定位 - 普通定位(没有地图) - 反地理编码(得到具体位置)

    #import <CoreLocation/CoreLocation.h> 使用到的头文件 要引入CoreLocation这个包 <CLLocationManagerDelegate ...

  8. easyUi学习备忘

    1.获取datagrid的自身相关的属性方式: jQuery("#grid").datagrid("options").height jQuery(" ...

  9. TCP通信三次握手的过程

    过程 编辑 第一次 第一次握手:建立连接时,客户端 发送syn包(syn=j)到服务器,并进入SYN_SENT状态,等待服务器确认:SYN:同步序列编号(Synchronize Sequence Nu ...

  10. 腾讯云 安全组配置及与MySQL 远程登录失败原因浅析

    前言,知道自己腾讯云服务器安全组配置并在安全组里开放了所有端口的用户可以粗略的看看下边的内容,否则就仔细看看吧. 因为有学习及业务需要,我要在腾讯云上安装了CentOS7.2版本的服务器上安装MySQ ...