瀏覽代碼

Show external ipv4 address on about screen

Bob Mottram 7 年之前
父節點
當前提交
aec19a4876
共有 2 個檔案被更改,包括 9 行新增4 行删除
  1. 1
    1
      src/freedombone-controlpanel
  2. 8
    3
      src/freedombone-utils-network

+ 1
- 1
src/freedombone-controlpanel 查看文件

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

+ 8
- 3
src/freedombone-utils-network 查看文件

@@ -31,11 +31,12 @@
31 31
 # If the system is on an IPv6 network
32 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 37
 IPV4_ADDRESS_TEST_DESTINATION='85.214.73.63'
37 38
 IPV6_ADDRESS_TEST_DESTINATION='2620:0:ccc::2'
38
-
39
+EXTERNAL_IP_LOOKUP_URL='ifcfg.me'
39 40
 
40 41
 # The static IP address of the system within the local network
41 42
 # By default the IP address is dynamic within your LAN
@@ -70,6 +71,10 @@ function install_static_network {
70 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 78
 function get_ipv4_address {
74 79
     IPv4dev=$(ip route get $IPV4_ADDRESS_TEST_DESTINATION | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
75 80
     echo $(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}' | awk -F '/' '{print $1}')