Categories
Troubleshooting

How to Find Public IP Address from CLI

Often, an IP address is hidden behind a proxy or NAT. Here is how you can tell the public IP:

Using Curl to check Public IP:


curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

Check Public IP with Curl

Using Telnet to check Public IP:


telnet www.checkmyip.com 80 | grep confidence | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'

Check Public IP with Telnet

Using wget to check Public IP:


wget -O - -q icanhazip.com

Find Public IP with wget

Using lynx to find Public IP Address:


wget -O - -q icanhazip.com

Find Public IP with lynx

6 replies on “How to Find Public IP Address from CLI”

I don’t know cisco, but a 30 second google found commands like ‘show ip route’ and ‘show ip interface’ that will point you in the right direction. I believe you can pipe to ‘include’. I don’t have a cisco anything to test on though. I’m sure one of the other readers knows off the top of their head 🙂

You can also use the following command to get external IP address
nslookup myip.opendns.com resolver1.opendns.com
Server: resolver1.opendns.com
Address: 208.67.222.222
Non-authoritative answer:
Name: myip.opendns.com
Address: 208.81.257.8 <—– External IP Address

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.