cross-posted from: https://gekinzuku.com/post/98403
While it’s easy to get an IP address from popular websites such as whatismyip.com, it’s not often friendly to a context where you might need to get your IP address for command line tools.
In order to grab your IP address via the command line, there’s a page on a site called ipinfo.io/ip which only contains body content corresponding to your IP address. The easiest way to fetch that data is with the
curlcommand (should be available on both Windows and Linux).curl ipinfo.io/ipIt may also be beneficial to add this to your
.bashrcor.aliasrcon Linux systems with something likealias myip="curl ipinfo.io/ip"Now you have an easy way to grab your IP address from the command line!


% curl ipinfo.io/ip curl: (7) Failed to connect to ipinfo.io port 80 after 25 ms: Connection refused % curl https://ipinfo.io/ip curl: (7) Failed to connect to ipinfo.io port 443 after 29 ms: Connection refusedThey suck and apparently block curl (and lynx and elinks) from dynamic IP, it works in Firefox or on a server with static IP.
Another one is ifconfig.me/ip so
that works.
Oh I had no clue they block curl from a dynamic IP. That’s a good alternative to have!