From aec19a487698e12781820d107e3c00276a512e4c Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Mon, 25 Sep 2017 11:10:26 +0100
Subject: [PATCH] Show external ipv4 address on about screen

---
 src/freedombone-controlpanel  |  2 +-
 src/freedombone-utils-network | 11 ++++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/freedombone-controlpanel b/src/freedombone-controlpanel
index c4eb712d4..db4ae9c82 100755
--- a/src/freedombone-controlpanel
+++ b/src/freedombone-controlpanel
@@ -519,7 +519,7 @@ function show_ip_addresses {
     echo $'IP/DNS addresses'
     echo '================'
     echo ''
-    echo -n "IPv4: $(get_ipv4_address)"
+    echo -n "IPv4: $(get_ipv4_address)/$(get_external_ipv4_address)"
     ipv6_address="$(get_ipv6_address)"
     if [ ${#ipv6_address} -gt 0 ]; then
         echo "    IPv6: ${ipv6_address}"
diff --git a/src/freedombone-utils-network b/src/freedombone-utils-network
index 7ae83975c..51c3b4d7d 100755
--- a/src/freedombone-utils-network
+++ b/src/freedombone-utils-network
@@ -31,11 +31,12 @@
 # If the system is on an IPv6 network
 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
+# Destinations used to get the local IP address of this system
+# Google ipv6 DNS   2001:4860:4860::8888
+# OpenDNS ipv6 DNS  2620:0:ccc::2
 IPV4_ADDRESS_TEST_DESTINATION='85.214.73.63'
 IPV6_ADDRESS_TEST_DESTINATION='2620:0:ccc::2'
-
+EXTERNAL_IP_LOOKUP_URL='ifcfg.me'
 
 # The static IP address of the system within the local network
 # By default the IP address is dynamic within your LAN
@@ -70,6 +71,10 @@ function install_static_network {
     mark_completed $FUNCNAME
 }
 
+function get_external_ipv4_address {
+    nslookup . $EXTERNAL_IP_LOOKUP_URL | grep Address | tail -n 1 | awk -F ' ' '{print $2}'
+}
+
 function get_ipv4_address {
     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}')
-- 
GitLab