Find My Public IP: Difference between revisions

From DN Wiki
Jump to navigation Jump to search
(Created page with " Three CLI commands to find your public IP address. <pre> > echo $(curl -s https://api.ipify.org) 11.22.33.44 # echo is just to add \n to the end > dig +short myip.opendns.c...")
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
Generally, you'll tell the user to go to Google and search for "my ip" but Google doesn't put IP box at the top of the results any more and sometimes you want a CLI way to do it.


Three CLI commands to find your public IP address.
 
 
CLI commands to find your public IP address.


<pre>
<pre>
> curl icanhazip.com
11.22.33.44
> echo $(curl -s https://api.ipify.org)
> echo $(curl -s https://api.ipify.org)
11.22.33.44
11.22.33.44
Line 12: Line 18:
> dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
> dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
"11.22.33.44"
"11.22.33.44"
# same as above, but nslookup for Windoze
> nslookup myip.opendns.com resolver1.opendns.com
Server:  resolver1.opendns.com
Address:  208.67.222.222
Non-authoritative answer:
Name:    myip.opendns.com
Address:  11.22.33.44
</pre>
PowerShell:
<pre>
  (Invoke-WebRequest 'http://icanhazip.com/').Content
</pre>
Which can be shortened to
<pre>
  (iwr 'http://icanhazip.com/').Content
</pre>
</pre>

Latest revision as of 03:24, 26 August 2023

Generally, you'll tell the user to go to Google and search for "my ip" but Google doesn't put IP box at the top of the results any more and sometimes you want a CLI way to do it.


CLI commands to find your public IP address.

> curl icanhazip.com
11.22.33.44

> echo $(curl -s https://api.ipify.org)
11.22.33.44
# echo is just to add \n to the end

> dig +short myip.opendns.com @resolver1.opendns.com
11.22.33.44

> dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
"11.22.33.44"

# same as above, but nslookup for Windoze
> nslookup myip.opendns.com resolver1.opendns.com
Server:  resolver1.opendns.com
Address:  208.67.222.222

Non-authoritative answer:
Name:    myip.opendns.com
Address:  11.22.33.44

PowerShell:

  (Invoke-WebRequest 'http://icanhazip.com/').Content

Which can be shortened to

  (iwr 'http://icanhazip.com/').Content