ifconfig-rs is yet another "what's my IP address" service currently powering myip.rs. It is written in Rust (hence the "-rs" suffix) using the Rocket web framework and includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com. The UI is made with uikit. It is MIT licensed so please feel free to clone and to fork it.
ifconfig_rs offers an API to query information like the origin's IP address, TCP port, host name, geoip based location, ISP, as well as user agent. See myip.rs for API and special CLI tool support.
Table of Contents
- Features
- Another "What's my IP" service? But why?
- Customaziation
- Deployment Prerequisites
- Heroku (and other providers using load balancers)
- FAQ
- Postcardware
-
It's really fast.
-
Shows your IP address, TCP port, host name, geoip based location, ISP, and user agent.
-
Google Maps integration for geoip location
-
Special support for CLI tools like curl, httpie, and wget. API calls will be answered with just the base information followed by a newline for easy script integration.
Well, first of all, everybody should have a "What's my IP" service and I wanted to do a little web project using Rust and Rocket. I have been strongly inspired by ipd which powers iconfig.co. I've added a few details though and I think the UI is nicer.
The file Rocket.toml sets the various runtime parameters.
If you omit the runtime setting, the TCP connection's remote IP address will be presented as your IP address. In case the runtime is set to "heroku", the X-Forwarded-To
header is used to determine your IP address. In case you another runtime environment, make sure that you get the real origin IP address -- see section Heroku.
This sets the title, name etc. of the website in the index.html template file.
The base URL sets the base URL for the CLI examples.
For web server specific settings like listen IP address and port etc. please see Rocket's documentation.
You have to run make get_geoip
to retrieve the latest MaxMind geoip and ASN databases.
Heroku uses load balancers to route incoming traffic to apps. On this route, the original remote IP address is masqueraded by the load balancers. Therefore, you can not rely on the TCP connection's remote IP address to identify the request origin's IP address. If the load balancers behave like good citizens, then they add the requesters IP address to the HTTP header X-Forwarded-For
. From this list, you can gather the origin's IP address. See Heroku's documentation or google for the header field. _ifconfig_rs uses a Rocket Fairing; see fairings.rs for details.
-
The IP address is wrong! WTH?
Yes, that's possible. It turns out that determining the originating IP address of an HTTP request is not as easy as it might seem. For example, there might be transparent proxies, load balancers, and even NAT gateways on the path from your browser to ifconfig-rs. Even though, ifconfig-rs uses a heuristic to determine the originating IP address, information may be hidden or removed which might lead to wrong results. If you encouter such a scenario, open an issue on GitHub and let's try to enhance the heuristic together.
-
Where is myip.rs hosted?
The code runs on a free Heroku Autoscaling Dnyo that powers down when there are no service accesses for a period of time. This may lead to a large delay for the first request triggering a service restart.
-
Does ifconfig-rs support IPv6?
Yes. The code is agnostic regarding the IP version, Heroku currently does not support IPv6, so {{ project.name }} is only available for IPv4. You can run your own instance of ifconfig-rs at another, IPv6 supporting provider.
-
Can I run my own instance of ifconfig-rs?
Yes please, you're welcome to. Just clone or fork this repository. If you find it useful for your purpose, I would highly appreciate you sending me a postcard from your hometown mentioning how you use it. See my address.
-
Can you add <feature>, please?
Yes, why not. Just contact me and let's discuss the details. Better, do it yourself and send me a pull request.
You're free to use ifconfig-rs. If you find it useful, I would highly appreciate you sending me a postcard from your hometown. My work address is
Lukas Pustina
CenterDevice GmbH
Rheinwerkallee 3
53227 Bonn
Germany