Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I restart the network using:

/etc/init.d/networking restart

I get this warning:

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

So what's the best way to restart the network after making changes now?

This problem also applies to Debian as the netbase package is inherited from debian.

share|improve this question

5 Answers 5

up vote 11 down vote accepted

It is just saying that the restart option is going away

/etc/init.d/networking stop
/etc/init.d/networking start
share|improve this answer
12  
two commands :-/ bad idea if you are in remote. Better use a one liner: /etc/init.d/networking stop; /etc/init.d/networking start –  hmontoliu May 15 '11 at 16:55
    
@hmontoliu: then again it seems wise to use the deprecated restart since you cannot forget the starting command –  mbx May 15 '11 at 21:53
1  
If you are in remote, you should always use screen –  Avio Mar 21 '13 at 11:09
1  
Screen won't really help if you shut down networking on a remote server. In this case you would have to go search for some sort of direct access, which isn't always convenient. –  kermit666 May 14 at 20:06
    
stop and start are obviously not deprecated but used in combination they have the same potential problem that restart used to have. –  Håkan Lindqvist Aug 21 at 5:55

The command below works well in a server environment, without throwing warnings. It implements both stop and start request on the networking service.

sudo service networking start
share|improve this answer

how about nohup sh -c "ifdown -a && ifup -a"

share|improve this answer

I use nohup sh -c "/etc/init.d/networking stop; sleep 2; /etc/init.d/networking start". I add sleep 2 because I think perhaps the issues with restart had something to do with hardware-dependent latencies, but this is unconfirmed and a semi-rule of thumb I'm somewhat ashamed to make public. So you can skip that if you're feeling rational!

share|improve this answer
    
so basically you're saying I have to alias restart="nohup sh -c /etc/init.d/networking stop; sleep 2; /etc/init.d/networking start" because somebody using Debian, thinks his or her job will be on the line if we actually evolve Linux beyond a hobbiest OS? –  user82971 May 29 '11 at 12:51
1  
Not at all. How zany of you! –  Eduardo Ivanec May 29 '11 at 17:26

Run the init.d command without parameters, it will tell you which is the usage:

~# /etc/init.d/networking 
Usage: /etc/init.d/networking {start|stop}

Seems that restart is deprecated

It is deprecated also in Debian at least since:

netbase (4.38) unstable; urgency=low

  * Create /etc/sysctl.d/bindv6only.conf on upgrades and new installs
    to set net.ipv6.bindv6only=1.
  * Made the init script check for swap over the network. (Closes: #540697)
  * Temporarily depend on initscripts to work around a bug in multistrap.
    (Closes: #556399)
  * etc-services: added sieve (4190/tcp).
  * etc-services: removed sieve (2000/tcp). (Closes: #555664)
  * Made the init script warn that using the force-reload and restart
    parameters is not a good idea. (Closes: #550240)

 -- Marco d'Itri <md@linux.it>  Sun, 06 Dec 2009 17:09:41 +0100

The related bug #550240 here

Which is quite nasty. To restart netwokring from remote probably the best and securest approach will be run the following within a screen session:

~# /etc/init.d/networking stop; /etc/init.d/networking start

As of today's networking init script, restart and force-reload will work in most circumstances. I guess it's reasonably safe to ignore the warning and still use restart. However I'll go with the stop + start way :-)

case "$1" in
start)
    process_options

    log_action_begin_msg "Configuring network interfaces"
    if ifup -a; then
        log_action_end_msg $?
    else
        log_action_end_msg $?
    fi
    ;;

stop)
    check_network_file_systems
    check_network_swap

    log_action_begin_msg "Deconfiguring network interfaces"
    if ifdown -a --exclude=lo; then
        log_action_end_msg $?
    else
        log_action_end_msg $?
    fi
    ;;

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
    ;;

*)
    echo "Usage: /etc/init.d/networking {start|stop}"
    exit 1
    ;;
esac
share|improve this answer
    
Really? Restart is useful when you are working remotely! –  Antonius Bloch May 15 '11 at 16:41
1  
See my edit. I agree that a bullet proof restart would be better than stop + start –  hmontoliu May 15 '11 at 16:53
    
I think it's worth noting that stop + start appears to do the exact same thing that restart would do. It does not appear to be any more safe, other than not using a deprecated option (deprecated specifically to discourage this operation). –  Håkan Lindqvist Aug 21 at 5:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.