在继续之前,有没有办法在bash脚本中检查多个接口的成功网络接口链接?等待网络链接继续之前在bash中
喜欢的东西:
eth0 eth1 eth2 eth3 network interfaces are brought up
Wait for link detection on all 4 interfaces
Proceed
在继续之前,有没有办法在bash脚本中检查多个接口的成功网络接口链接?等待网络链接继续之前在bash中
喜欢的东西:
eth0 eth1 eth2 eth3 network interfaces are brought up
Wait for link detection on all 4 interfaces
Proceed
如果运行ifconfig -s
后的网络接口的名字出现在你可以检查。
喜欢的东西:
if [ $(ifconfig -s | grep eth0) ]; then echo "eth0 is up!"
检查this link了解更多详情。
为了使这个测试正在进行中,你可以做一些像什么@ jm666说:
while ! ping -c 1 -W 1 1.2.3.4; do
echo "Waiting for 1.2.3.4 - network interface might be down..."
sleep 1
done
在一个循环
如果我只想测试一次,这很好,但如果我需要主动等待,直到它联机然后继续,该怎么办? – user1527227
好的,编辑我的答案 –
为什么你在那里有一个'-W'标志?您没有为单个ping指定超时...... – user1527227
尝试1X每第二个ping到一些著名主持人什么是每个网络中,或者检查ifconfig输出... – jm666
如果它们启动,它并不一定意味着其他主机响应ping。 – LtWorf