I'm using a gl.inet mt1300 router as travelrouter. It has is own fork of OpenWrt so please bear with me a bit..
( OpenWrt 19.07.7, r11306-c4a6851c72)
(I didn't go to Openwrt snapshot because of the wifidrivers not working properly)
The router has a blue and a white led, this (I think) script below makes the led blink blue when there is no internet connection en solid white when there is. As far as I can see, it does this by using ping.
I want to alter the script so it doesn't only check if it can ping, but when it can ping AND it goes through tun0 then the led must be set to white_breath so I can see visualy it's connected to vpn.
So if it pings when tun0 is down, it does what the script does at this moment and when tun0 is up it changes the led status, and back when tun0 goes down again.
When I ping with vpn on:
root@GL-MT1300:/usr/bin# ping -I tun0 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: seq=0 ttl=59 time=19.911 ms
64 bytes from 1.1.1.1: seq=1 ttl=59 time=44.984 ms
When I ping with vpn off:
`root@GL-MT1300:/usr/bin# ping -I tun0 1.1.1.1
ping: bad address 'tun0'
The script that I want to edit;
#!/bin/sh
status="0"
count=`uci get mwan3.wan.count 2>/dev/null`
timeout=`uci get mwan3.wan.timeout 2>/dev/null`
track_ip=`uci get mwan3.wan.track_ip 2>/dev/null`
[ -z "$count" ] && count="1"
[ -z "$timeout" ] && timeout="2"
[ -z "$track_ip" ] && track_ip="1.1.1.1 1.0.0.1"
mt1300_led off
mt1300_led blue_breath daemon
for ip in $track_ip;
do
ping -c $count -W $timeout -q $ip 1>/dev/null
ret=`echo $?`
if [ "$ret" = "0" ];then
status="1"
break
fi
done
while true
do
if [ "$status" = "0" ];then
mt1300_led blue_breath daemon
else
mt1300_led white daemon
fi
sleep 5
#mwan3 will not be used in the AP/WDS mode
mode=`uci -q get glconfig.bridge.mode`
if [ "$mode" = "ap" -o "$mode" = "wds" ];then
[ "$status" = 1 ] && sleep 10
for ip in $track_ip;
do
ping -c $count -W $timeout -q $ip 1>/dev/null
ret=`echo $?`
if [ "$ret" = "0" ];then
status="1"
break
else
status="0"
fi
done
continue
fi
if [ "$status" = "0" ];then
interface=`get_wan_interface`
if [ -z "$interface" ];then
continue
fi
for ip in $track_ip;
do
ping -c $count -W $timeout -q $ip 1>/dev/null
ret=`echo $?`
if [ "$ret" = "0" ];then
status="1"
break
fi
done
else
interface=`get_wan_interface`
if [ -z "$interface" ];then
status="0"
continue
fi
mwan3_status=`mwan3 policies | grep "Current ipv4 policies:" -A 2 | tail -n 1 | sed 's/ //g' 2>/dev/null`
if [ "$mwan3_status" = "default" ];then
for ip in $track_ip;
do
ping -c $count -W $timeout -q $ip 1>/dev/null
ret=`echo $?`
if [ "$ret" = "0" ];then
status="1"
break
else
status="0"
fi
done
continue
fi
mwan3_interface=`echo $mwan3_status | awk -F \( '{print $1}' 2>/dev/null`
check=`echo $interface | grep $mwan3_interface 2>/dev/null`
if [ -z "$check" ];then
for ip in $track_ip;
do
ping -c $count -W $timeout -q $ip 1>/dev/null
ret=`echo $?`
if [ "$ret" = "0" ];then
status="1"
break
else
status="0"
fi
done
fi
fi
done