ISP Router commands

Tags: #<Tag:0x00007fc417eda3e0>

Dear all,

Every so often, I need to restart my ISP router. Currently, I type in the IP address, User/PW and then push a button on the console. Is there a way that I can do this via home assistant ?

Here is the login screen
image

The URL goes from http://XX.YY.ZZ.UU/ to http://XX.YY.ZZ.UU/config.html

Here you see the button on the console

image
This results in the following confirmation message

image

This is the command that is been generated after pushing the button is

http://192.168.1.1/rebootinfo.cgi?sessionKey=312429842

and message

Anyone did something similar ?

Regards,
Jens

You don’t need to mask internal IPs.
And you forgot to do it in the code block anyways.

What happens if you pull the plug? Is that good enough as a reboot?
In that case a Zigbee plug could work for you.
Far easier than trying to build that thing.

Hello,

You are right about the hiding. Pull the plug works, but it is mostly to be able to control remotely. I used a zigbee plug (which doesn’t work that well, could replace it). However, remote control won’t work besides if using a script. Finally, a reboot via the console takes less time. But if I don’t find a way to do this, I’ll need to refer back to previous solution.

Regards,
Jens

Usually, such routers can be accessed via ssh or even telnet, which makes rebooting task much easier.

Hello Igor,

I’ve been looking at this but it looks like you can’t access it via Telnet nor SSH, unfortunately. Any other ideas ?

Regards,
Jens

In that case playing with curl or wget is only scriptable way I am aware of.

Igor,

Thank you for your reply. As this totally new to me could you direct me to the right information how to do this ?

Regards,
Jens

Curl and wget both are command line programs able to handle http requests, sessions, etc. It is bit a difficult to provide you with ‘instant’ solution, but there are man pages and plenty of other knoweledge sources about. Just read it, open command prompt and try.

Looks like a curl command should be able to do that…
Use command line switch:

or shell commands:

Hello, and @IgorZg

I found some information guides 1 and 2 resulting in the following code. Please note that I’ve put user/password. The problem I’m having is the session-keys, hence the session-key error (not sure if I would get more errors as I didn’t get that far).
I’ve tried to find out if there are ways around this problem, but nothing to be found. Maybe you guys have still an idea ?

curl -c /tmp/cookie-jar.txt 'http://192.168.1.1/postlogin.cgi?sessionKey=517955133' \
  -H 'Connection: keep-alive' \
  -H 'Cache-Control: max-age=0' \
  -H 'Upgrade-Insecure-Requests: 1' \
  -H 'Origin: http://192.168.1.1' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36' \
  -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
  -H 'Referer: http://192.168.1.1/' \
  -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
  --data-raw 'sessionKey=517955133&loginUsername=USER&loginPassword=PASSWORD' \
 
 curl -b /tmp/cookie-jar.txt 'http://192.168.1.1/rebootinfo.cgi?sessionKey=1602446389' \
  -H 'Connection: keep-alive' \
  -H 'Cache-Control: max-age=0' \
  -H 'Upgrade-Insecure-Requests: 1' \
  -H 'Origin: http://192.168.1.1' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36' \
  -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
  -H 'Referer: http://192.168.1.1/config.html' \
  -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
  --data-raw 'sessionKey=1602446389' \

So the question is how to get or generate the sessionID or sessionKey. Any ideas ?