Services that just return your public IP as text

28

10

I'm writing a script that does dynamic DNS updates for me, but my server is behind a router, and so I need to use a web service to determine my public IP.

So far I've found this one which returns just your plain IP. I was looking around trying to find a couple of alternatives to use in my script supposing that that one is down, but I can't find any others that return just the IP as plaintext.

These ones return some HTML, but I really don't want to bother parsing HTML when what the script needs to do is such a simple task.

Does anyone know of some other reliable services which return only your public IP in plaintext?

Alex Coplan

Posted 2012-05-05T16:46:40.533

Reputation: 740

Question was closed 2014-12-08T12:15:16.343

Answers

37

Famous one – I can haz IP:

$ curl icanhazip.com
1.2.3.4

And that's it.

slhck

Posted 2012-05-05T16:46:40.533

Reputation: 182 472

True. It's actually the first one I really remember. – slhck – 2012-05-05T16:56:03.017

1icanhazip.com is not very reliable. Once every few times, the site doesn't answer at all. – Serge Wautier – 2012-08-21T14:06:44.477

12

I use http://checkip.amazonaws.com/

curl -s http://checkip.amazonaws.com/

(This form miscounts the above 82 characters as 15 characters, so I have to enter an extra sentence.)

ShadSterling

Posted 2012-05-05T16:46:40.533

Reputation: 1 111

I had to stop using this service last week, possibly because my ISP started doing something weird. Now I use http://ipinfo.io/ip , which is free to use for up to 1k queries/day; see http://ipinfo.io/developers .

– ShadSterling – 2015-07-29T17:07:07.723

7

Or you could host your own. Use a free hosting company, and using PHP use a code like this:

<?php

echo $_SERVER['REMOTE_ADDR'];

?>

Reacen

Posted 2012-05-05T16:46:40.533

Reputation: 229

1exactly what I was looking for! Maybe I don't want some one else logging my IPs or spamming some other log – wuxmedia – 2018-10-06T11:30:58.837

'free hosting' will most likely be logging something – Maciek Rek – 2019-08-14T11:42:37.760

1Of course I could do that, but surely there must already be plenty of services out there which do this already. – Alex Coplan – 2012-05-05T16:50:24.193

3

see page http://wtfismyip.com, http://wtfismyip.com/text actually on. Get ip address in the form of text. XML or JSON formats too.

or get http://checkip.dyndns.com/ but format is "Current IP Address: xxx.xxx.xxx.xxx"

mbi33

Posted 2012-05-05T16:46:40.533

Reputation: 31