Find My Public IP Address From Linux Command Line

#!/bin/bash # You can also use the Google server to get the same info using dig command # dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{ print $2}' myip="$(dig +short myip.opendns.com @resolver1.opendns.com)" echo "My WAN/Public IP address: ${myip}"

2 Responses

this is other very simple way:
wget -qO - ipecho.net/plain; echo
Your way is very fast, I like it

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.