Skip to content

Instantly share code, notes, and snippets.

@afelicioni
Created April 4, 2021 20:57
Show Gist options
  • Save afelicioni/ded0f5e5fd3798bdfd9b61bbd00b43ac to your computer and use it in GitHub Desktop.
Save afelicioni/ded0f5e5fd3798bdfd9b61bbd00b43ac to your computer and use it in GitHub Desktop.
get public ip using curl, awk leveraging cloudflare trace endpoint
#!/bin/bash
IP=$(curl --location --request GET 'https://www.cloudflare.com/cdn-cgi/trace' 2>/dev/null | awk 'BEGIN { FS = "=" } ; $1 == "ip" { print $2 }')
echo $IP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment