Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on gekinzuku.com
code_monkeys·Code Monkeysbygraham1

YSK how to get your IP address from the command line

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 curl command (should be available on both Windows and Linux).

curl ipinfo.io/ip

It may also be beneficial to add this to your .bashrc or .aliasrc on Linux systems with something like

alias myip="curl ipinfo.io/ip"

Now you have an easy way to grab your IP address from the command line!

View original on gekinzuku.com
1

3 replies

gekinzuku.com

I like it, it's more simple than what I've been using:

curl --silent https://geolocation-db.com/json/ | jq .IPv4 -r
2

Oh jeeze yeah I have a hard enough time remembering ipinfo.io/ip, so I would never be able to remember what you had lol

2

You reached the end