Jump to content

Reboot modem-router from PC


tigerjack

Recommended Posts

A little curiosity.

Sometimes I need to restart my modem-router (wireless connection) to change the IP.
I can do this in two ways:

a- With On\Off button

b- I go to the main page from PC with 192.168.1.1 (login, reboot tab, click on restart, and so on)

However I think you can create a batch file (or something similar) to get the same result and restart the modem-router from PC without having to perform the uncomfortable procedure described in paragraph b.

Any suggestions ?

(Sorry for my english)

thx

 

Link to comment
Share on other sites


  • Replies 33
  • Views 2.9k
  • Created
  • Last Reply

too lazy for "paragraph a"? spent couple of bucks for remote controlled electrical socket ;)

 

Link to comment
Share on other sites


42 minutes ago, gipsy said:

too lazy for "paragraph a"? spent couple of bucks for remote controlled electrical socket ;)

 

I know, I know.......it is not a big deal, it was just a curiosity

Link to comment
Share on other sites


48 minutes ago, Chancer said:

I suggest you look at telnet options for your router.

I think you will be able to do it that way.

 

I read somewhere that you could use the rasdial command and create a batch file ..... two or three rows written with notepad and saved as .bat.

Unfortunately I do not remember where I read it

Link to comment
Share on other sites


1 hour ago, tigerjack said:

I know, I know.......it is not a big deal, it was just a curiosity

 

check

an example for TP-link ,it's in Russian,but sure it's not a big deal this case.
 

Quote

 

#!/bin/sh
WATCHED_IP="8.8.8.8"
ROUTER_IP="192.168.0.1"
USERNAME="login"
PASSWORD="pass"

# watch for remote host
ping -q -c 1 "$WATCHED_IP" > /dev/null    && exit

clear

# exit if modem is down
ping -q -c 1 "$ROUTER_IP" > /dev/null      || exit

curl --basic --user "$USERNAME:$PASSWORD" -A "Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)" --refer "http://$ROUTER_IP" "$ROUTER_IP/userRpm/SysRebootRpm.htm?Reboot=reboot"


 

 

Link to comment
Share on other sites


3 hours ago, Chancer said:

I suggest you look at telnet options for your router.

I think you will be able to do it that way.

 

I love people that open up their routers for remote access, it makes it so easy to break into them.  Router Security Tip #1  NEVER but NEVER allow remote admin access to your router, only physical access from a hard wired connected computer.

Link to comment
Share on other sites


11 hours ago, straycat19 said:

 

I love people that open up their routers for remote access, it makes it so easy to break into them.  Router Security Tip #1  NEVER but NEVER allow remote admin access to your router, only physical access from a hard wired connected computer.

I don't understand your comment.

Telnetting in from your LAN does not open remote access.

Link to comment
Share on other sites


Israeli_Eagle
12 hours ago, straycat19 said:

 

I love people that open up their routers for remote access, it makes it so easy to break into them.  Router Security Tip #1  NEVER but NEVER allow remote admin access to your router, only physical access from a hard wired connected computer.

 

I fully agree, NEVER use WiFi and/or WAN for such!!!

 

And usually a good router ROM (for example DD-WRT) has an option WDS/Connection Watchdog anyway, so reboots automatically if there is a connection problem.

DD-WRT.jpg

Link to comment
Share on other sites


After a day of research and testing, also following your suggestions, I was unable to restart the router with any script.:pos:
I think for now my curiosity will remain so.
I thank you for the time dedicated to me.
But I do not easily give up.

Link to comment
Share on other sites


22 hours ago, gipsy said:

 

check

an example for TP-link ,it's in Russian,but sure it's not a big deal this case.
 

 

 

thank you for this script, i haven't tried it yet but will try it as quick as possible.

could you please tell me what you mean by "Watched IP" ? which ip adress is that ?

Link to comment
Share on other sites


I used to to telnet into a router from Windoze to execute a WoL command:

@ECHO OFF

:: Create SendKeys script
ECHO.set sh=Wscript.CreateObject("Wscript.Shell")>_TEMP.VBS

ECHO.Wscript.Sleep 1000 >>_TEMP.vbs

ECHO.sh.SendKeys "admin" >>_TEMP.VBS
ECHO.sh.SendKeys "{ENTER}" >>_TEMP.vbs

ECHO.sh.SendKeys "your_router_password" >>_TEMP.VBS
ECHO.sh.SendKeys "{ENTER}" >>_TEMP.vbs
ECHO.Wscript.Sleep 1000 >>_TEMP.vbs


ECHO.sh.SendKeys "wol up 0050fc70b6cd" >>_TEMP.VBS
ECHO.sh.SendKeys "{ENTER}" >>_TEMP.vbs
ECHO.Wscript.Sleep 1000 >>_TEMP.vbs

ECHO.sh.SendKeys "quit" >>_TEMP.VBS
ECHO.sh.SendKeys "{ENTER}" >>_TEMP.vbs

:: Open a telnet window - it will be the window with focus
start /I telnet.EXE your_router_LAN_IP 23


:: Run the script to send keys to telnet window
cscript//nologo _TEMP.VBS

:: Clear away workfile
DEL _TEMP.VBS

EXIT 

Essentially the batch file writes a VBScript file which opens a telnet session and sends key strokes to it, then runs the script. There are lots of waits in it to stop the keys being sent too quickly and I erred on the side of caution when setting the delays. I claim no originality for it as I found it years ago on the internet and modified it for my purposes.

 

You cannot directly script a telnet session in Windoze, although there is a programme somewhere on the www which lets you script it.

Link to comment
Share on other sites


3 hours ago, mehdibleu said:

 

thank you for this script, i haven't tried it yet but will try it as quick as possible.

could you please tell me what you mean by "Watched IP" ? which ip adress is that ?

It is a known internet ip address  in the case of 8.8.8.8 thats a google dns url

it is just a test if you are online or not

 

 

Link to comment
Share on other sites


4 hours ago, mehdibleu said:

thank you for this script, i haven't tried it yet but will try it as quick as possible.

could you please tell me what you mean by "Watched IP" ? which ip adress is that ?

it isn't mine,it's just a quote from source i gave.

 

Link to comment
Share on other sites


  • Administrator

One thing I must mention though, you did not mention your router and it's model here.

Link to comment
Share on other sites


Some considerations:
we all know how to restart a router in two simple ways described everywhere (switch or URL). It is a different story to find ready-made scripts to perform the same operation by PC, there are too many variables starting with the router model, its firmware, Telnet, Java, firewall and so on. However, I wondered whether there are programs that log our actions and write result in a batch file or vbs or otherwise. I came to know of software like Action(s) for example and/or similar that could possibly solve this and other problems. This way everyone can create their own files tailored without being dependent on others. The only difficulty lies in knowing how to use these programs. I'm no expert but someone may try !!!
And if it succeeds, and will share his experience will be welcome.
 

Link to comment
Share on other sites


Can be accomplished in few simple steps

 

Step 1

Turn on Telnet service in windows

Go to control panel, 'programs and features' > 'turn windows features on or off' > mark 'telnet client' > ok, apply

 

Step 2

Save the below line in a .vbs file (paste the code in a notepad, file>save as, type filename.vbs)

Note: change YOUR PASSWORD in line 8, ~ is required after the password characters

 

Quote

Option explicit
Dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
oShell.Run "telnet"
WScript.Sleep 1000
oShell.Sendkeys "open 192.168.1.1~"
WScript.Sleep 1000
oShell.Sendkeys "YOUR PASSWORD~"
WScript.Sleep 1000
oShell.Sendkeys "sys reboot~"
WScript.Sleep 1000
Wscript.Quit
oShell.Sendkeys "q~"

 

Let me know if any errors..(if username is required to include, etc)

change 1000 to 3000 for 3 sec delay between inputs

The cmd prompt session will not closes always

 

Step 3

Double click the .vbs file

Note: do not click on any other window after clicking the file

wait for the pass of 'sys reboot' cmd

 

Let me know if it worked for you

Happy rebooting

It a good idea to delete the sandboxie session and reboot your modem before and after vpn and naughty things :D

 

Link to comment
Share on other sites


36 minutes ago, rahulgi said:

Option explicit
Dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
oShell.Run "telnet"
WScript.Sleep 1000
oShell.Sendkeys "open 192.168.1.1~"
WScript.Sleep 1000
oShell.Sendkeys "YOUR PASSWORD~"
WScript.Sleep 1000
oShell.Sendkeys "sys reboot~"
WScript.Sleep 1000
Wscript.Quit
oShell.Sendkeys "q~"

 

already tried (downloaded from other blog) , not work

to my router I access with user and password (not only password)  :whistle:

Link to comment
Share on other sites


Hi tigerjack..

What was the error message on running the script

 

@to my router I access with user and password (not only password)  :whistle:

we all do like that, but not when connecting via telnet

 

is there an option to change the username in your router configuration

if yes, try resetting it or change it to admin

if you are getting an error username reserved.. then the script should work just fine

 

also make sure telnet access via LAN/WLAN is allowed in router (probably under access restriction)

 

share your model number or product description page

Link to comment
Share on other sites


Better follow @gipsy advise

On ‎1‎/‎19‎/‎2017 at 1:22 AM, tigerjack said:

spent couple of bucks for remote controlled electrical socket ;)

 

or simply restart your network connections with no spent at all ... but same result  ;)

Link to comment
Share on other sites


2 hours ago, Dukun Cabul said:

Better follow @gipsy advise

On ‎18‎/‎01‎/‎2017 at 7:22 PM, tigerjack said:

spent couple of bucks for remote controlled electrical socket ;)

 

or simply restart your network connections with no spent at all ... but same result  ;)

 

 you're right and that's what I usually do but then again, the new method was only a curiosity

Link to comment
Share on other sites


3 hours ago, rahulgi said:

Hi tigerjack..

What was the error message on running the script

Hi rahulgi,

take a look here http://www.howtogeek.com/206620/how-to-automatically-reboot-your-router-the-geeky-way/  and the script

 

Option explicit
Dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
oShell.Run "telnet"
WScript.Sleep 3000
oShell.Sendkeys "open 192.168.1.1~"
WScript.Sleep 3000
oShell.Sendkeys "admin~"
WScript.Sleep 3000
oShell.Sendkeys "mypassword~"
WScript.Sleep 3000
oShell.Sendkeys "system reboot~"
WScript.Sleep 3000
oShell.Sendkeys "~"
Wscript.Quit

 

it seems very similar to yours with the variant "admin", and that's what I tried without success.

My router

tp1a.pngtp3a.pngtp4a.pngtp5a.png

 

Link to comment
Share on other sites


18 hours ago, tigerjack said:

 

 you're right and that's what I usually do but then again, the new method was only a curiosity

 

Try AutoIt

This script for TP-LINK TL-WR1043ND only, you must mod the script according to your modem/router !

 

Spoiler

 

#include <IE.au3>
_IECreate("http://192.168.0.1")
WinWaitActive("TL-WR1043ND - Internet Explorer")
Sleep(1000)
Send("Username{Enter}")
Sleep(1000)
Send("Password{Enter}")
WinWaitActive("TL-WR1043ND - Internet Explorer", "userRpm/Index.htm")
Sleep(1000)
Send("{Tab 23}")
Sleep(1000)
Send("{Enter}")
Sleep(1000)
Send("{Tab 6}")
Sleep(1000)
Send("{Enter}")
Sleep(1000)
Send("{Tab 29}")
Sleep(1000)
Send("{Enter}")
WinWaitActive("Message from webpage", "Are you sure you want to reboot this device?")
Sleep(1000)
Send("{Enter}")
Exit
 
NOTE:
Username = your own Username for login to your Modem/Router
Password = your Password for login to your Modem/Router
Send("{Tab XX}") = the amount/number of tabs you need to hit/press to navigate to the tab/button/menu that you want to click/press.
Sleep(XXX) = delay operation, 1000 = 1 second, 2000 = 2 seconds, and so on.

 

 

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...