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

2. Using wget

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

3. Using lynx

lynx -dump

If you have access to a web browser, you can simply use, or

Share this:

Support CNX Software! Donate via cryptocurrencies or become a Patron on Patreon

Leave a Reply

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