当我使用以下命令重新启动网络时:
/etc/init.d/networking restart
我收到此警告:
Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
那么现在进行更改后重新启动网络的最佳方法是什么?
该问题也适用于 Debian,因为 netbase 包是从 debian 继承的。
答案1
这只是说重启选项将消失
/etc/init.d/networking stop; /etc/init.d/networking start
注意只有一行!当通过网络运行网络重启时,这很重要。
答案2
运行不带参数的 init.d 命令,它会告诉你用法是哪一个:
~# /etc/init.d/networking
Usage: /etc/init.d/networking {start|stop}
似乎重启已被弃用
它在 Debian 中也至少从以下版本开始被弃用:
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 <[email protected]> Sun, 06 Dec 2009 17:09:41 +0100
这很讨厌。要从远程重启网络,最好的和最安全的方法可能是在屏幕会话:
~# /etc/init.d/networking stop; /etc/init.d/networking start
从今天的networking
初始化脚本开始,restart
将force-reload
起作用多数情况情况。我认为忽略警告并继续使用重启是相当安全的。不过我会采用停止 + 启动的方式 :-)
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
答案3
我使用nohup sh -c "/etc/init.d/networking stop; sleep 2; /etc/init.d/networking start"
。我之所以添加,sleep 2
是因为我认为重启问题可能与硬件相关的延迟有关,但这尚未得到证实,而且是一个半经验法则,我有点羞于公开。所以如果你感觉理性的话,你可以跳过它!
答案4
怎么样nohup sh -c "ifdown -a && ifup -a"