linux debian怎么重启网卡,在Ubuntu和Debian中重启网络的首选方法是什么
问题描述当我使用以下方法重新启动网络时:/etc/init.d/networking restart我收到此警告:Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces那么,现在进行更改后重新启动网络的最佳方法是什么?该问题也适用于Debian,因为ne
问题描述
当我使用以下方法重新启动网络时:
/etc/init.d/networking restart
我收到此警告:
Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
那么,现在进行更改后重新启动网络的最佳方法是什么?
该问题也适用于Debian,因为netbase软件包是从debian继承的。
最佳思路
只是说重新启动选项不见了
/etc/init.d/networking stop; /etc/init.d/networking start
注意只有一行!通过网络运行网络重新启动时,这一点很重要。
次佳思路
运行不带参数的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 Sun, 06 Dec 2009 17:09:41 +0100
真讨厌要从远程重新启动netwokring,最好的和最安全的方法将在屏幕会话中运行以下命令:
~# /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
第三种思路
我使用nohup sh -c "/etc/init.d/networking stop; sleep 2; /etc/init.d/networking start"。我添加sleep 2是因为我认为重新启动的问题可能与hardware-dependent延迟有关,但这尚未得到证实,semi-rule的经验使我有些羞愧以至于无法公开。因此,如果您感到理性,可以跳过该步骤!
第四种思路
下面的命令在服务器环境中运行良好,不会引发警告。它在网络服务上实现了停止和启动请求。
sudo service networking start
参考资料
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)