Last active
September 26, 2018 04:07
-
-
Save andiwand/19dc57d632b63af0ee1ec1739a2106bf to your computer and use it in GitHub Desktop.
OpenWrt / LEDE script to fix default routes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ash | |
# OpenWrt / LEDE script to fix default routes. | |
if [ "$#" -ne 1 ]; then | |
>&2 echo "usage: $0 interface [interface ...]" | |
exit 1 | |
fi | |
for arg in "$@"; do | |
INTERFACE="$arg" | |
uci get "network.${INTERFACE}.gateway" > /dev/null 2>&1 || exit | |
GATEWAY=`uci get "network.${INTERFACE}.gateway"` | |
METRIC=`uci get "network.${INTERFACE}.metric"` | |
[ `ifstatus ${INTERFACE} | jsonfilter -e "@.up"` = true ] && OPERATION=add || | |
ip route $OPERATION default via $GATEWAY metric $METRIC | |
#echo "ip route $OPERATION default via $GATEWAY metric $METRIC" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment