admin 发表于 2021-7-17 17:15:46

Wifi断线自动连接


while :
do
        gateway=$(route -n | grep wlan0 | grep UG | awk '{print $2}')
        if [ -z $gateway ];
        then
                echo "the gateway is null, wlan0 connecting..."
                nmcli conn up MySSID
        else
                ping -c 3 -I wlan0 -s 8 $gateway >/dev/null 2>&1
                if [ $? = 0 ];
                then
                        echo "wifi is connected"
                else
                        echo "wlan0 connecting..."
                        nmcli conn up MySSID
                fi
        fi
   
        sleep 150
done
页: [1]
查看完整版本: Wifi断线自动连接