Add scheduled reboot / reset support for TP-LINK Archer D7 and similar

My TP-LINK Archer D7 router works fine but airplay to my Chromecast drops occasionally. This is usually solved with a quick reset of the wifi modem.

The problem is that the router doesn’t have a feature to schedule an automatic reboot and I find it quite annoying to restart manually.

Image result for tp-link archer d7

Luckily there is a way to overcome this limitation of the router. You will need to have access to a Linux machine in your network that we’ll use to reboot the router remotely. I have a Raspberry Pi as HTPC which is connected to my network, and it’s on all the time, so I will be using that for this purpose.

Gain access to the router

The router can be accessed remotely via telnet by default.

xbian@xbian ~ $ telnet 192.168.1.1 23

Entering character mode
Escape character is '^]'.

Password: **your-router-password**

--------------------------------------------------------------------
Welcome To Use TP-LINK COMMAND-LINE Interface Model.
--------------------------------------------------------------------
TP-LINK(conf)#

If you run the command “dev reboot” the router would reboot.

Reboot the router remotely

So far we gained access to the router, and we saw we could reboot it, but we want to do this remotely. For this, we’ll create a script on the Raspberry Pi that will log in to the router and execute the reboot command.

On the Linux box create a file named “reboot_d7” that will have this content:

#!/usr/bin/expect
set timeout 10
set ip 192.168.1.1
set port 23
set password YOUR-ROUTER-PASSWD
spawn telnet $ip $port
expect "password:" {
 send "$password\r"
}
expect "#"
send "dev reboot\r"
expect "#"
sleep 3
send "logout\r"
expect eof

Make sure the file is executable:

chmod +x reboot_d7

We will be using a script called “expect” and you will need to install this dependency:

 sudo apt-get install expect

The script needs to be run as is (do not run with sh since it’s not a shell script!):

xbian@xbian ~ $ ./reboot_d7

Now all that’s left is to schedule the script to run every night at 4am. We can add this to the cron job.

# crontab -e
0 4 * * * /home/xbian/reboot_d7

Let me know if this worked for you or if you need more details.

Csaba is passionate about Cyber Security, Pentesting and just making things work.

Leave a reply:

Your email address will not be published.

 

Site Footer

Sliding Sidebar