Debian: Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
July 18, 2011 6 Comments
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
Thanks for this. I always got worried with that message and wondered what was I supposed to do.
Pingback: Debian – First Step | Rebojo
but if we have ssh connect, do it on screen
thx for information :D
try service networking restart
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).