Skip to content

Instantly share code, notes, and snippets.

@nmarley
Created July 27, 2017 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmarley/7777032e11ac9ced12455c886cdb22b6 to your computer and use it in GitHub Desktop.
Save nmarley/7777032e11ac9ced12455c886cdb22b6 to your computer and use it in GitHub Desktop.
DigitalOcean cloud-init metadata IP address helper script
#! /bin/bash
# DigitalOcean cloud-init metadata IP address helper script
METADATA_URL="http://169.254.169.254/metadata"
PUBLIC_IPV4="$(curl -fs -m 2 $METADATA_URL/v1/interfaces/public/0/ipv4/address)"
ANCHOR_IPV4="$(curl -fs -m 2 $METADATA_URL/v1/interfaces/public/0/anchor_ipv4/address)"
FLOATING_ACTIVE="$(curl -fs -m 2 $METADATA_URL/v1/floating_ip/ipv4/active)"
FLOATING_IPV4="$(curl -fs -m 2 $METADATA_URL/v1/floating_ip/ipv4/ip_address)"
echo PUBLIC_IPV4="$PUBLIC_IPV4"
echo ANCHOR_IPV4="$ANCHOR_IPV4"
echo FLOATING_ACTIVE="$FLOATING_ACTIVE"
echo FLOATING_IPV4="$FLOATING_IPV4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment