# Want to reboot router from its WebGUI via server



## jamaroney (Aug 24, 2022)

I want to set a cron to have my wireless router regularly reboot via my FreeBSD server. My router doesn't offer telnet or SSH.

I found that when I choose the reboot option on the router's WebGUI (via my Win 10 computers), it then goes to its own internal page (devicemng_rebootinfo.htm) which automatically reboots it.  So, on my Win 10 browsers, after I go to my router's address (192.168.1.2) and enter my username and password. all I have to do is enter "http://192.168.1.2/devicemng_rebootinfo.htm" and the router will automatically reboot.

From my FreeBSD server, is there a command or shell script that would allow me such access?

Sorry if I don't know what other relevant information to include. Any assistance would be appreciated.


----------



## VladiBG (Aug 24, 2022)

You can use curl to send basic auth data and then to open the desire address. But first you will need to dump the login process depending of your website so you can craft the auth. Search in google for "Curl POST With Basic Authentication"

example:


> curl -u "username:_pass" http://192.168.1.2/devicemng_rebootinfo.htm



or in your browser get the request header and dump the auth token then use



> curl http://192.168.1.2/devicemng_rebootinfo.htm -H "Accept: text/html,application/xhtml"  -H "Authorization: Basic {token}"


----------



## jamaroney (Aug 24, 2022)

So, I tried the first example you supplied (with proper username/password) as well as several other options shown on the reqbin website (their "Curl POST With Basic Authentication" page), and all I seem to get is the page source of the devicemng_rebootinfo.htm page. It doesn't reboot the router like it does when I access the page via a browser on my Win10 computers.

Do I need to install/utilize a web browser while I'm trying to accomplish this? I'm not at all knowledgeable about how to do this from a headless server.


----------



## VladiBG (Aug 24, 2022)

If you get to the page source then your login process is working. Then you need to view the actual data that you need to POST to that page, it may be FORM post or some .cgi like reboot.cgi . It's easy by recording your browser network activity via developing tools in chrome based browser and observe the request header when you navigate to this page.

Do you need to click some button when you open this page "devicemng_rebootinfo.htm" ?


----------



## jamaroney (Aug 24, 2022)

VladiBG said:


> If you get to the page source then your login process is working. Then you need to view the actual data that you need to POST to that page, it may be FORM post or some .cgi like reboot.cgi . It's easy by recording your browser network activity via developing tools in chrome based browser and observe the request header when you navigate to this page.
> 
> Do you need to click some button when you open this page "devicemng_rebootinfo.htm" ?


No, going to the page automatically reboots the router - it says things to the effect that my router is now rebooting. If I'm working through normal procedures (starting at the router's home page), it's the page that the router directs to when I select "Reboot Router."


----------



## VladiBG (Aug 24, 2022)

Try to record the traffic activity when you click "reboot router" and see what is the actual POST data which you are sending to that page.


----------



## richardtoohey2 (Aug 24, 2022)

When you login with your browser, the web server on the router creates a session. When you navigate to another page in your browser (like the reboot page) the router knows it is still the same session - the same logged-in user - so it does the reboot.

So you can’t just visit the reboot page from the command line - you have to mimic the whole login/session flow (which is what VladiBG is saying).

This might help explain some of the concepts: 








						What are sessions? How do they work?
					

I am just beginning to start learning web application development, using python. I am coming across the terms 'cookies' and 'sessions'. I understand cookies in that they store some info in a key va...




					stackoverflow.com
				




Apologies if you knew all this already.

Should be possible but you’ll have to do the digging to see what exactly your router does.


----------



## jamaroney (Aug 25, 2022)

Thanks for the suggestions. I used Chrome Dev Tools to try to determine what's going on when I get to "devicemng_rebootinfo.htm" (after logging in), but I was unable to come up with anything fruitful.

A lot of time spent unsuccessfully trying to accomplish what I had hoped would be a straightforward task.  Time to move on...

Again, thanks.


----------

