Posted: Sun Nov 26, 2017 3:46 Post subject: Help with a script to renew DHCP when connection disconnects
Hello!
I've been having some random (not random see next page) connection disconnects for a while and now it's getting pretty irritating. I disconnect randomly 1-3 times a day and every time i have to go to my router's WAN page and click DHCP Renew and boom connection is backup as soon as i press it.
Is there a setting/script that can do this automatically with little downtime as possible?
I found this in the wiki but not sure if this is fine just as it is? or would i need to edit something?
ME=`basename $0`
RUNNING=`ps | awk '/'"$ME"'/ {++x}; END {print x+0}'`
if [ "$RUNNING" -gt 3 ]; then
echo "Another instance of \"$ME\" is running"
exit 1
fi
if [ "$RET" -ne "$PACKETS" ]; then
echo "Ping failed, releasing IP address on $IFACE"
#send a RELEASE signal
kill -USR2 `cat /var/run/udhcpc.pid` 2> /dev/null
#ensure udhcpc is not running
killall udhcpc 2> /dev/null
echo "Renewing IP address: $IFACE"
$UDHCPC
echo "Waiting 10 s..."
sleep 10
else
echo "Network is up via $TARGET"
fi
done
Edit: i went ahead and ran the script (dunno if i did it right) and rebooted, resulted in no given wan ip(0.0.0.0) so i had no internet, i should note i'm using my router to connect to a wifi hotspot (wireless client mode)
no modem is being used.
Would love some help editing the original script to work on my router.
here are some maybe useful commands.
Would be more inclined to upate the firmware to the latest release and see if that fixes the disconnect problem. New Broadcom drivers have been added since your firmware was released.
I'll give that a go, thanks.
just always assumed it wasn't a firmware issue, had the same problem with a tomato firmware, but worse! and an older dd-wrt version if i remember correctly.
edit: updated to DD-WRT v3.0-r33492 big (10/10/17)
will report back if it still happens. _________________ Asus RT-N66U
if this helps this is what syslog showed at the time of disconnect, again Renewing dhcp insta-fixed it.
Code:
Nov 30 03:10:03 DD-WRT user.warn igmpproxy[1826]: The origin for route 239.255.255.250 changed from 192.168.10.107 to 192.168.10.244
Nov 30 03:15:53 DD-WRT user.warn igmpproxy[1826]: The origin for route 239.255.255.250 changed from 192.168.10.244 to 192.168.10.197
Nov 30 03:28:35 DD-WRT user.warn igmpproxy[1826]: The origin for route 239.255.255.250 changed from 192.168.10.197 to 192.168.10.196
Nov 30 04:59:06 DD-WRT user.debug : ttraff: data for 29-11-2017 commited to nvram
Nov 30 21:46:32 DD-WRT user.warn igmpproxy[1826]: The origin for route 239.255.255.250 changed from 192.168.10.196 to 192.168.10.166
Dec 1 03:11:50 DD-WRT user.warn igmpproxy[1826]: select() failure; Errno(4): Interrupted system call
Dec 1 03:12:00 DD-WRT user.info : Maybe igmprt had died, we need to re-exec it
Dec 1 03:12:00 DD-WRT user.info : igmprt : multicast daemon successfully started
I've had issues to with the WAN IP not renewing or updating if the modem was reset by the ISP because of maintenance and I found these commands to work.
I use a Con Job to run this script every 5min....
Code:
#!/bin/sh
PACKETS=1 # Check for Packet Reveived
HOST1='8.8.4.4' # Ping this Server
TARGET=`ip route | awk '/default via/ {print $3}'`
# ---CHECK WAN---
if [ "$TARGET" = "0.0.0.0" ]; then
logger "WAN has a GW IP $TARGET, Resetting WAN."
killall -SIGUSR2 udhcpc # Release WAN IP
sleep 5
killall -SIGUSR1 udhcpc # Renew WAN IP
exit 0
fi
if [ "$TARGET" = "" ]; then
logger "WAN has a Blank GW IP, Resetting WAN."
killall -SIGUSR2 udhcpc # Release WAN IP
sleep 5
killall -SIGUSR1 udhcpc # Renew WAN IP
exit 0
fi
RET1=`ping -I vlan2 -c $PACKETS $HOST1 2> /dev/null | awk '/packets received/ {print $4}'`
sleep 2
if [ "$RET1" != "$PACKETS" ]; then
logger "Ping Failed, Resetting WAN."
killall -SIGUSR2 udhcpc # Release WAN IP
sleep 5
killall -SIGUSR1 udhcpc # Renew WAN IP
exit 0
fi
exit 0
_________________ Home Network on Telus 1Gb PureFibre - 10GbE Copper Backbone
2x R7800 - Gateway & WiFi & 3xWireGuard - DDWRT r53562 Std k4.9
Off Site 1
R7000 - Gateway & WiFi & WireGuard - DDWRT r54517 Std
E3000 - Station Bridge - DDWRT r49626 Mega K4.4
Off Site 2
R7000 - Gateway & WiFi - DDWRT r54517 Std
E2000 - Wired ISP IPTV PVR Blocker - DDWRT r35531
I've had issues to with the WAN IP not renewing or updating if the modem was reset by the ISP because of maintenance and I found these commands to work.
I use a Con Job to run this script every 5min....
[/code]
Question though, does this ping (8.8.4.4) every 5 minutes to check if my connection is down? so if my connection drops a minute after the check i have to wait ~4 minutes for it to renew it?
I'm Looking for something to constantly(reasonably) ping so i have the least amount of downtime possible.
thanks for the help! _________________ Asus RT-N66U
I need a solution to renew it as soon as the connection drops so i don't get booted out of game.
You can have cron run the script every second if you want. But then you need to have the script check that another instance of it isn't already running.
Do you have this issue if you connect the modem directly to a PC? _________________ --------------------------------------------------
VLANs, port trunking, virtual SSID (Guest)
DNSmasq, NTP, syslog, nflow
Hub and spoke, multi-site, routed VPN (OpenVPN client), split tunnel
1 DNS zone per site, forward, reverse look-up across all sites
Asus RT-AC68U rev A2 DD-WRT v3.0-r48138 std (01/17/22)
Asus RT-AC68U rev C1 DD-WRT v3.0-r48138 std (01/17/22)
Asus RT-AC1900P DD-WRT v3.0-r48138 std (01/17/22)
Asus RT-AC1900P DD-WRT v3.0-r48138 std (01/17/22)
Netgear R7000 DD-WRT v3.0-r48138 std (01/17/22)
Linksys E2000 DD-WRT v3.0-r33492 mega (10/10/17)
Do you have this issue if you connect the modem directly to a PC?
I'm connected to an Xfinitywifi hotspot no modem being used, just the router and lan to pc.
Quubee wrote:
You can have cron run the script every second if you want. But then you need to have the script check that another instance of it isn't already running.
I have no clue how to do those would need some help _________________ Asus RT-N66U
On a sidenote is there a way i can DHCP-Renew on a press of a button without having the dd-wrt page open? would still prefer some kind of script but i have no clue on how to run those properly. _________________ Asus RT-N66U
Joined: 10 Jan 2015 Posts: 270 Location: Minnesota
Posted: Wed Dec 20, 2017 18:20 Post subject:
t0t0fe0 wrote:
I'm connected to an Xfinitywifi hotspot no modem being used, just the router and lan to pc.
How did you go about connecting your router to an xfinitywifi hotspot? by wifi repeater/ client bridge mode?
More generally, where are you that requires you to use the xfinitywifi hotspot and not a modem hooked up to the router for internet access?
t0t0fe0 wrote:
I need a solution to renew it as soon as the connection drops so i don't get booted out of game.
The xfinitywifi hotspots usually are timed access and you need to re-login every so often since anyone in public with a cable account can use them... This is probably the reason for your disconnection issue and is not an ideal way to get internet access. _________________ LATEST DD-WRT FW IS LOCATED HERE: https://dd-wrt.com/support/other-downloads/?path=betas%2F