Linux Scripts to find Public IP Address

In some cases, you may need to know your public IP or the public IP of a server behind a NAT (e.g. for remote SSH login) if the IP is assigned dynamically as is the case for PPPoE connections.

Here are several ways to find your public IP in Linux using the shell.

1. Using curl (almost too simple)

curl -s http://www.whatismyip.org

2. Using wget

wget -q -O – checkip.dyndns.org|sed -e ‘s/.*Current IP Address: //’ -e ‘s/<.*$//’

3. Using lynx

lynx -dump checkip.dyndns.org

If you have access to a web browser, you can simply use http://www.whatismyip.org, http://checkip.dyndns.org or http://www.moanmyip.com.

Share this:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress. We also use affiliate links in articles to earn commissions if you make a purchase after clicking on those links.

Radxa Orion O6 Armv9 mini-ITX motherboard

Leave a Reply

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

Boardcon LGA3576 Rockchip RK3576 System-on-Module designed for AI and IoT applications
Boardcon LGA3576 Rockchip RK3576 System-on-Module designed for AI and IoT applications