[nmglug] How can I use CLI to find my public IP address in IPv4 vs IPv6?

Akkana Peck akkana at shallowsky.com
Mon May 13 16:57:56 PDT 2024


Hi, LeRoy,

dig, host and curl all use a -4 flag to connect using IPv4. So:

curl -4 icanhazip.com

dig -4 +short myip.opendns.com @resolver1.opendns.com

host -4 myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'

If you don't have dig, it's just an apt install away (or whatever equivalent command your distro uses).

What "crap" do you get from the host command?

All of these commands worked for me (and gave me IPv4 when I added -4).

        ...Akkana

LeRoy Diener writes:
> Hi NMGLUG folks,
> 
> I am familiar with using https://ipchicken.com/ to find my public IP
> address using the browser.
> I would like to verify my public IP address using CLI as well as the
> browser.
> I found this
> page https://www.tecmint.com/find-linux-server-public-ip-address/ with
> 4 ways.
> The web page (last updated July 2023) shows that the results are in
> IPv4, but my results are in IPv6.
> I tried all four ways.
> >From the dig command, I get "bash: dig: command not found"
> >From the host command, I get crap. When I remove the pipes I get stuff
> including an IPv6 address.
> >From the wget and curl commands, Iget an IPv6 address.
> The IPv6 address from 5 variations of wget and curl are all the same.
> The IPv6 address from host is different.
> I like curl ifconfig.me because it is easy to remember.
> 
> Here's the problem.
> I would like to verify my public IP address using CLI as well as the
> browser.
> >From ipchicken in the broswer, I get IPv4.
> >From the CLI, I get IPv6.
> How can I verify my public IP address?
> 
> In gratitude,
> LeRoy
> -- 
> There is something glorious birthing within all of us.
> I am the Love of God, no matter what.BSA
> LeRoy Diener
> 213-LEROYIZ
> 213-537-6949
> https://leroydiener.com

> _______________________________________________
> nmglug mailing list
> nmglug at lists.nmglug.org
> http://lists.nmglug.org/listinfo.cgi/nmglug-nmglug.org



More information about the nmglug mailing list