back
130 comments
It's great to have services like this.

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';
      }
    }
It is even easier with Caddy's `respond` directive[0], placeholders[1], and automatic HTTPS.

Caddyfile:

  example.com {
      respond "{remote_host}"
  }
[0] https://caddyserver.com/docs/caddyfile/directives/respond

[1] https://caddyserver.com/docs/caddyfile/concepts#placeholders

Along the same lines, if you want to make your own AWS Lambda /API Gateway version of this:

    def lambda_handler(event, context):
        return {
            'statusCode': '200',
            'headers': None,
            'body': event.get('requestContext', {}).get('identity', {}).get('sourceIp', 'unknown')
        }
I do this, though my lambda is a bit more complex in practice, since I have some triggers that say "if this thing reports a new IP, do something".

Of course, AWS provides this basic service as checkip.amazonaws.com

This can also be done with HAProxy

    listen whatismyip
        bind :::80 # listen on ipv4/ipv6
        bind :::443 ssl crt /etc/haproxy/ssl/fullchain.pem
        mode http

        http-request return status 200 content-type "text/plain" lf-string "%[src]" if { path /ip }
        http-request return status 200 content-type "application/json" lf-string "{\"ip\":\"%[src]\"}" if { path /json_ip }
        http-request deny
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
You can even have the JSON version:

    location /json_ip {
        default_type application/json;
        return 200 "{\"ip\":\"$remote_addr\"}";
    }
been using this for few years. As far as I know, can't return IPv4/IPv6 only from nginx without using separate server block to enforce one of them
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.

I've been using ipecho.net for a while as well. Just ipecho.net/plain to get your IP back in plaintext. Not affiliated, just what I've been using.
I've been using ifconfig.me for a decade or more.
http://icanhazip.com/ is my favourite one of these services, for simplicity and also as I can always remember the URL :)
I use https://wtfismyip.com/ for similar reasons :)
I wonder how much more it will take before the answer to "What is my IP address?" will simply be "Look in the settings" or "Just type ip addr in the terminal".

We are so used to NAT that we don't realize how crazy it is that you essentially have to ask a stranger what's your address. It's really difficult to explain this to someone with no networking knowledge. Nothing else works this way: phone numbers, emails or postal addresses.

I run eth0.me - a similar service. This might be the IP lookup service with the shortest URL, which is the reason why I run it.

Some anecdotes:

-At the moment the service has 10 GiB of traffic/day. In February, there were 295 476 879 requests.

-Because the service returns only the IP address and nothing else, the requests are larger than the replies.

-At some point a russian ISP began querying eth0.me from (apparently) all of their eyeball routers. Thousands of devices from their address space would query this service every second, which resulted in many Terabytes of traffic monthly. I decided to block their address space.

This service was run by somebody else up until a few years ago. It became more and more unreliable and went offline. At some point I noticed that the domain had expired. I decided to buy it and run it myself.

If someone want non-rate-limted IP info here is:

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.

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
I prefer ipinfo.io

You can even lookup info for other up addresses. E.g. https://ipinfo.io/1.1.1.1

Here is my favorite. only using DNS:

$ nslookup myip.opendns.com resolver1.opendns.com

I don't know where this is pulling data from, but:

> Country United Kingdom

> Country (ISO code) GB

> In EU? true

Well, that's inaccurate for a start.

Nice, I'm gonna miss the chicken [0] though... or not, the IP chicken is very easy to remember.

[0] https://ipchicken.com/

My 2cents:

  http://checkip.amazonaws.com/

  http://whatismyip.akamai.com/

  dig +short myip.opendns.com @resolver1.opendns.com
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.

[0]: https://gist.github.com/mondain/b0ec1cf5f60ae726202e

https://ifconfig.me/

$ 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

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.
There are a billion hacker-friendly ways to do this: https://unix.stackexchange.com/q/22615/14305
Similar service but with a frontend web development focus: https://whatsmybrowser.info/
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/
http://f3.to/ip/ https://f3.to/ip/

in case you just want to import a string. No headers either. (I'm lazy, so this is what I use to get an external IP for my robots)

I just use the maxmind API directly, which is super cheap and has no rate limit to my knowledge. This site is using the maxmind dataset anyways.

https://dev.maxmind.com/geoip/geoip2/web-services/

https://httpstat.us/ and https://readme.localtest.me/ are similarly useful, trivially simple websites that are hacker-friendly.
I'm happy with https://www.ipify.org/ - supports plaintext and JSON, v4 or v6, etc. via changes to the URL, so it works without having to set custom headers or telling your client to use one or the other.
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 know a guy who owns the domain ipa.sh that he intended to use as a replacement for ifconfig.me because it was slow and unavailable a lot.

Referring of course to the new Linux commands "ip a sh". :)

I hope he gets around to deploying it properly some day.

I miss being able to type “IP” into google and have it just tell you your IP address above the first result.

Now, all you get is a bunch of spammy sites that block you with a captcha then fill the page with ads.

Hopefully his thing rises to the top of the results.

Very sad to say, there is a massive hole in its upkeep with recent events.

In EU? true Region England

I made something similar but simpler which just returns the IP address. It also supports formats like json https://ipcheck.fun/
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!
and this is why no one will use this substantially EVER: it's down already.

Error 1020 - Access denied

What happened? This website is using a security service to protect itself from online attacks.

You can also hit v4.ifconfig.co to force ipv4
is the "Is EU?" flag up-to-date? a UK Ip address yields true, Switzerland one yields false
> Country: United Kingdom

> In EU?: true

How very 2019.

It incorrectly reports the UK is in the EU!
Just duck it

https//ddg.gg?q=my+ip

Not sure I'd trust the expertise of someone who doesn't know how to redirect to https...