To find the your public IP address from command line (CLI) you can use the below commands for Linux and Windows Operating systems.




These 2 commands will generate web request and show the ip address as the response of the request.


dig +nocomments +noquestion +noauthority +noadditional +nostats | grep -oE “\b([0-9]{1,3}\.){3}[0-9]{1,3}\b”

This command runs DNS query and show the resolved ip address. The dns query to using the DNS resolver outputs the public IP address from where the DNS query is generated.

Please note the period (.) at the end of the, this makes sure that the DNS suffix is not added to the query and query is absolute.


nslookup | find “Address”

This outputs two IP addresses and the second IP address will be your public IP address