• DE
  • ES
  • EN
  • NL
Google+twitterfacebook

Blog

What's my IP address? - Now easy to remember curl command line++


Published on Tuesday October 3, 2017 by Jeroen Derks.

Many times when I checking for example access or error logs, I need to know my public or external IP address (these days most people by now should be using NAT at home because their Internet access router configures it out of the box so that they cannot simply use ifconfig or ipconfig to see which IP address is in use).

To do so I would have more or less two options:

  1. Retrieve the public IP address from the router, or
  2. Consult an external server to provide me with the external IP address I'd be using to access that server.

Since routers come in many brands, types and operating systems, it is not generally possible to retrieve any information from it in a standard way. Furthermore, you might just be a simple user of the network that is not responsible for the network administration and as such you would not have access to the router to begin with.

So, that leaves us with the second option. There are many websites that provide a service for you to know your remote IP address, optionally with additional information such as your location, browser, supported languages, screen size, and what not. For me the most used sites are whatsmyip.net, whatsmyip.org and whatsmyip.com, but there are many more.

However, I'm to lazy to open a tab in my browser and type any of those URLs, I'm faster with the command line... ☺

Instead I wrote a simple PHP script to help me with that. The result is in.je/ip, which you can easily call using curl or wget:

  • curl in.je/ip
  • wget -qO - in.je/ip


Example:

jeroen@dev:~$ time curl in.je/ip
66.249.76.156

real    0m0.103s
user    0m0.007s
sys     0m0.007s

So it complies with the first requirement of working from the command line, where you can for example pipe it into a different program if necessary.

Also, it supports different kinds of output data and formats, such as binary, DNS, GeoIP information, HTML, Javascript, PHP, shell scripts, API, XML or SOAP requests, etc. For example to do reverse DNS lookup just use:

jeroen@dev:~$ curl in.je/ip/rdns
crawl-66-249-76-156.googlebot.com

Please go to in.je/ip to read about all the features.

Enjoy!

If you have any improvement or suggestion to share, please leave a message via the link below.

Please let me know if this article has been useful to you! (or not)