Various Ways to Determine Public IP on Linux CLI

Always when you are working a lot with CLI environment, Linux particularly, you would like to know the public IP address especially when you were running on NAT environment. Here is a list of command that you can use to determine the public IP of your host via command line.

Using curl

cURL is mostly available on all Linux distributions, and is the most popular way to determine public IP address of the host. You just need to know the URL or host that will response with the correct public IP as per below:

$ curl
$ curl
$ curl
$ curl
$ curl

Using wget

Basically, command executed on curl can be replace with wget -qO- option, as per below:

$ wget -qO-

Using Lynx

Lynx is a text-based browser which runs like a browser for your CLI

$ lynx # you will be redirected to a text-based browser

If you have the simplest method apart from what being mentioned here, please share it. I can’t imagine how simple it would be!


Leave a comment

Leave a Reply

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