

ping `curl whatismyip.akamai.com` - TazeTSchnitzel
http://whatismyip.akamai.com/

======
hrbrmstr
From the methods outlined in the thread so far, I think I'd pick Akamai after
a quick test of each of them. (results in the following are based on the
'real' value returned in a 'time' command

    
    
      Google 'ping' "baseline" from my ISP
         20 packets transmitted, 20 packets received, 0.0% packet loss
         round-trip min/avg/max/stddev = 19.858/23.823/31.484/2.593 ms
    
      #/SITE/METHOD
      #1: myip.opendns.com (dig)
      #2: whatismyip.akamai.com (curl)
      #3: ifconfig.me (curl)
      #4: ip.nux.ro (curl)
      #5: icanhazip.com (curl)
    
      RESULTS
    
      #1      #2      #3      #4      #5
      0.051   0.144   3.45    0.24    0.333   
      0.05    0.143   7.229   0.237   0.106   
      0.053   0.147   1.986   0.246   0.103   
      0.047   0.143   7.065   0.246   0.109   
      0.045   0.145   2.15    0.257   0.102   
      0.046   0.141   4.301   0.273   0.113   
      0.05    0.141   2.763   0.242   0.103   
      0.048   0.144   3.685   0.251   0.114   
      0.045   0.149   15.312  0.256   0.195   
      0.047   0.148   5.091   0.244   0.118   
      0.044   0.144   2.637   0.248   0.133   
      5.038   0.142   1.535   0.247   0.109   
      0.049   0.143   7.065   0.238   0.115   
      0.044   0.146   4.098   0.241   0.106   
      0.05    0.145   1.665   0.248   0.216   
      0.05    0.142   1.365   0.261   0.108   
      0.051   0.143   2.509   0.256   0.159   
      0.046   0.17    5.323   0.245   0.109   
      0.044   0.141   83.252  0.246   0.117   
      0.05    0.145   1.435   0.242   0.119
    
      0.048   0.144   3.685   0.246   0.113 MEDIAN
      0.310   0.145   8.551   0.248   0.135 AVERAGE
      1.144   0.006   18.377  0.008   0.057 STDEV

------
pchivers
This is exactly what I was looking for. I was previously using
<http://automation.whatismyip.com/n09230945.asp>, but the author is no longer
making it available for free.

------
tptacek
... and give anyone who controls your DNS a shell on your box. :)

~~~
TazeTSchnitzel
How so?

~~~
eropple
Not 100%, but can't you just re-point the DNS to a server you control and
return a different body from the curl request?

~~~
tptacek
Maybe depending on your shell I'm probably wrong.

~~~
TazeTSchnitzel
I don't see how you could be right. It won't evaluate the result:

    
    
      ajf@Ubuntu-1204-precise-64-minimal:~$ echo `echo "3 > file"`
      3 > file

~~~
tptacek
CONCEDING THIS IN ADVANCE OF VERIFYING.

~~~
elithrar

        ping `\`echo /etc/passwd\``
        zsh: permission denied: /etc/passwd
    

I may be wrong here, but would just returning \\`rootyourmachine.sh\\`` in the
request body therefore work?

Edit: Serving that from a web server via ping `curl localhost:9999` only
causes ping to respond with a usage warning, as if you had entered an
incorrect command.

Is there a way to "break out of" ping from here, though?

~~~
tptacek
No; you can pass arguments to ping, of course, but that's not helpful.

Sorry, gut reaction to command interpolation with curl.

------
azar1
I like `curl icanhazip.com` because it's cuter.

~~~
skrause
It also supports IPv6. whatismyip.akamai.com is IPv4 only.

~~~
p1mrx
<http://ipv6.whatismyip.akamai.com/>

------
t0
I usually use <http://checkip.dyndns.org>.

Good find, thanks.

~~~
TazeTSchnitzel
I prefer akamai's, since you can just curl it and get just the IP, nothing
more. So you can do, say:

    
    
      ping `curl whatismyip.akamai.com`
    

EDIT: Edited title from "whatismyip.akamai.com" to "ping `curl
whatismyip.akamai.com`"

------
zdw
<http://ifconfig.me> also has a fairly simple way to get more information
beyond just an ip address.

------
aiurtourist
Forgive me, but what's so exciting about this?

~~~
raldi
Most "what is my IP?" services either return it in hard-to-parse format, or
they block curl.

~~~
prezjordan
Couldn't you roll your own with a few lines of Ruby and send it off to heroku?

~~~
raldi
I could also write my own version of /bin/cat, but that doesn't mean it's a
good use of my time.

------
cynwoody
From a Verizon FiOS connection in the Boston area:

    
    
        --- a1524.g.akamai.net ping statistics ---
        29 packets transmitted, 29 packets received, 0.0% packet loss
        round-trip min/avg/max/stddev = 20.872/22.326/26.220/1.058 ms
    

For comparison:

    
    
        --- google.com ping statistics ---
        24 packets transmitted, 24 packets received, 0.0% packet loss
        round-trip min/avg/max/stddev = 10.791/12.767/16.010/1.329 ms

~~~
TazeTSchnitzel
The point of this submission was more to point out you can do `curl
whatismyip.akamai.com` rather than "ping `curl whatismyip.akamai.com`"
specifically, but that's still interesting.

~~~
cynwoody
I was just trying to measure the latency to the server, an important
characteristic for this service.

Previous ones I've used in the past (e.g., to update a dynamic DNS server)
have suffered from excessive (multi-second) latency or would simply timeout
unpredictably. I ended up writing my own on appspot.com.

~~~
TazeTSchnitzel
Ah, sorry, I had misread your post.

------
cynwoody
You can also just google 'my ip'.

But the Akamai service is obviously much easier to use from a script.

~~~
GuiA
Why not grep+awk ifconfig if you need your IP from a script?

~~~
Wilya
If you're looking for your public ip, it won't always work. Especially if you
are behind a nat/proxy.

That, plus knowing which interface to inspect among those returned by ifconfig
isn't always obvious.

~~~
GuiA
Cool, thanks for the reply! (and to all other replies as well :) )

------
mailbait
on a side note, <http://l2.io/ip.js> is pretty cool. since it allows script
injection into the return, it can be used clientside to inject their ip into
the webpage. Pretty cool if you're posting from static html to a 3rd party
form.

<script type="text/javascript"
src="[http://l2.io/ip.js?var=document.getElementById(ip1).value...](http://l2.io/ip.js?var=document.getElementById\(ip1\).value></script>);

works where item ip1 is where you want to IP address to end up on the client
html.

------
Amfy
I really don't understand why this was upvoted, or have I missed something?

------
sepeth
curl ifconfig.me

------
j0k3r
Wow <https://news.ycombinator.com/item?id=2278975> (788 days ago)

------
Aaronneyer
curlmyip.com is usually my go to.

------
demonkit
what is the difference between this and "curl ifconfig.me". I tried, "curl
ifconfig.me" seemed a little bit slower.

------
agent462
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"

------
Nux
ping `curl ip.nux.ro` :P

