Categories
Web

Public IP Lookup Service

A common task for an administrator is to check the public IP addresses of the current system they are on or the current system they are using. This is important both in day-to-day work and while working with cloud providers. There are many services available, but not all are created equal.

The time for checkip.dyndns.org has passed. As of today, it does not offer TLS and adds the string “Current IP Address:”. In my opinion, a better option would be a service that provides a structured return or simply returns only the IP address.

Powershell / JSON

I work more in PowerShell than in Bash or other languages. Therefore, I prefer an easy option that also offers JSON returns. I went with ipinfo.io/json, which can easily be integrated into PowerShell.

$publicIp = Invoke-RestMethod -Uri 'https://ipinfo.io/json' | Select-Object -ExpandProperty ip

Some might say that returning JSON with parsing is overkill and that using a plain IP response is preferable.

ℹ️ If you have many requests from the same IP address, ipinfo.io will rate-limit and not answer anymore. In a recent project, I had this issue. The object is very nice as it resolves ASN information, but this also comes at a higher cost for the operator in opposition to only showing the remote IP address. Keep this in mind if you start using this endpoint.

Plain IP

I’m not sure which one has an edge over the other, or if all of them are equally good. But I use and recommend those.