瀏覽代碼

External IP lookup

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

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

@@ -34,7 +34,6 @@ IPV6_NETWORK='2001:470:26:307'
34 34
 # OpenDNS ipv6 DNS  2620:0:ccc::2
35 35
 IPV4_ADDRESS_TEST_DESTINATION='85.214.73.63'
36 36
 IPV6_ADDRESS_TEST_DESTINATION='2620:0:ccc::2'
37
-EXTERNAL_IP_LOOKUP_URL='ifcfg.me'
38 37
 
39 38
 # The static IP address of the system within the local network
40 39
 # By default the IP address is dynamic within your LAN
@@ -88,7 +87,7 @@ function install_static_network {
88 87
 }
89 88
 
90 89
 function get_external_ipv4_address {
91
-    nslookup . $EXTERNAL_IP_LOOKUP_URL | grep Address | tail -n 1 | awk -F ' ' '{print $2}'
90
+    curl ipinfo.io/ip
92 91
 }
93 92
 
94 93
 function get_ipv4_address {
@@ -105,7 +104,7 @@ function update_external_ip {
105 104
     ip_update_script=/usr/bin/externalipupdate
106 105
     { echo '#!/bin/bash';
107 106
       echo "existing_ip=\$(cat $CONFIGURATION_FILE | grep \"EXTERNAL_IPV4_ADDRESS=\" | head -n 1 | awk -F '=' '{print \$2}')'";
108
-      echo "curr_ip=\$(nslookup . $EXTERNAL_IP_LOOKUP_URL | grep Address | tail -n 1 | awk -F ' ' '{print \$2}')";
107
+      echo "curr_ip=\$(curl ipinfo.io/ip)";
109 108
       echo "if [[ \"\$curr_ip\" != \"\$existing_ip\" ]]; then";
110 109
       echo "  sed -i \"s|EXTERNAL_IPV4_ADDRESS=.*|EXTERNAL_IPV4_ADDRESS=\${curr_ip}|g\" $CONFIGURATION_FILE";
111 110
       echo "  echo \"\$(date)\" >> ~/${PROJECT_NAME}-external-ip-changes.txt";