DEV Community

Cover image for A handy way to know your public IP Address with DNS servers

A handy way to know your public IP Address with DNS servers

Aditya Thebe on March 20, 2020

Originally written in : adityathebe.com There are plenty websites that show you your public IP address when you visit them. The simplest way wou...
Collapse
 
mburszley profile image
Maximilian Burszley • Edited

If on Windows, you can use PowerShell to execute these same commands, e.g.:

# get site entries
Invoke-RestMethod -Uri https://api.ipify.org

# get dns entries
Resolve-DnsName -Name myip.opendns.com -Server resolver1.opendns.com
Collapse
 
anhduc720 profile image
Le Anh Duc

My favorite way

curl ifconfig.io
Collapse
 
sriganesh profile image
Sri ganesh

Hey, I made something similar recently which I hope is easy to remember.

$ curl ipaddress.sh
151.101.2.217

More info: about.ipaddress.sh

Collapse
 
aleksandrhovhannisyan profile image
Aleksandr Hovhannisyan

You can also do what I do and Google:

my ip

Collapse
 
adityathebe profile image
Aditya Thebe

Sure that's convenient but I was mainly focusing on scripting purposes.

Collapse
 
m15terhyde profile image
M15terHyde

this method, unless you're using quic, runs over tcp so it requires setting up a tcp connection. dns runs over udp so it can be faster since there is no connection setup.