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
This commit is contained in:
Davanum Srinivas
2013-01-28 21:56:02 -05:00
parent 95fb0d440c
commit a263ef283e

View File

@@ -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=""