One-liner to retrieve external IP address [duplicate]
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.
IP=`curl ifconfig.me`
[stephan@nemesis] ~ $ curl ifconfig.me
173.13.169.18
Voila. :)
(Edit Sept 2020)
I usually use icanhazip.com now. You may need to chop the newline, though:
curl -s icanhazip.com | tr -d '\n'