How to obtain public ip address using windows command prompt? How to obtain public ip address using windows command prompt? shell shell

How to obtain public ip address using windows command prompt?


Use the Invoke-WebRequest module in powershell. For example:

Invoke-WebRequest ifconfig.me/ip

Source

Edit: I misread the question and thought you needed to use Powrshell.

There is no built in command in cmd.exe to return a public IP address. But you can use nslookup to resolve it, like so;

nslookup myip.opendns.com. resolver1.opendns.com

Another option for the OP:

telnet curlmyip.com 80

Type "GET" after you are connected.

Note: telnet is not installed/enabled by default on Windows.

Source


Simplest way is fire following command

curl "http://myexternalip.com/raw"

& You Will get public IPV4.


This command works for me:

nslookup myip.opendns.com. resolver1.opendns.com