r/tinycode • • Jul 10 '11

Outside IP one-liner.

curl http://checkip.dyndns.com/ 2>/dev/null | sed 's/.*: \(.*\)<\/b.*/\1/'

9 Upvotes

17 comments sorted by

14

u/infinitus_ Jul 10 '11
curl ifconfig.me

1

u/trashbox Jul 10 '11

Best one yet, and not something I would need to save as a script.

1

u/obsa Jul 11 '11

Maybe it's just my route, but it was powerfully slow to load.

1

u/SolomonKull Jul 17 '11

Took me almost 1 second.

18

u/prototrout Jul 10 '11 edited Jul 10 '11
curl http://whatismyip.org/

Or if you prefer:

curl 1134614506

2

u/terremoto Jul 10 '11 edited Jul 10 '11

Better: wget -O- http://automation.whatismyip.com/n09230945.asp

See http://www.whatismyip.com/faq/automation.asp

Nevermind, I thought the OP was using whatismyip.com.

1

u/trashbox Jul 10 '11

Nice, I'll remember that.

2

u/[deleted] Jul 10 '11

How is that any better?

1

u/terremoto Jul 10 '11

Visit the URL and I think it will be self explanatory -- you don't have to parse out the IP address.

0

u/[deleted] Jul 10 '11

[deleted]

2

u/terremoto Jul 10 '11

I stand corrected. I was thinking it was whatismyip.com

1

u/obsa Jul 11 '11

Correctness aside, who is trying to remember these URLs?

3

u/m1ss1ontomars2k4 Jul 10 '11

But who is checkip.dyndns.com?

5

u/[deleted] Jul 17 '11

curl icanhazip.com

1

u/CarbonFire Aug 15 '11

For me, this loads much faster than

curl ifconfig.me

1

u/[deleted] Sep 10 '11

Ya beat me to it!

3

u/[deleted] Jul 10 '11
tracepath -n 192.88.99.1 | awk '/2: / { print $2; exit }'

3

u/terremoto Jul 11 '11 edited Jul 11 '11

That won't always return the correct address depending on your network topology.

EDIT: I got bored and decided to make a version of this that will match the first non-reserved address; a monstrosity follows (yes, the IP regex could be condensed. EDIT 2 -- Okay, I condensed the regex.):

tracepath -n 192.88.99.1 | grep -vm1 "\(192\.168\|169\.254\|172\.\(1[6-9]\|2[0-9]\|3[01]\)\|10\.[0-9]\+\)\(\.[0-9]\+\)\{2\}" | grep -o "\([0-9]\+\.\)\{3\}[0-9]\+"

EDIT 3 -- For traceroute:

traceroute 192.88.99.1 | grep -vm1 "\(192\.168\|169\.254\|172\.\(1[6-9]\|2[0-9]\|3[01]\)\|10\.[0-9]\+\)\(\.[0-9]\+\)\{2\}\|192\.88\.99\.1" | grep -o "\([0-9]\+\.\)\{3\}[0-9]\+"

2

u/obsa Jul 11 '11

The thing that annoys me most about that particular service is the "Current IP Address" prefix. Why is that even necessary?

/complaining about free stuff