I’ve always liked how the site ifconfig.me (down today it seems) returns JUST the IP address from command line when accessed via CURL. Unfortunately it is not IPv6 enabled. This morning I set out to CLI-enable ipquail.com. The journey is documented in this short commit history.
$ for i in www 4 6; do \ echo -n "curl $i.ipquail.com => " curl $i.ipquail.com done curl www.ipquail.com => 2604:4280:d000:11::5 curl 4.ipquail.com => 184.108.40.206 curl 6.ipquail.com => 2604:4280:d000:11::5
This can be used in scripts as well:
#!/bin/bash IP4=`curl 4.ipquail.com 2>/dev/null` IP6=`curl 6.ipquail.com 2>/dev/null` echo "Your IP Address is $IP4" echo "Your IPv6 Address is $IP6"
I deployed the new files to all Anycast nodes using SaltStack as described in my previous post.
Note: This only works if you are NOT changing the default curl user agent, if you are, you would need to specify curl as your user agent using the -A flag for curl.