Last active
September 20, 2018 11:48
-
-
Save ddormer/abfda1ac8aece12eb9ff83a6ee4f5fd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Update a Linode DNS entry with a network interface's IP address. | |
# Uses Linode's v3 API. | |
API_KEY= | |
DOMAIN_ID= | |
RESOURCE_ID= | |
INTERFACE=eth0 | |
get_ip_4() { | |
ip addr show $INTERFACE |grep 'inet '|awk '{print $2}'|sed -e "s/\/.*$//" | |
} | |
get_ip_6() { | |
ip addr show $INTERFACE |grep 'inet6 '|awk '{print $2}'|sed -e "s/\/.*$//" | |
} | |
curl "https://api.linode.com/?api_key=$API_KEY&api_action=domain.resource.update&DomainID=$DOMAIN_ID&resourceID=$RESOURCE_ID&target=$(get_ip_4)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment