From a263ef283e422fc25e7ecff2e9c272eab1a336a6 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Mon, 28 Jan 2013 21:56:02 -0500 Subject: [PATCH] Pick just the first route when looking for the host interface The current code will fail miserably if multiple default routes are present (perfectly normal if they have different metrics). Fixing the code to pick the first/top entry Fixes LP# 1084470 Change-Id: Ieda16b575685071ff831c92e6b2a29737d6f849b --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 005d88e7b6..27096670f9 100755 --- a/stack.sh +++ b/stack.sh @@ -253,7 +253,7 @@ FIXED_NETWORK_SIZE=${FIXED_NETWORK_SIZE:-256} NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1} # Find the interface used for the default route -HOST_IP_IFACE=${HOST_IP_IFACE:-$(ip route | sed -n '/^default/{ s/.*dev \(\w\+\)\s\+.*/\1/; p; }')} +HOST_IP_IFACE=${HOST_IP_IFACE:-$(ip route | sed -n '/^default/{ s/.*dev \(\w\+\)\s\+.*/\1/; p; }' | head -1)} # Search for an IP unless an explicit is set by ``HOST_IP`` environment variable if [ -z "$HOST_IP" -o "$HOST_IP" == "dhcp" ]; then HOST_IP=""