How to get a public IP address from the command line

Sometimes, it needs to figure out what IP a server has but the server doesn’t have GUI or web browser blocked (or not installed). The examples below contain a way of obtaining public IP via CLI.

In the Windows environment you can use the next commands in the Powershell:

Resolve-DnsName -Name myip.opendns.com -Server resolver1.opendns.com

nslookup myip.opendns.com resolver1.opendns.com

(Invoke-WebRequest -Uri 'ifconfig.co/ip').Content

The classic Windows command line works only with this command:

nslookup myip.opendns.com resolver1.opendns.com

In the Linux environment you can use the next commands in the shell:

wget -O - -q ifconfig.co/ip

curl ifconfig.co/ip

host myip.opendns.com resolver1.opendns.com

๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡
๐Ÿ’ฌDiscuss or ask a question in the Telegram๐Ÿ’ฌ

๐Ÿ“•ะงะธั‚ะฐั‚ัŒ ัั‚ัƒ ะถะต ัั‚ะฐั‚ัŒัŽ ะฝะฐ ั€ัƒััะบะพะผ ๐Ÿ‘‰ https://dzen.ru/media/samsitblog/kak-uznat-vneshnii-ip-adres-cherez-komandnuiu-stroku-64ccc74b4a27621bc21027e3


by

Tags: