Lately, I was configuring Nagios and most of the systems were on the same private IP block as the Nagios server. One of the servers was outside the LAN and I was using the allowed_hosts directive for nrpe daemons where I needed to put the external IP of Nagios server in nrpe configuration of the outside host. I fiddled with elinks and it did not work which was a bit of frustration.
I thought about pinging the external host and capturing the icmp packets with tcpdump and many other ways came to mind. It turned out that I can find the external IP more easily using some of these ways.
The easiest way is to use is to use curl
curl www.whatismyip.org
Another way is to use wget by directing the output of standard output and sending the error messages to /dev/null
wget http://www.whatismyip.org -O - -o /dev/null
or if I wanted clearer output, I could use wget this way
wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
I could use elinks with checkip.dyndns.org and not with whatismyip.com
elinks checkip.dyndns.org
An additional tip. If you want to find all the IPs assigned to a system, the following gives you what you want
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}
Hope this helps.

















Umm..
Why don’t you simply use ‘lynx http://www.whatsmyip.org‘ ?
It’s standard and very easy.. =)
Good and useful tips. Thanks. In Mac OS X, ifconfig output is slightly different. To show all IPs assigned in a Mac OS X system, the following works:
ifconfig | awk ‘$1 == “inet” && $2 != “127.0.0.1″ {print $2}’