Skip to content

Instantly share code, notes, and snippets.

@brwyatt
Created April 6, 2025 06:21
Show Gist options
  • Save brwyatt/7bdff655a826362925c3101aeba6b704 to your computer and use it in GitHub Desktop.
Save brwyatt/7bdff655a826362925c3101aeba6b704 to your computer and use it in GitHub Desktop.

Workaround for missing default route on Proxmox boot

Have an issue where Proxmox, on boot, fails to set the default route. It is set in the config (file and UI), and changing the gateway and applying will set the default route, so something's getting mixed up here. So hopefully this fixes it.

Replace 172.17.25.1 with your gateway, and vlan25 with the correct interface.

Script

file: /usr/local/bin/fix-default-route.sh

#!/bin/bash

ip route get 8.8.8.8 > /dev/null 2>&1
if [ $? -eq 2 ]; then
    echo 'Default route not present! Adding!'
    ip route add default via 172.17.25.1 dev vlan25
else
    echo 'Default route already exists!'
fi

Systemd unit

file: /etc/systemd/system/fix-default-route.service

[Unit]
Description=Fix missing default route on boot
After=network-online.target
Wants=network-online.target

[Install]
WantedBy=default.target

[Service]
ExecStart=/usr/local/bin/fix-default-route.sh

Install

chmod +x /usr/local/bin/fix-default-route.sh
systemctl enable fix-default-route.service

Verify

systemctl start fix-default-route.service
systemctl status fix-default-route.service

Should see that it didn't update anything (assuming this is being added while things are working). Then, to verify it adds it...

ip route del default via 172.17.25.1 dev vlan25
systemctl start fix-default-route.service
systemctl status fix-default-route.service

And it should say it was missing and it added it back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment