Debian: Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces

Have you run /etc/init.d/networking restart on a recent Debian? Or maybe you ran invoke-rc.d networking restart? Then you have seen this warning: Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces. It was reported to folks at Debian (#565187 netbase: Command deprecated and not explained) and a response was “That is not the place for documentation. There is not a good solution either.” Even though there is no good solution, there must at least be one solution, right? So the solution is to manually stop and start each interface (say, using ifdown eth0 and then ifup eth0). But some things to consider are:

(1) If you are SSH’ed into interface eth0, if you do an ifdown eth0, you lose connectivity. One thing I tested in a VirtualBox Debian virtual machine (VM) is the following command and my connection didn’t break. But before you do anything on a production system, test this out properly.

su -
ifdown eth0 && ifup eth0

Or if you have sudo privileges, then only

sudo ifdown eth0 && sudo ifup eth0

An even better method may be below, adapted from the suggestion of Eduardo Ivanec. I tried it out over an SSH session and it worked well. Since there’s no visible output, whatever output the command generates is appended to nohup.out file in the same directory as where you ran this command. This is the only log you have of what actually happened and if it shows the right messages, it means networking was restarted successfully.

su -
nohup sh -c "ifdown eth0 && ifup eth0"

If you have sudo privileges, you can do the following. But the nohup.out log file created is owned by root.

sudo nohup sh -c "ifdown eth0 && ifup eth0"

(2) If you have multiple interfaces, you need to ifdown/ifup all of them one by one. I don’t have an easier way to manage this, while keeping true to the philosophy that Debian has adopted: “Now devices come online when they are plugged in and go offline when they are disconnected. Everything has been rewritten to be event driven.” (source: Re: Restarting Networking in Debian; this is not official wording, just interpretation by one person). But you could try something like the following (again, I have only tested it in a VM):

su -
invoke-rc.d networking stop && invoke-rc.d networking start

Or if you have sudo privileges, then only

sudo invoke-rc.d networking stop && sudo invoke-rc.d networking start

Continuing our adaptation of Eduardo Ivanec’s suggestion, you can do the following instead:

su -
nohup sh -c "invoke-rc.d networking stop; sleep 2; invoke-rc.d networking start"

If you have sudo privileges, you can do the following. But the nohup.out log file created is owned by root.

sudo nohup sh -c "invoke-rc.d networking stop; sleep 2; invoke-rc.d networking start"

Since it’s tough to remember and type such a long command every time, you may want to add the following to your .bash_aliases file. It acts as a good log with dates and times.

alias netrestart="sudo nohup sh -c 'invoke-rc.d networking stop; date; echo sleeping; sleep 2; echo waking; date; invoke-rc.d networking start'"

Further Reading

Restarting Networking in Debian; What is the preferred method to restart networking in Ubuntu and Debian

15 Responses to Debian: Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces

  1. Anonymous says:

    Thanks for this. I always got worried with that message and wondered what was I supposed to do.

  2. Pingback: Debian – First Step | Rebojo

  3. rich says:

    but if we have ssh connect, do it on screen

  4. dibia nak bali says:

    thx for information :D

  5. Anonymous says:

    try service networking restart

  6. Anonymous says:

    that’s does the same:
    root@home:~# service networking restart
    Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces … (warning).

  7. Pingback: bind server: Trailing Dot Required For localhost, but no clients

  8. Tony A. says:

    post-up ifup eth2
    post-up ifup eth3

    I just added those lines to the bottom of my eth1 declaration in /etc/network/interfaces on debian wheezy and verified it does what I want – namely bring up eth0, eth1, eth2, and eth3 everytime I restart networking either by /etc/init.d/networking restart -or- service networking restart.

  9. For ifdown and ifup on “ALL DEVICES” do this:

    First I suggest getting information (ie manual command)
    man man <— gets the manual for the man command
    man ifdown <— gets the ifdown manual
    man ifup <— gets the ifup manual

    Now that you know what your doing run this command:

    sudo ifdown eth0 -a && ifup eth0 -a

  10. My bad here’s what should have been posted:

    sudo ifdown -a && sudo ifup -a

    and

    sudo nohup sh -c “ifdown -a && ifup -a”

  11. Ian says:

    Thanks for the info – I thought I stuffed up an install somehow..

  12. Ian says:

    I have added ‘auto eth0’ to /etc/network/interfaces and now restart seems to work

    If this helps anyone..

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    auto eth0
    allow-hotplug eth0
    iface eth0 inet static
    address 192.168.0.245
    gateway 192.168.0.1
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255

    dns-nameservers 8.8.8.8 8.8.4.4

  13. Pingback: Zettabyte » Homeserver

  14. Anonymous says:

    tnks!

  15. heidayu7 says:

    Thank you very much :D