Skip to content
Snippets Groups Projects
Commit 2a53814a authored by Bob Mottram's avatar Bob Mottram
Browse files

External IP lookup

parent 806a7bbf
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,6 @@ IPV6_NETWORK='2001:470:26:307'
# 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
......@@ -88,7 +87,7 @@ function install_static_network {
}
function get_external_ipv4_address {
nslookup . $EXTERNAL_IP_LOOKUP_URL | grep Address | tail -n 1 | awk -F ' ' '{print $2}'
curl ipinfo.io/ip
}
function get_ipv4_address {
......@@ -105,7 +104,7 @@ function update_external_ip {
ip_update_script=/usr/bin/externalipupdate
{ echo '#!/bin/bash';
echo "existing_ip=\$(cat $CONFIGURATION_FILE | grep \"EXTERNAL_IPV4_ADDRESS=\" | head -n 1 | awk -F '=' '{print \$2}')'";
echo "curr_ip=\$(nslookup . $EXTERNAL_IP_LOOKUP_URL | grep Address | tail -n 1 | awk -F ' ' '{print \$2}')";
echo "curr_ip=\$(curl ipinfo.io/ip)";
echo "if [[ \"\$curr_ip\" != \"\$existing_ip\" ]]; then";
echo " sed -i \"s|EXTERNAL_IPV4_ADDRESS=.*|EXTERNAL_IPV4_ADDRESS=\${curr_ip}|g\" $CONFIGURATION_FILE";
echo " echo \"\$(date)\" >> ~/${PROJECT_NAME}-external-ip-changes.txt";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment