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

About these ads

6 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).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 26 other followers

%d bloggers like this: