It will work. The server will return JSON. The URL http://ipinfo.io/ returns HTML if the Accept header indicates that you want HTML, and JSON if there is no header, a wildcard header, or a header that requests JSON. As far as I can see, irm doesn’t add an Accept header, so the command jodrellblank provided will fetch JSON and work correctly.
Perhaps you ought to open one for Norway? (I don't think it would be appropriate for me to do it because I am not seeing the issue, not being in Norway.)
Free version of MaxMind's GeoIP - a lot of services use them but the free version is the most inaccurate. That being said, not sure it's a mistake on the EU thing?
Presuming that the "in-EU" is actually meant to refer to "subject to most EU legislation, and in particular the GDPR", then it's incorrect in the opposite way for Norway: it shows false.
Looks great but these services have a tendency to come and go. Bad actors just end up hammering it. But I've been using icanhazip.com for years and it's still going strong.
I tend not to use these sort of services except for quick hack purposes, which I suppose this is exactly designed for. Unfortunately, those needs vary so widely I can't try to keep track of these sort of services and just Google/DDG for something similar when I need it. Unless this pops up on the first page of a Google/DDG search, it's unlikely I'll ever use it.
If the software behind the service is available and looks like it'll be easily usable for years because it has few to no dependancies that are likely to deprecated, I might actually commit the effort to memory and use it for all similar demands, similar to how I keep track of specific CLI *nix tools which I can rest assured, even if there are no updates and potential security issues, most are going to be usable at some future date in a pinch.
But seriously, it's basically a front end to a bunch of people who have been incentivized (or fooled) into installing a proxy server on their home computers. It's primarily of interest as a way to make certain types of fraud (like ad fraud and credit card fraud) much harder to detect.
Pro of icanhazip.com is that you can curl it directly, it returns your address and nothing else; you don't have to parse the result to get the value, which is a big plus when used in a script:
For a service like this one, it is essential not to automatically redirect to https, because many simple and/or command line clients do not automatically follow (resolve) a HTTP redirect answer.
Put it another way, if you cannot lookup dns, odds are curl won't work. Of course, some nets might require the use of internal dns servers and block outbound traffic to dns.
It's very good that it doesn't redirect to HTTPS. I frequently work with little devices which have a curl/wget version that only supports very basic HTTP, but no HTTPS. It's always a pain to find a website which will work with that.
For the benefit of anyone interested: for a "self-hosted" solution, you can do this entirely within Nginx. Here's an example config:
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 default_server;
listen [::]:443 default_server;
# Use Letsencrypt for SSL. This part will depend on your own setup.
ssl_certificate /etc/letsencrypt/live/<my domain>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<my domain>/privkey.pem;
server_name <my domain>;
# Deny all access at all paths; useful if you're hosting other stuff behind
# the same Nginx server (e.g. reverse proxy)
location / {
deny all;
}
# At /ip, return 200 with the client IP address in the body
location = /ip {
default_type text/plain;
return 200 '$remote_addr';
}
}
this service does a lot more than just return your remote_ip, which wont work behind a load-balancer or other proxy unless you configure realip module. and also need to add geoip module to do all the location stuff
That said, do you know of any software library that exposes the Geoip database (or at least Geoip Lite which you one easily obtain for free) in a nice API? Like how a lot of programming languages have tzinfo/tzdata libraries for querying the Tz database.
I should clarify that I was looking for an "offline" API/library that I can use against a local copy of the Lite database, but this is great stuff too.
I thought maxmind has some kind of terms change that forced account signup and some other issues 'because of some privacy law' like gdpr - maybe the Cali one?
So it has ruined my second favorite wordpress security plugin - and MaxMind not really usable like it once was (?)
That's exactly what I use it for. I have a small program on my laptop that makes a request of my lambda every now and then (and if it senses a change of the network). It triggers a change in the firewall rules for a SSH server.
Between that and Mosh, I barely even notice when I change networks.
One more reason to love that extraordinary web server. It is really wonderful, sad that it is not more used.
I work in IT (was a sysadmin for years, still administer my own servers) and I hated the configuration of the web servers (first Apache, then nginx) - mostly because I was too lazy to read the docs from beginning to end.
This changed with caddy. It is simple, fast, reliable, HTTPS first with LE. Great.
I mean, if you really really want my IP, you need to at least be asking for microphone or video permissions... otherwise, you are only going to get my default route! I work on a VPN product, and threw this together to get all my IP addresses, VPN be damned ;P. https://rv.saurik.com/wtfip/
For what it is worth, I have found that the STUN protocol is also an option for discovering this sort of information. There are lists of public stun servers out there [0]. Finding a client is a little more difficult than just using curl, I grant, but not impossible.
I wish sites would prefer browser-provided location to services like these. I'm constantly being placed in some random city five or six hundred km away, where my ISP also happens to have customers, even though I have Firefox configured to report accurately (geo.provider.network.url = data:application/json,{"location":{"lat":43.5,"lng":-80.5},"accuracy":1000}).
Slightly OT: Some similar services also expose useful data like if IP is a VPN, a threat/bot, hosting provider or ISP, or a proxy.
I always wondered where this info comes from, looking at the similar pattern I presume from the same provider. Is it a premium service from MaxMind or what?
I had some auto-tests for VPN app which were relying on similar web-service to check own IP address. One day service become unavailable and autotests got broken. IIRC it was (https://canihazip.com/s)
I decided to solve this task in a fast and reliable fashion, so I made a tool which discovers own IP address using major public STUN servers: https://github.com/Snawoot/myip
Program issues parallel queries to public STUN servers to determine public IP address and returns result as soon as quorum of matching responses reached.
Works fast and reliable, especially compared to services requiring HTTPS:
user@dt1:~> time curl https://api.ipify.org
45.152.165.44
real 0m2,515s
user 0m0,030s
sys 0m0,019s
user@dt1:~> time curl ifconfig.co/
45.152.165.44
real 0m0,131s
user 0m0,011s
sys 0m0,008s
user@dt1:~> time myip
45.152.165.44
real 0m0,084s
user 0m0,012s
sys 0m0,012s
handy thing yeah - I used this like 6 years ago to write some quick bash scripts that would grab dynamic IP changes and send them to cloudflare to update a DNS record and create our own dynamic DNS service!
134 comments
[ 4.4 ms ] story [ 203 ms ] threadYou can even lookup info for other up addresses. E.g. https://ipinfo.io/1.1.1.1
Your example doesn't work. It needs to be:
Your other example can be get like this:And JSON: https://ifconfig.co/json?ip=1.2.3.4
> Country United Kingdom
> Country (ISO code) GB
> In EU? true
Well, that's inaccurate for a start.
Has the UK data protection law deviated significantly from GDPR?
But if that's the reason, it should be labelled as such: "GDPR applies" or something.
https://github.com/mpolden/echoip/issues/130
Perhaps you ought to open one for Norway? (I don't think it would be appropriate for me to do it because I am not seeing the issue, not being in Norway.)
Free version of MaxMind's GeoIP - a lot of services use them but the free version is the most inaccurate. That being said, not sure it's a mistake on the EU thing?
The free DB has to be re-downloaded monthly IIRC.
If the software behind the service is available and looks like it'll be easily usable for years because it has few to no dependancies that are likely to deprecated, I might actually commit the effort to memory and use it for all similar demands, similar to how I keep track of specific CLI *nix tools which I can rest assured, even if there are no updates and potential security issues, most are going to be usable at some future date in a pinch.
https://lumtest.com/myip.json
https://lumtest.com/echo.json
It's powered by largest residential proxy network so they almost certainly never gonna ban your IP.
But seriously, it's basically a front end to a bunch of people who have been incentivized (or fooled) into installing a proxy server on their home computers. It's primarily of interest as a way to make certain types of fraud (like ad fraud and credit card fraud) much harder to detect.
curl wtfismyip.com/json
This service also works perfectly fine with https://ifconfig.co/
[0] https://ipchicken.com/
(And this ifconfig.co doesn't seem to actually, you know, work which is a big hindrance)
$ nslookup myip.opendns.com resolver1.opendns.com
$ dig +short @resolver1.opendns.com myip.opendns.com
$ curl ifconfig.me
129.6.255.60
$ curl ifconfig.me/all
ip_addr: 129.6.255.60
remote_host: unavailable
user_agent: curl/7.68.0
port: 52332
For the benefit of anyone interested: for a "self-hosted" solution, you can do this entirely within Nginx. Here's an example config:
That said, do you know of any software library that exposes the Geoip database (or at least Geoip Lite which you one easily obtain for free) in a nice API? Like how a lot of programming languages have tzinfo/tzdata libraries for querying the Tz database.
https://dev.maxmind.com/geoip/geoip2/web-services/
https://pypi.org/project/geoip2/
So it has ruined my second favorite wordpress security plugin - and MaxMind not really usable like it once was (?)
https://dev.maxmind.com/geoip/geoip2/geolite2/
In practice it's good enough for many purposes. It's actually the version of the database that ifconfig.co uses.
Of course, AWS provides this basic service as checkip.amazonaws.com
Between that and Mosh, I barely even notice when I change networks.
Caddyfile:
[0] https://caddyserver.com/docs/caddyfile/directives/respond[1] https://caddyserver.com/docs/caddyfile/concepts#placeholders
I work in IT (was a sysadmin for years, still administer my own servers) and I hated the configuration of the web servers (first Apache, then nginx) - mostly because I was too lazy to read the docs from beginning to end.
This changed with caddy. It is simple, fast, reliable, HTTPS first with LE. Great.
[0]: https://gist.github.com/mondain/b0ec1cf5f60ae726202e
https://dev.maxmind.com/geoip/geoip2/web-services/
Referring of course to the new Linux commands "ip a sh". :)
I hope he gets around to deploying it properly some day.
I always wondered where this info comes from, looking at the similar pattern I presume from the same provider. Is it a premium service from MaxMind or what?
There used to be one at ifconfig.dev but I don’t know what happened to it
IPv4: curl http://whatismyip.akamai.com curl http://whatismyip.akamai.com/advanced
Both hosts are distributed around the world using the Akamai platform and should be fast for everyone.
I decided to solve this task in a fast and reliable fashion, so I made a tool which discovers own IP address using major public STUN servers: https://github.com/Snawoot/myip
Program issues parallel queries to public STUN servers to determine public IP address and returns result as soon as quorum of matching responses reached.
Works fast and reliable, especially compared to services requiring HTTPS:
ifconfig.io https://news.ycombinator.com/item?id=17168415
ifconfig.in https://news.ycombinator.com/item?id=4070133
ifconfig.me https://news.ycombinator.com/item?id=6429921
ipinfo.io https://news.ycombinator.com/item?id=5604476