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

Support CNX Software! Donate via PayPal or cryptocurrencies, become a Patron on Patreon, or buy review samples

Notify of