#!/bin/sh ENDPOINT=129.100.33.20 case "$2" in up|dhcp4-change) route=$(ip -4 route show default | awk 'NR==1') gateway=$(echo "$route" | awk '{for (i=1;i<=NF;i++) if ($i=="via") print $(i+1)}') device=$(echo "$route" | awk '{for (i=1;i<=NF;i++) if ($i=="dev") print $(i+1)}') if [ -n "$gateway" ] && [ -n "$device" ]; then ip -4 route replace "$ENDPOINT/32" via "$gateway" dev "$device" fi ;; esac