在继续之前,有没有办法在 bash 脚本中检查多个接口的网络接口链接是否成功?
就像是:
eth0 eth1 eth2 eth3 network interfaces are brought up
Wait for link detection on all 4 interfaces
Proceed
在继续之前,有没有办法在 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!"
检查此链接以获取更多详细信息。
要进行此测试,您可以执行@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