It works like a charm.... if nothing wrong happens... (Phone restart, USB cable disconnection/reconnection, etc).
From the wiki guide, I thing that those 2 commands must be rerun in order to reconnect tethering if a disconnection has occured:
ifconfig usb0 up
udhcpc -i usb0
How is it possible to run those ones automatically in case of a connection failure?
For now, as a workaround, I just set the Watchdog to ping the phone's tether gateway address each 30 minutes, but I want a solution that doesn't require a reboot of the router each time.
Joined: 18 Mar 2014 Posts: 12884 Location: Netherlands
Posted: Mon Feb 06, 2023 14:08 Post subject:
There are watch dog scripts which are loaded from startup and then run continuously, pinging every x seconds and if it detects a connection loss it will execute your commands
Joined: 18 Mar 2014 Posts: 12884 Location: Netherlands
Posted: Mon Feb 06, 2023 14:37 Post subject:
To give you a head start something like this, Administration/Commands and Save as Startup
Code:
#=======BEGIN tether-watchdog=========
sleep 60
SCRIPT="/tmp/tether-watchdog.sh"
cat << "EOF" > $SCRIPT
#!/bin/sh
(
SLEEP=120 # time (in secs) between each pass, do not set lower than 120 this gives you the ability to login and remove script from startup
#DEBUG= # uncomment/comment to enable/disable debug mode
PINGIP="8.8.8.8" # Target IP to ping to
[ ${DEBUG+x} ] && set -x
logger "Start $(basename $0)"
while sleep $SLEEP; do
logger "sleep $SLEEP $(basename $0)"
TUN=$(get_wanface)
while ! ping -qc1 -W6 -n $PINGIP -I $TUN &> /dev/null; do
sleep 9
if ! ping -qc1 -W6 -n $PINGIP -I $TUN &> /dev/null; then
logger "$(basename $0) $TUN down, Restart will be executed"
ifconfig usb0 up
udhcpc -i usb0
break
fi
done
done
)2>&1 | logger -t $(basename $0)[$$]
EOF
chmod +x $SCRIPT
$SCRIPT > /dev/null 2>&1 &
#=======END tether-watchdog=========
To give you a head start something like this, Administration/Commands and Save as Startup
Code:
#=======BEGIN tether-watchdog=========
sleep 60
SCRIPT="/tmp/tether-watchdog.sh"
cat << "EOF" > $SCRIPT
#!/bin/sh
(
SLEEP=120 # time (in secs) between each pass, do not set lower than 120 this gives you the ability to login and remove script from startup
#DEBUG= # uncomment/comment to enable/disable debug mode
PINGIP="8.8.8.8" # Target IP to ping to
[ ${DEBUG+x} ] && set -x
logger "Start $(basename $0)"
while sleep $SLEEP; do
logger "sleep $SLEEP $(basename $0)"
TUN=$(get_wanface)
while ! ping -qc1 -W6 -n $PINGIP -I $TUN &> /dev/null; do
sleep 9
if ! ping -qc1 -W6 -n $PINGIP -I $TUN &> /dev/null; then
logger "$(basename $0) $TUN down, Restart will be executed"
ifconfig usb0 up
udhcpc -i usb0
break
fi
done
done
)2>&1 | logger -t $(basename $0)[$$]
EOF
chmod +x $SCRIPT
$SCRIPT > /dev/null 2>&1 &
#=======END tether-watchdog=========
Thanks a lot egc, it works like a charm.
I just changed the ping ip by the phone's tethering gateway ip since I want to monitor the connection between the router and the phone, not the Internet.
To give you a head start something like this, Administration/Commands and Save as Startup
Code:
#=======BEGIN tether-watchdog=========
sleep 60
SCRIPT="/tmp/tether-watchdog.sh"
cat << "EOF" > $SCRIPT
#!/bin/sh
(
SLEEP=120 # time (in secs) between each pass, do not set lower than 120 this gives you the ability to login and remove script from startup
#DEBUG= # uncomment/comment to enable/disable debug mode
PINGIP="8.8.8.8" # Target IP to ping to
[ ${DEBUG+x} ] && set -x
logger "Start $(basename $0)"
while sleep $SLEEP; do
logger "sleep $SLEEP $(basename $0)"
TUN=$(get_wanface)
while ! ping -qc1 -W6 -n $PINGIP -I $TUN &> /dev/null; do
sleep 9
if ! ping -qc1 -W6 -n $PINGIP -I $TUN &> /dev/null; then
logger "$(basename $0) $TUN down, Restart will be executed"
ifconfig usb0 up
udhcpc -i usb0
break
fi
done
done
)2>&1 | logger -t $(basename $0)[$$]
EOF
chmod +x $SCRIPT
$SCRIPT > /dev/null 2>&1 &
#=======END tether-watchdog=========
Thanks a lot egc, it works like a charm.
I just changed the ping ip by the phone's tethering gateway ip since I want to monitor the connection between the router and the phone, not the Internet.
Finally, the connection seems to drop and coming back each 120 seconds. The IP address to ping is good so I don't know what is going on.
Where can I see the debug output from the router's webpage (if possible)? Do I need to go through SSH?
Joined: 21 Aug 2019 Posts: 120 Location: Here, There And Everywhere
Posted: Sun Feb 12, 2023 12:13 Post subject:
@frankd84
Which router are you using that has support for Android tethering? As discussed in another thread, quote, "Option has not been added to date on any device that I'm aware of".
@frankd84
Which router are you using that has support for Android tethering? As discussed in another thread, quote, "Option has not been added to date on any device that I'm aware of".
Joined: 21 Aug 2019 Posts: 120 Location: Here, There And Everywhere
Posted: Mon Feb 13, 2023 8:07 Post subject:
@frankd84 Thanks for clarification. I couldn't find the modules from the guide in any Atheros-based router that I have, but they do exist in Linksys WRT1200, which is, as is your WRT1900, Marvell-based. Maybe this thread should be moved to Marvell forum.
... but they do exist in Linksys WRT1200, which is, as is your WRT1900, Marvell-based. Maybe this thread should be moved to Marvell forum.
Originally, this thread was started in Advanced Network but was moved by someone else here. However, I didn't mention the router model on this post before... so my bad
Mod note 04.06.24: Topic moved to Marvell (for now), should've been left in Advanced Networking. -kp69