Possible Duplicate:
Finding the Public IP address in a shell script

For use in scripting, it would be handy to be able to do this:

IP=`....something ....`
echo ...$IP... >> configfile

I'm looking for the IP address as seen by the web, in this instance. Ubuntu, if it makes a difference. Happy to install a package or two.

marked as duplicate by Michael Hampton, EEAA, mdpc, Zoredache, kce Feb 5 '13 at 3:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Thanks - I looked for dupes but didn't find. – Steve Bennett Feb 5 '13 at 22:47
IP=`curl ifconfig.me`

[stephan@nemesis] ~ $ curl ifconfig.me

Voila. :)

  • I'd suggest, ifconfig.me returns (to curl) only the IP address without any header or body tags. – Stephan Feb 5 '13 at 2:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.