Road to the Bastille

Sometimes all we want is to figure out our public IP address. Sometimes life is just that simple: grab the IP and move on. But when you are in a sea of servers after navigating through a maze of SSH tunnels, where are you? What server is this?

Sure, you can just open the browser, go to the AWS console, search for that particular instance (probably takes two or three attempts until getting the correct instance name, assuming you know the right region to search for), and then figure out it only has internal addresses…

I’m too lazy to go that route again. So I made a little web server to answer that question for me: iprs.fly.dev.

Usage is straightforward: make a GET request to my hosted server at iprs.fly.dev. For example, using curl:

$ curl -L iprs.fly.dev
2804:431:c00f:feee:bee:2572:573d:c00f

😎

And if you still care about want your IPv4 instead, you can also check it out:

$ curl -L -4 iprs.fly.dev
200.232.29.121

Way easier and faster than navigating the cloud provider’s console :)

You can always force curl to use a specific IP version with -4/--ipv4 or -6/--ipv6. Whether your connection uses IPv4 or IPv6 by default depends on your local network setup and ISP, you might not even have IPv6.

The source code for this project is available at GitHub:heitorPB/ip.rs. I coded it in Rust, using Axum for the web server, built the Docker image via Nix and hosted it in a Flying Cloud.

And this is totally reinventing the wheel. There are plenty of other services online that also show your IP. And now there’s one more 🙃 So, why make it? For fun, to practice Rust, learn Axum and to have something to blog about here.