Solving License Failures Due to Multiple Default Routes

Recently, one of our clients encountered a cPanel license activation failure on two VPS instances hosted by Hostinger. After securely sharing their login credentials, we conducted an in-depth investigation and identified the root cause: multiple default routes configured in the Linux networking stack.


Issue Summary

The issue was caused by an automatically added default route (169.254.0.1) by Hostinger. Although this route is temporary and usually reverts after a VPS reboot, it interfered with outbound traffic, causing license verification to fail.

We advised the client to contact Hostinger to disable the duplicate route; however, the issue persisted. As a result, we developed an automated solution to remove the unnecessary route and prevent future disruptions.

For more details on this topic, refer to the official guide: Resolving Multiple Default Routes in Linux


Manual Resolution Script

The following script removes the conflicting default route (169.254.0.1). You may update the IP based on your environment.

Bash Script: /root/network.sh

#!/bin/bash

check_root() {
  if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root"
    exit 1
  fi
}

get_default_routes() {
  ip route | grep '^default'
}

delete_route() {
  local route_to_delete=$1
  ip route del $route_to_delete
}

main() {
  check_root

  local remove_ip="169.254.0.1"
  local routes=$(get_default_routes)

  echo "Current default routes:"
  echo "$routes"

  while IFS= read -r route; do
    local ip=$(echo "$route" | grep -oP '(?<=via )[^ ]+')
    if [[ "$ip" == "$remove_ip" ]]; then
      delete_route "$route"
      echo "Deleted default route: $route"
    fi
  done <<< "$routes"

  echo "Remaining default routes:"
  get_default_routes
}

main

Setup Instructions:

  1. Save the script as /root/network.sh.

  2. Make it executable:

    chmod +x /root/network.sh
    
  3. Add a cron job to run it every 5 minutes and on reboot:

    echo -e '*/5 * * * * root sh /root/network.sh >/dev/null 2>&1\n@reboot root sh /root/network.sh >/dev/null 2>&1' | sudo tee /etc/cron.d/fixNetRoute
    
  4. Run the script once manually, then proceed with the cPanel license activation.


Fully Automated Installer

To streamline the process and ensure long-term stability, we created an automated installer. This script sets up a persistent solution using systemd.

What It Does:

  • Installs the route-fixing script at /usr/local/bin/network.sh

  • Configures a systemd service to run the script continuously (checks every 60 seconds)

  • Removes any legacy cron job (/etc/cron.d/fixNetRoute) to avoid conflicts

Installer Script: /root/install_fix_net_route.sh

#!/bin/bash

set -e

SCRIPT_PATH="/usr/local/bin/network.sh"
SERVICE_PATH="/etc/systemd/system/fix-net-route.service"
CRON_FILE="/etc/cron.d/fixNetRoute"

echo "[+] Creating $SCRIPT_PATH..."

cat > "$SCRIPT_PATH" <<'EOF'
#!/bin/bash

check_root() {
  if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root"
    exit 1
  fi
}

get_default_routes() {
  ip route | grep '^default'
}

delete_route() {
  local route_to_delete="$1"
  ip route del $route_to_delete
}

main() {
  check_root

  while true; do
    local remove_ip="169.254.0.1"
    local routes
    routes=$(get_default_routes)

    echo "[$(date)] Checking default routes..."

    while IFS= read -r route; do
      local ip
      ip=$(echo "$route" | grep -oP '(?<=via )[^ ]+')
      if [[ "$ip" == "$remove_ip" ]]; then
        delete_route "$route"
        echo "[$(date)] Deleted default route: $route"
      fi
    done <<< "$routes"

    sleep 60
  done
}

main
EOF

chmod +x "$SCRIPT_PATH"
echo "[✓] network.sh created and made executable."

echo "[+] Creating systemd service at $SERVICE_PATH..."

cat > "$SERVICE_PATH" <<EOF
[Unit]
Description=Continuous route fixer to remove 169.254.0.1 default gateway
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=$SCRIPT_PATH
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF

echo "[✓] Service file created."

if [ -f "$CRON_FILE" ]; then
  echo "[!] Old cron job found. Removing to prevent conflicts..."
  rm -f "$CRON_FILE"
  echo "[✓] Old cron job removed."
else
  echo "[i] No existing cron job found at $CRON_FILE."
fi

echo "[+] Reloading systemd and enabling service..."

systemctl daemon-reexec
systemctl daemon-reload
systemctl enable --now fix-net-route.service

echo "[✓] Service enabled and started."

echo
echo "To check the service status and logs:"
echo "  systemctl status fix-net-route.service"
echo "  journalctl -u fix-net-route.service -f"

Usage Instructions:

  1. Save the script as /root/install_fix_net_route.sh.

  2. Make it executable:

    chmod +x /root/install_fix_net_route.sh
    
  3. Run it as root:

    /root/install_fix_net_route.sh
    

Summary

  • Problem: Duplicate default route (169.254.0.1) caused license activation to fail.

  • Manual Solution: Script with cron job to remove the route at regular intervals.

  • Automated Solution: Installer script sets up a persistent systemd service.

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

How to restrict direct root access in Linux

We can do it just in two steps. Step One: At first we will create new root user as follows (for...

How to extract .tar.gz files in Linux/UNIX OS

A tarball is a group of files that are bundled together using the tar command. Use the...

How to add welcome message when SSH start?

You need to change the contents of /etc/motd. Unfortunately, by default, /etc/motd is a link to...

How to change root password when SSH logged in

Run the following command: passwd Now type your new passwordOnce done, retype new passwordDone!...

How to install Pinguzo on any Linux/UNIX OS

Login to Pinguzo panel using Softaculous account or create an account of Pinguzo To add new...