Skip to content

Instantly share code, notes, and snippets.

@ddormer
Last active September 20, 2018 11:48
Show Gist options
  • Save ddormer/abfda1ac8aece12eb9ff83a6ee4f5fd2 to your computer and use it in GitHub Desktop.
Save ddormer/abfda1ac8aece12eb9ff83a6ee4f5fd2 to your computer and use it in GitHub Desktop.
#!/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