How I Automated My Airtel (ZTE) Router Reboot to Fix Packet Loss & High Ping
How I Automated My Airtel (ZTE) Router Reboot to Fix Packet Loss & High Ping
If youâre like me and rely on a stable internet connection for work, gaming, or streaming, you know how frustrating it is when your router starts acting up. My Airtel (ZTE) router, unfortunately, doesnât have a built-in scheduled reboot feature. Over time, I noticed that if I didnât manually restart it every day, Iâd start experiencing packet loss and high pingâmaking online activities nearly impossible.
After struggling with these issues for months, I decided to automate the process. Hereâs how I built a solution using Python, Selenium, and a bit of scripting magic.
The Problem: No Scheduled Reboot, High Ping & Packet Loss
Most modern routers offer a âScheduled Rebootâ option, but my Airtel (ZTE) router doesnât. After a day or two of uptime, the routerâs performance would degradeâcausing:
- Packet loss (dropped connections in games and video calls)
- High ping (lag and delays)
- General sluggishness
The only fix was to log in to the routerâs admin panel and manually reboot it. Doing this every day was tedious and easy to forget.
The Solution: Automated Router Restart Script
I created a Router Scheduled Restart Automation script that logs into the routerâs admin panel and reboots it automatically. Hereâs how it works:
1. Automating the Browser with Selenium
Selenium is a tool that can control a web browser programmatically. I wrote a Python script (Airtel-Router-reboot.py
) that:
- Opens the routerâs admin page
- Logs in using credentials stored securely in a
.env
file - Navigates to the reboot section
- Clicks the reboot button
- Waits for the router to come back online
2. Notifications & Error Handling
The script sends notifications to a Discord channel using a webhook, so I know when the reboot starts, succeeds, or fails. It also takes screenshots at each step for troubleshooting.
3. Scheduling with Cron
To make the reboot happen automatically every day, I set up a cron job on my home server. This ensures the script runs at 4:10 AM daily, when nobody is using the internet.
Step-by-Step: Setting Up the Automation
Prerequisites
- Python 3
- Chrome browser and ChromeDriver
- Selenium, python-dotenv, requests Python packages
Installation
- Clone the Repo & Install Dependencies
1 2 3 4 5 6 7
git clone https://github.com/Harshraj9812/Router-Restart-Automation.git cd Router-Restart-Automation sudo apt update sudo apt install -y python3 python3-pip unzip wget curl xvfb python3 -m venv venv source venv/bin/activate pip install -r scripts/requirement.txt
- Install Chrome & ChromeDriver
1 2 3 4 5 6
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb sudo apt install ./google-chrome-stable_current_amd64.deb -y wget https://storage.googleapis.com/chrome-for-testing-public/136.0.7103.94/linux64/chrome-linux64.zip unzip chrome-linux64.zip sudo cp chrome-linux64/chrome /usr/local/bin sudo chmod +x /usr/local/bin/chrome
- Configure Environment Variables
- Create a
.env
file in the scripts directory:1
touch scripts/.env
- Add your credentials:
1 2 3
AIRTEL_ROUTER_USERNAME=your_router_username AIRTEL_ROUTER_PASSWORD=your_router_password DISCORD_WEBHOOK_URL=your_discord_webhook_url
- Create a
- Run the Script Manually
1
python3 Airtel-Router-reboot.py
- Set Up the Cron Job
- Edit your crontab:
1
crontab -e
- Add:
1
10 4 * * * /path/to/venv/bin/python3 Airtel-Router-reboot.py >> /path/to/scripts/Airtel-Router-reboot.log 2>&1
- Edit your crontab:
How It Works
- The script logs in to the routerâs admin panel using Selenium.
- It navigates through the UI just like a human would.
- It clicks the reboot button and waits for the router to restart.
- It pings the router to confirm itâs back online.
- It sends notifications to Discord at each step.
Results
Since setting this up, my router reboots every morning before I wake up. I havenât experienced packet loss or high ping since. The automation is reliable, and the Discord notifications give me peace of mind.
Why Not Just Use a Smart Plug?
A smart plug could power-cycle the router, but a graceful reboot is safer and avoids potential file system corruption or other issues. Plus, this method works for any router with a web interfaceâeven if it doesnât support scheduled reboots.
Conclusion
If youâre struggling with an Airtel (ZTE) router (or any router without a scheduled reboot feature), this automation can save you a lot of headaches. Check out the Router Restart Automation repo for the full code and setup instructions.
Happy surfingâwithout the lag!
Repo: Router-Restart-Automation
Main Script: scripts/Airtel-Router-reboot.py