Browse Source

Show external ipv4 address on about screen

Bob Mottram 7 years ago
parent
commit
aec19a4876
2 changed files with 9 additions and 4 deletions
  1. 1
    1
      src/freedombone-controlpanel
  2. 8
    3
      src/freedombone-utils-network

+ 1
- 1
src/freedombone-controlpanel View File

519
     echo $'IP/DNS addresses'
519
     echo $'IP/DNS addresses'
520
     echo '================'
520
     echo '================'
521
     echo ''
521
     echo ''
522
-    echo -n "IPv4: $(get_ipv4_address)"
522
+    echo -n "IPv4: $(get_ipv4_address)/$(get_external_ipv4_address)"
523
     ipv6_address="$(get_ipv6_address)"
523
     ipv6_address="$(get_ipv6_address)"
524
     if [ ${#ipv6_address} -gt 0 ]; then
524
     if [ ${#ipv6_address} -gt 0 ]; then
525
         echo "    IPv6: ${ipv6_address}"
525
         echo "    IPv6: ${ipv6_address}"

+ 8
- 3
src/freedombone-utils-network View File

31
 # If the system is on an IPv6 network
31
 # If the system is on an IPv6 network
32
 IPV6_NETWORK='2001:470:26:307'
32
 IPV6_NETWORK='2001:470:26:307'
33
 
33
 
34
-# Destinations used to get the external IP address of this system
35
-# Google ipv6 DNS is 2001:4860:4860::8888
34
+# Destinations used to get the local IP address of this system
35
+# Google ipv6 DNS   2001:4860:4860::8888
36
+# OpenDNS ipv6 DNS  2620:0:ccc::2
36
 IPV4_ADDRESS_TEST_DESTINATION='85.214.73.63'
37
 IPV4_ADDRESS_TEST_DESTINATION='85.214.73.63'
37
 IPV6_ADDRESS_TEST_DESTINATION='2620:0:ccc::2'
38
 IPV6_ADDRESS_TEST_DESTINATION='2620:0:ccc::2'
38
-
39
+EXTERNAL_IP_LOOKUP_URL='ifcfg.me'
39
 
40
 
40
 # The static IP address of the system within the local network
41
 # The static IP address of the system within the local network
41
 # By default the IP address is dynamic within your LAN
42
 # By default the IP address is dynamic within your LAN
70
     mark_completed $FUNCNAME
71
     mark_completed $FUNCNAME
71
 }
72
 }
72
 
73
 
74
+function get_external_ipv4_address {
75
+    nslookup . $EXTERNAL_IP_LOOKUP_URL | grep Address | tail -n 1 | awk -F ' ' '{print $2}'
76
+}
77
+
73
 function get_ipv4_address {
78
 function get_ipv4_address {
74
     IPv4dev=$(ip route get $IPV4_ADDRESS_TEST_DESTINATION | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
79
     IPv4dev=$(ip route get $IPV4_ADDRESS_TEST_DESTINATION | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
75
     echo $(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}' | awk -F '/' '{print $1}')
80
     echo $(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}' | awk -F '/' '{print $1}')