Show your external IP address on the command line:

`# curl -s https://ipinfo.io | jq -r .ip`
`1.2.3.4`

I use this a lot.

#cli #bash #curl

IPinfo | The Trusted IP Data Provider for Developers & Enterprises

IPinfo delivers fast, accurate, and reliable IP data to power fraud detection, geolocation, analytics, and more. Trusted by over 500,000 developers.

@tdp_org Well, that sure is a lot better than what I've currently got ddclient configured to use:

use=cmd, cmd='curl --silent --interface enp130s0 http\://checkip.dyndns.com/ | perl -ne \'chomp; if (s/.*\\b([1-9][0-9]*\\.[1-9][0-9]*\\.[1-9][0-9]*\\.[1-9][0-9]*)\\b.*/$1/){print;exit}\''

@jik @tdp_org

any added value over the old
curl icanhazip.com
trick?

@tdp_org Actually, it occurs to me that even if I use ipinfo.io instead of checkip.dyndns.com, I still need to specify --interface enp130s0 to curl, because otherwise I get back the egress IP of my VPN, which is not actually what I want.
@jik
A little bit shorter will be the command curl ipcfg.co or curl -4 ipcfg.co or curl -6 ipcfg.co
@tdp_org

@yala @jik @tdp_org @braindance

I use dig instead of curl,
to a DNS host instead of website. I've used the same command for a decade.

https://unix.stackexchange.com/a/81699

These "my IP" sites tend to be short lived, slow, compete for SEO, filled with ads, or otherwise change/break. This means you end up searching the web first for the right site instead of just running the command.

How can I get my external IP address in a shell script?

I need to find my external IP address from a shell script. At the moment I use this function: myip () { lwp-request -o text checkip.dyndns.org | awk '{ print $NF }' } But it relies on perl-lib...

Unix & Linux Stack Exchange
@tdp_org I've got https://ip.eternallybored.org/ set up; if the user agent contains curl, it'll return just the IP address :)
IP: 49.13.113.46

What's my IP address and user agent

@tdp_org I like icanhazip.com because it just returns the raw IP

@tdp_org I usually use curl ifconfig.co for that. They also gave JSON output for more details: curl ifconfig.co/json

https://ifconfig.co

What is my IP address? — ifconfig.co

ifconfig.co • What is my IP address? — The best tool to find your own IP address, and information about it.

@tdp_org I like this site better. It has swearing, so it's obviously better.
```
curl https://wtfismyip.com
```
WTF is my IP?!?!??

Tells you WTF your IP address is

@tdp_org curl ip.me. Save your fingers.