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:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX RK3588 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
0 Comments
oldest
newest
Khadas VIM4 SBC