Everytime, when the machine came up, i would be having a different public ip address to access the machine as my ADSL modem+router would also go down.
At first, i setup a cron to be run at boot time which would give me the public ip address.
The corresponding cron entry is
I also created a dns entry to access the machine. And then wrote a script to update the dns record in godaddy whenever the machine reboots. Here is the script.
Now whenever my pi reboots, it checks and updates the corresponding DNS record at godaddy. And i can ssh my machine from anywhere.