Many services and applications require you to know your external (WAN) address.  There are plenty of web sites that allow you to do this, but here are a couple of simple ways to do this from the line in .

The first method uses the cURL utility, which is basically a command-line utility for retrieving data using URL syntax.  In or , you can cURL from the repositories using the command:

1
sudo apt-get install curl

After installing cURL, just run this command to get your external IP address:

1
curl ifconfig.me/ip

You can replace ifconfig.me with other service hostnames/URLs, such as:

  • whatismyip.org
  • icanhazip.com
  • tnx.nl/ip
  • myip.dnsomatic.com
  • ip.appspot.com
  • checkip.dyndns.org:8245
  • whatismyip.com
  • jsonip.com

The second method is really a variation on the one above and uses the wget command. You can use the same hostnames/URLs as above with this command:

1
wget -qO- ifconfig.me/ip

Have fun! And let me know your tips for this in the comments.

Print Friendly

Comments

comments

Bài viết liên quan