External IP lookup
This commit is contained in:
parent
806a7bbf62
commit
2a53814aed
|
@ -34,7 +34,6 @@ IPV6_NETWORK='2001:470:26:307'
|
||||||
# OpenDNS ipv6 DNS 2620:0:ccc::2
|
# OpenDNS ipv6 DNS 2620:0:ccc::2
|
||||||
IPV4_ADDRESS_TEST_DESTINATION='85.214.73.63'
|
IPV4_ADDRESS_TEST_DESTINATION='85.214.73.63'
|
||||||
IPV6_ADDRESS_TEST_DESTINATION='2620:0:ccc::2'
|
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
|
# The static IP address of the system within the local network
|
||||||
# By default the IP address is dynamic within your LAN
|
# By default the IP address is dynamic within your LAN
|
||||||
|
@ -88,7 +87,7 @@ function install_static_network {
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_external_ipv4_address {
|
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 {
|
function get_ipv4_address {
|
||||||
|
@ -105,7 +104,7 @@ function update_external_ip {
|
||||||
ip_update_script=/usr/bin/externalipupdate
|
ip_update_script=/usr/bin/externalipupdate
|
||||||
{ echo '#!/bin/bash';
|
{ echo '#!/bin/bash';
|
||||||
echo "existing_ip=\$(cat $CONFIGURATION_FILE | grep \"EXTERNAL_IPV4_ADDRESS=\" | head -n 1 | awk -F '=' '{print \$2}')'";
|
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 "if [[ \"\$curr_ip\" != \"\$existing_ip\" ]]; then";
|
||||||
echo " sed -i \"s|EXTERNAL_IPV4_ADDRESS=.*|EXTERNAL_IPV4_ADDRESS=\${curr_ip}|g\" $CONFIGURATION_FILE";
|
echo " sed -i \"s|EXTERNAL_IPV4_ADDRESS=.*|EXTERNAL_IPV4_ADDRESS=\${curr_ip}|g\" $CONFIGURATION_FILE";
|
||||||
echo " echo \"\$(date)\" >> ~/${PROJECT_NAME}-external-ip-changes.txt";
|
echo " echo \"\$(date)\" >> ~/${PROJECT_NAME}-external-ip-changes.txt";
|
||||||
|
|
Loading…
Reference in New Issue