Created
April 4, 2021 20:57
-
-
Save afelicioni/ded0f5e5fd3798bdfd9b61bbd00b43ac to your computer and use it in GitHub Desktop.
get public ip using curl, awk leveraging cloudflare trace endpoint
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 | |
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