Fix run-os-net-config.sh to use ping6 for IPv6 hostnames

The run-os-net-config.sh script checks to see if an IP address is
IPv4 or IPv6, and uses ping or ping6 accordingly. This change also
resolves hostnames and submits the resolved IP to the same test.
If the hostname only resolves to an IPv6 address, then ping6 will
be used.

Change-Id: I9f37992157935b37cc9beb8a2f3b9d749a62bd1b
Closes-bug: 1830274
This commit is contained in:
Dan Sneddon 2019-05-23 12:38:00 -07:00
parent 5dd09273aa
commit 68bfc26728

View File

@ -44,8 +44,9 @@ function ping_metadata_ip() {
echo -n "Trying to ping metadata IP ${METADATA_IP}..."
_IP="$(getent hosts $METADATA_IP | awk '{ print $1 }')"
_ping=ping
if [[ "$METADATA_IP" =~ ":" ]] ; then
if [[ "$_IP" =~ ":" ]] ; then
_ping=ping6
fi