I am using Ubuntu 10.04 and when I am connected to my preferred automatic network, my computer is assigned a new IP address every so often without me, the user, needing to be aware of it. I have no control over the network server, just my own computer. Here's my goal:
I'm looking for a way to detect whenever my IP address has been changed, and to record my new IP address in a text file. I could use Linux Scheduling for this, I know, but then I would have to bog up my computer with an extraneous process that would execute every 5 mins or so to make sure I catch the IP change close to when it happens. My IP doesn't change that often - sometimes I go days with the same address, so I'm hoping that there is some sort of networking script that executes whenever my computer is assigned a new IP address. Then I would modify the end of that script to run my own script that keeps track of the IP address.

So: Is there such a script that runs each time I receive a new IP address? Or, are there better suggestions for doing this?

Thanks very much, and if you'd like more information about what I'm trying to do, just let me know.