4 ms·
I didn't know about the /cdn-cgi/trace Cloudflare trick. Here's a one-liner to print just the ip via curl: curl -s cloudflare.com/cdn-cgi/trace | grep ip | c
by ksbrooksjr 5y ago
I didn't know about the /cdn-cgi/trace Cloudflare trick. Here's a one-liner to print just the ip via curl:
curl -s cloudflare.com/cdn-cgi/trace | grep ip | cut -d "=" -f 2 --
- stevekemp 5y agoYou could use awk instead of grep & cut: curl -s cloudflare.com/cdn-cgi/trace | awk '{FS="="} /ip/ {print $2}'
- luismedel 5y agoAnd sed: curl -s cloudflare.com/cdn-cgi/trace | sed -nr "s/^ip\=(.+)$/\1/p"
- btgeekboy 5y agoThat may return IPv6 if you have IPv6 connectivity, which might not be what you're looking for. I just do this, myself: IP=`curl -s checkip.amazonaws.com`
- I_complete_me 5y agoWhat do those -- at the end do? I get my IP without them.