Different way of trapping ipv6 address error

This commit is contained in:
Bob Mottram 2017-09-25 14:54:23 +01:00
parent 88d45d0b23
commit 6e15f791d8
2 changed files with 3 additions and 4 deletions

View File

@ -522,9 +522,7 @@ function show_ip_addresses {
echo -n "IPv4: $(get_ipv4_address)/$(get_external_ipv4_address)"
ipv6_address="$(get_ipv6_address)"
if [ ${#ipv6_address} -gt 0 ]; then
if [[ "$ipv6_address" != *'unreachable'* ]]; then
echo " IPv6: ${ipv6_address}"
fi
echo " IPv6: ${ipv6_address}"
fi
echo ''
echo ''

View File

@ -81,7 +81,8 @@ function get_ipv4_address {
}
function get_ipv6_address {
echo $(ip -6 route get $IPV6_ADDRESS_TEST_DESTINATION | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
retval=$(ip -6 route get $IPV6_ADDRESS_TEST_DESTINATION 2> /dev/null)
echo $(echo "$retval" | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
}
# NOTE: deliberately no exit 0