Tech Support > Computer Hardware > Modems > Check connection & auto renew IP on a Linksys BEFSX41 - how to
Check connection & auto renew IP on a Linksys BEFSX41 - how to
Posted by Jonathan Higbee on November 9th, 2003



Recently my broadband ISP has been creating a bit of a
problem for me. In order for me to stay online, sometimes
their system requires a DHCP release & renew before the
lease time is up for a given dynamic IP I've gotten from
them. To resolve this problem in the past with my Linksys
BEFSX41 router I have had to manually release & renew the IP
address (on the Status tab). However I just found a way to
work around this problem with the use of a batch file I
wrote.

Title: How to detect a loss of connection to a broadband
type ISP using a batch file on MS Windows, and if the
connection is lost, how to get the connection back up via
releasing & renewing the leased IP address from your ISP.
For use with the BEFSX41 Linksys router - but may be
applicable to other models.

Step 1. Obtain the free programs curl & sleep, such as via
downloading & installing the free linux-like environment for
MS Windows called Cygwin (www.cygwin.com).

Step 2. On the BEFSX41 router disable the password prompt to
gain administrative access to it. To do this go the password
tab of the router control and set the password to nothing
(blank). Since you're taking this action you may also want
to also ensure that remote control for the router is turned
off (under the Firewall tab ensure that "Remote Management"
is turned off).

Step 3: Create a batch file called test_connection.bat which
contains the lines listed after "step 4."

Step 4: Simply run the batch file in a minimized command
prompt window when you want your computer to stay connected.
You run the batch file in a regular MS Windows command line
window.

The contents of test_connection.bat follows:

REM test_connection.bat - by Jonathan Higbee - jhXXXX at
cyberspace dot org where XXXX = the current year.
REM Prerequisites: Get a W2K command line version of "sleep"
and "curl,"
REM such as via installing the free cygwin (www.cygwin.com).
REM Ensure that wherever curl and sleep are on your system
are in
REM the PATH environment variable
REM This batch file does not need to be run under cygwin -
it's intended
REM to be run just under regular Windows (most likely W2K or
NT or XP, but
REM it may work in other versions.
REM This batch file is intended for use with the Linksys
BEFSX41 router
REM with the admin password prompt turned off. To turn off
the password
REM prompt on the BEFSX41 just go to the password tab for
the router control
REM and set the password to be nothing (blank).
REM
REM The purpose of this batch file is this: Sometimes
broadband ISPs will have their system set up so that in
order to continue
REM working online they require that you release & renew the
dynamic IP
REM you have leased from them. Some routers don't
automatically detect
REM the loss of connection. The BEFSX41 currently does not.
But if you
REM have this batch file running on your system during the
day while you're
REM at work then you can keep your system online while
you're away.
REM
REM Usage: test_connection site.to.ping
REM
REM Example:
REM
REM test_connection www.yahoo.com
REM

:loop

REM wait 3 minutes before checking the connection again
after looping

sleep 180

:loop_after_sleep

REM sometimes several pings are required to get the link
going after an IP release and renew

ping -n 1 %1 2>&1 | findstr /C:"Reply from" >nul 2>&1

if %errorlevel%==0 goto loop

ping -n 1 %1 2>&1 | findstr /C:"Reply from" >nul 2>&1

if %errorlevel%==0 goto loop

ping -n 1 %1 2>&1 | findstr /C:"Reply from" >nul 2>&1

if %errorlevel%==0 goto loop

ping -n 1 %1 2>&1 | findstr /C:"Reply from" >nul 2>&1

if %errorlevel%==0 goto loop

REM use the cygwin included (or equivalent) curl command to
cause the BEFSX41 router to release the IP leased to it

curl http://192.168.1.1/Gozila.cgi?dhcpAction=0

sleep 30

REM use the cygwin included (or equivalent) curl command to
cause the BEFSX41 router to renew the IP lease
REM or to get a new IP if that's what the ISP's system wants
to do

curl http://192.168.1.1/Gozila.cgi?dhcpAction=1

sleep 30

goto loop_after_sleep

REM end of test_connection.bat



Similar Posts