Change dns used for external IP address detection

This commit is contained in:
Bob Mottram 2017-09-25 10:52:17 +01:00
parent 29671b04ad
commit 021a850a5e
1 changed files with 8 additions and 2 deletions

View File

@ -31,6 +31,12 @@
# If the system is on an IPv6 network # If the system is on an IPv6 network
IPV6_NETWORK='2001:470:26:307' IPV6_NETWORK='2001:470:26:307'
# Destinations used to get the external IP address of this system
# Google ipv6 DNS is 2001:4860:4860::8888
IPV4_ADDRESS_TEST_DESTINATION='85.214.73.63'
IPV6_ADDRESS_TEST_DESTINATION='2620:0:ccc::2'
# The static IP address of the system within the local network # The static IP address of the system within the local network
# By default the IP address is dynamic within your LAN # By default the IP address is dynamic within your LAN
LOCAL_NETWORK_STATIC_IP_ADDRESS= LOCAL_NETWORK_STATIC_IP_ADDRESS=
@ -65,12 +71,12 @@ function install_static_network {
} }
function get_ipv4_address { function get_ipv4_address {
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}') IPv4dev=$(ip route get $IPV4_ADDRESS_TEST_DESTINATION | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
echo $(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}' | awk -F '/' '{print $1}') echo $(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}' | awk -F '/' '{print $1}')
} }
function get_ipv6_address { function get_ipv6_address {
echo $(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') echo $(ip -6 route get $IPV6_ADDRESS_TEST_DESTINATION | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
} }
# NOTE: deliberately no exit 0 # NOTE: deliberately no exit 0