Post

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

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

Installation

  1. 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
    
  2. 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
    
  3. 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
      
  4. Run the Script Manually
    1
    
     python3 Airtel-Router-reboot.py
    
  5. 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
      

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

This post is licensed under CC BY 4.0 by the author.