Quantcast
Channel: All Fios Internet posts
Viewing all articles
Browse latest Browse all 39554

Re: Remotely restart FIOS (MI424WR) Router - Instructions to reboot actiontec router every night

$
0
0

To reboot a Verizon MI424WR router remotely from a Raspberry Pi on the same internal network, here's what to do:

 

Log into the pi account on the Raspberry Pi.

 

Download and install the expect application. Enter this command at the Raspberry Pi's prompt:

 

sudo apt-get install expect

 

Create the following expect script in the /home/pi directory and name it verizonrouterreboot.expect

 

# This expect script will connect by telnet with a local Verizon router
# and command it to reboot.
# It has been tested on an MI424WR Revision I with the latest stock firmware
# as of 2014-01-16, Version 40.21.10.2.
# The Verizon router must have telnet access enabled for local administration
# using port 23.

# Be sure to enclose any text below after expect or send in double
# quotation marks, and if you need to send a return, end the text with \r.

# Open a telnet session with the Verizon router.
spawn telnet 192.168.1.1

# Log in to the Verizon router.
# Replace yourverizonrouterpassword with the admin password on your Verizon router.
# Retain the \r after the admin password.

expect "Username:"
send "admin\r"
expect "Password:"
send "yourverizonrouterpassword\r"

# Wait for a prompt. Adjust as needed to match the actual prompt
# on your router.
expect "Wireless Broadband Router> "

# Probably no need to delay after receiving a prompt, but just in case.
sleep 5

# Command the Verizon router to reboot.
send "system reboot\r"

# Wait 5 seconds and close the telnet connection to the Verizon router. This is
# probably not necessary because the router reboot should close the connection.
sleep 5
send "exit\r"

# Close the spawned telnet session on the Raspberry Pi. This may not be
# necessary either because the router reboot or the exit above may do this.
close

# Wait 5 more seconds before exiting from expect in case any commands need
# time to complete.
sleep 5

# Exit from expect.
exit

 

Create the following shell script in the /home/pi directory and name it verizonrouterreboot.sh. Don't omit the curly braces at the top and at the beginning of the next-to-last line.

 

{
# This shell script starts expect on a Raspberry Pi and runs an expect script
# to reboot a Verizon FiOS Actiontec MI424WR Revision I router. Please see the
# expect script for details.
# The expect script must be in the same directory as this shell script,
# or you can insert the path to the expect script.

cd /home/pi
expect -f verizonrouterreboot.expect

# Insert a hard return when expect ends to get a new Raspberry Pi prompt
# on a new line.
echo "\r"

# The log file won't tell you much, but its creation time will tell you
# when the script ran and this can be useful if you start it from cron.

} 2>&1 > /home/pi/verizonrouterreboot.log
exit

 

Make sure you are in the /home/pi directory. Enter the following at a shell prompt to reboot the router:

 

sh verizonrouterreboot.sh

 

My router takes about two minutes to reboot.

 

If you want to add an automatic reboot to the Raspberry Pi's cron, make sure you are logged in as pi and enter this at the prompt:

 

crontab -e

 

The nano text editor will open a temporary file. Add this to the bottom of the file:

 

0 0 * * * /home/pi/verizonrouterreboot.sh

The crontab entry above will reboot the router every day at 12 midnight. See documentation for crontab if you want to do this on different days or at different times. A web search for "man crontab" without the quotes will find this documentation.

 

When you finish making modifications to the file in nano, press CTRL-X, answer "yes" when it asks if you want to save the modified buffer, and the reboot job will be added to cron.

 

If you don't like the long names all in lower case I have used for the scripts and files, like "verizonrouterreboot", feel free to change them, but be careful to change them everywhere.


Viewing all articles
Browse latest Browse all 39554

Trending Articles