The officially official Devuan Forum!

You are not logged in.

#1 Re: Off-topic » [SOLVED] how to reboot modem from router command line? » 2023-06-11 07:04:18

Hello All,
First off, thanks to everyone that has contributed to this forum posting!!!!

I just wanted to contribute my solution to remotely rebooting a Netgear R7000P NightHawk Router (with latest version of firmware as of 06/09/2023 - "V1.3.3.154_10.1.86").

Based on the hints and suggestions in this forum I have crafted[hacked together  ;-) ] a very reliable shell script that I run on an old RPi-3 via cron to nightly reboot the router. (You may ask why am I rebooting this R7000P router, well after stupidly updating firmware to the latest version, the router has been getting into a very strange state and its web pages would no longer load or its internal webserver would just stop responding - it would still do its routing functions and even continue to operate as an OpenVPN server!).  So, I tried to downgrade back to the original version of firmware and the R7000P would not allow it. In a quick attempt to solve the issue, I just chose to reboot the device every morning at 4:56am!!!!  This seems to have worked...

The text of the script is here:
------------------------
#!/bin/sh
#
# Simple script to REBOOT the Netgear R7000P router via the commandline....
#
# This is based on various search results:
https://dev1galaxy.org/viewtopic.php?id=2293
#
#
# 06/09/2023
#
#

# Command to login and establish my unique transaction ID...
MyTxNId=`/usr/bin/wget --no-check-certificate  -O- -q --http-user admin --http-password YourPassword https://192.168.1.1/ADVANCED_home2.htm | grep "form action"|tr '=' ' ' | tr '"' ' ' | awk '{print $4}'`;

# The Transaction ID is defined by the R7000P router...
echo "My Ephemeral Transaction ID from the R7000P router is: "  $MyTxNId

echo " "
echo " "

# Now perform a HTTP POST operation to the "hidden" CGI and reboot the router...
echo "Now issuing the ReBoot command to the R7000P!"
/usr/bin/wget --no-check-certificate -q -O /dev/null --http-user admin --http-password YourPassword --post-data 'buttonSelect=2' https://192.168.1.1/newgui_adv_home.cgi?id=$MyTxNId

echo " "
echo " "

# The wait is like 5 to 7 minutes to reboot!!!!
echo "Now Wait A Few Minutes for the Router to ReBoot!!!!"

echo " "
echo " "
------------------------

Note: Substitute your actual IP address (and access method - HTTP or HTTPS) of the R7000P and replace the text "YourPassword" with whatever your password is for your device!!!!!!  Also, if you don't use HTTPS access, then you can eliminate the "--no-check-certificate" WGET option, it is used to prevent WGET from complaining about the self-signed SSL/TLS certificate from the R7000P router!

I hope this helps the next person that is trying to solve this reboot problem that Netgear should have incorporated into their firmware - like most other systems - or even better, support a SSH login to enable access the router's internal commandline environment!!!!

Enjoy!

Board footer

Forum Software