From 421157064978cdfbfd25e063508dc1f1ee841887 Mon Sep 17 00:00:00 2001 From: William Orr Date: Wed, 13 Mar 2019 18:43:02 +0100 Subject: [PATCH] Ignore expired routes in `netstat` on macOS When routes expire in macOS, `netstat -r` shows a trailing exclamation point to indicate this. In the current version of this code, this will set `DEF_GW_IF` to contain a `!`, causing subsequent DNS modifications on OSX to fail. This change ignores the the `!` that can be set in this case. --- scripts/darwin/get-network-service-name.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/darwin/get-network-service-name.sh b/scripts/darwin/get-network-service-name.sh index 2f61b5c..f02863a 100755 --- a/scripts/darwin/get-network-service-name.sh +++ b/scripts/darwin/get-network-service-name.sh @@ -7,5 +7,5 @@ if [[ -n "${FORCE_NETWORK_SERVICE}" ]]; then exit 0 fi -DEF_GW_IF=$(netstat -nr | grep default | awk '{print $NF}' | grep -v tun | tail -n1) +DEF_GW_IF=$(netstat -nr | grep default | awk '!/tun|!/ {print $NF}' | tail -n1) networksetup -listnetworkserviceorder | grep -B1 " Device: ${DEF_GW_IF})" | head -n1 | sed 's/^(.*) //'