zoukankan      html  css  js  c++  java
  • 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。

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

  • 相关阅读:
    关于MTK平台CC相关的Log查询
    es5 对象方法
    es5 数组查询案例
    继承 和 es5 新增方法 数组方法
    扩展内置对象
    Js 面向对象 动态添加标签页
    记住用户名 缓存案例 localstorage
    解析好的静态页面.shtml浏览器无法解析.需要apache解析后再返回给浏览器
    开始工作----微信通过get检查当前网站---是否可用
    view视图--display中echo出ob_get_contents的缓冲内容--(实现,拼接好文件--导入文件)
  • 原文地址:https://www.cnblogs.com/siikee/p/4193922.html
Copyright © 2011-2022 走看看