If you are not behind a router, you can find it out using ifconfig. Else you could request this website using curl and extract the information you need from it, e.g. using a perl script.
curl -s checkip.dyndns.org | sed -e \'s/.*Current IP Address: //\' -e \'s/<.*$//\'