Automatically restart card

Automatically restart card (NIC unstable, often dropped)

As shown in the code above, if the ping times can not
pass an IP address (here use the LAN gateway), restart the card, then sleep for 10 seconds and then repeat.

Create a sh file: restart_net.sh

while true; do
    ping -c 3 192.168.0.193;
    if [ $? -ne 0 ]; then
        ifup eth0;
    fi
    sleep 10;
done

carried out

/bin/bash  restart_net.sh 2>&1 > /root/shell/log/restart_net.log &

View Log: tail -f /root/shell/log/restart_net.log

 

Published 263 original articles · won praise 46 · views 370 000 +

Guess you like

Origin blog.csdn.net/qq_27229113/article/details/103458777