Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run a script on new ip address

Status
Not open for further replies.

RandyRiegel

Programmer
Sep 29, 2003
256
US
I have a dynamic DSL connection on my home Linux machine. I need to run a script everytime my computer gets a new address. How would I do this? If I turn my modem off then back on it will take my machine a minute or two to change the IP address and get a connection. I really don't want to use a cron job for it if I don't have to.

Randy
 
I'm not using PPPOE so I don't have a ppp0. My external device is eth0. When I browse into my modem it says something about PPP over Modem. I'm assuming this is very similar to PPPOE. What scripts does Linux run if any when it obtains its IP.

Randy
 
So this is a DHCP change on your ethernet NIC? Are you trying to notify a dynamic DNS server provider? There are scripts that tie to changes in the NIC.

I'm not sure, but I'm aware of daemons that run to manage as DHCP clients... they probably have hooks to run external scripts.


 
Yes, IP address is of my NIC. Yes, I'm trying to notify my dynamic dns provider (zoneedit.com). Right now I have zoneclient from sourceforge.net running but I have to put it in crontab and have it check constantly to make sure everthing is sill the same. I don't want to run the script too much and waste resources but also don't want to run them too far apart and have more downtime if IP address changes. I'd like to run my zoneclient update script ONLY when eth0 changes.

Do you happen to know how often NICs are checked by the OS for changes from the dynamic server? When I reset my modem, it took a few minutes AFTER the modem was fully connected for Linux to recognize my new ip address and give me internet access again.

Randy
 
Your IP should not change unless your modem goes down. If you put the modem on the same outlet as the server then if the modem losses power so does the server and you can put the script in the startup.
 
OK before the DHCP purists start correcting me, your DHCP lease is renewed BEFORE the lease runs out. The timing of when the lease renewal is made is a bit of a black box, but the lease renewal request is made before the lease end date/time.

You MAY get a new lease on your old IP or you may get a new IP. DHCP tries to accomodate old IP re-leasing, but is not obligated to do so. As a result, it is true that your IP can change while you are running.

Sorry to correct myself.

 
thedaver: No problem, I would have done it for you. You are right and some ISPs will force a change if they don't want you running a server from your site. My first ISP would drop the lease if your modem went down for even a second or two. The one I have now has a long lease time and I get my ip back even if I'm down for several days.
 
I'm not sure what my lease time is. But last night when I was trying to do some tests with the zoneclient software I turned off modem for about a minute turned it back on and got the same IP address. Although I have turned it off before and gotten a new IP when it reconnected. Must have just been luck.

Why does it take so long after I turn my modem back on for the Linux box to connect to the internet. I timed it last night and from the time I saw the DSL light and the Internet light on my modem light up it was 9 minutes until Linux got back it connection. I could to a "service network restart" and get it back instantly but would like to find a setting so that it checks more often or something.

I'm going to leave my modem on and see how long it keeps the same IP address. Hopefully they don't. Franklin, which ISP are you with now if you don't mind me asking. I'm with SBC Yahoo DSL.

Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top