Skip to content

Instantly share code, notes, and snippets.

@andiwand
Last active December 3, 2022 04:49
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andiwand/5b5acc2c4873a0cfbe5eb0123c8fdd16 to your computer and use it in GitHub Desktop.
Save andiwand/5b5acc2c4873a0cfbe5eb0123c8fdd16 to your computer and use it in GitHub Desktop.
OpenWrt / LEDE hotplug script to add default routes correctly.
#!/bin/sh
# OpenWrt / LEDE hotplug script to add default routes correctly.
#
# Location "/etc/hotplug.d/iface/01-default-route".
#
# Fixed mwan3 "No default route in the main routing table" and
# "WARNING: this interface has no default route in the main routing table!" for me.
uci get "network.${INTERFACE}.gateway" > /dev/null 2>&1 || exit
GATEWAY=`uci get "network.${INTERFACE}.gateway"`
METRIC=`uci get "network.${INTERFACE}.metric"`
[ "$ACTION" = ifup ] && OPERATION=add || OPERATION=del
ip route $OPERATION default via $GATEWAY metric $METRIC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment