Click to See Complete Forum and Search --> : obtaining ip address when renewing lease
krumholz
07-31-2002, 12:32 AM
I have a firewall script that I want to run when ever I boot the PC or when ever my lease is renewed. It seems like RH 7.3 creates a file in /etc/dhcpc called dhcpd-eth0.info The file has my ipaddr etc... I can parse the file to get the ipaddr - My Questions - Where can I put a code to be executed when ever the lease is renewed or I get an ipaddrr (example at boot time) ? Is /sbin/ifup only called at boot time ?
Thanks in advance:confused:
Dagda
07-31-2002, 09:58 AM
If you system is up and it renews the IP then it should be the same so you don't need to run a script. On boot just write your script and execute it through /etc/rc.d/rc.local (the linux autoexec.bat)
krumholz
07-31-2002, 12:40 PM
If my lease is not renewed (for what ever reason-e.g. maybe the srever that gave me the ip address is down), I thought DHCP will ask for another IP address, like I was re-booting. That is the condition I am trying to catch.
DHCP servers grant you a lease on an IP for a specific period of time.
For example, 72 hours.
What happens is that after half the lease has expired, the DHCP server checks for your box to see if it is still using th elease. Then it checks again in half the time that is left for the lease, etc, etc.
IP addresses do not always change each time you reboot. Although some ISP's use really short leases so that may be what you mean.
Cheers.
jumpedintothefire
08-01-2002, 09:10 AM
Which dhcp client are you running? pump or dhcpcd? Which one shows up when you do, as root, ps -A??
dhcpcd will run a file called /etc/dhcpd/dhcpd-eth0.exe if the ipaddress has changed, make it a symlink to whatever you want to run. No need to change anything if your ip address has not changed. ifup is called at boot or when you use it to bring up an interface. If you're having problems renewing, but not on bootup, then chances are that the dhcp ports are blocked by your firewall script and you can't talk to the dhcp server... Do you get the same ip address after a reboot??
Just my 2 cents worth...
krumholz
08-01-2002, 12:56 PM
I have dhcp and usually get the same IP when I boot. I noticed that my old IP became something else w/o re-booting. I assumed that for some reason the lease was not renewed and dhcp requested another ip address and was granted one. I dont think my ports are blocked becase I have not booted my pc for weeks before loosing the ip address; and I have had internet connections and access.