LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Script or program for continuously retrying to get an IP via DHCP (http://www.linuxquestions.org/questions/slackware-14/script-or-program-for-continuously-retrying-to-get-an-ip-via-dhcp-649843/)

Ken-ji 06-17-2008 03:58 AM

Script or program for continuously retrying to get an IP via DHCP
 
This has been a problem of mine since the Slackware 10.

My ISP's internet link can go down from time to time.

During that time, if my machine boots up, the initial dhcpcd tries to bind an IP address, and fails and dies.

Since the machine is a headless router and fileserver, I'd like it to continuously request for an IP address until it is granted one.
The exit error levels don't help at all since, the version used by slackware (2.0.x) has bugs when they fail to get an IP.

Does anybody have a script for this?

ifplugd won't work since there is no link down/up events. (Modem stays on all the time)

bgeddy 06-17-2008 06:36 AM

I take it your current version of Slackware is 12.1 ? I think the network startup scripts have changed since Slackware 10 so the following may not work on older versions.

Not sure if this will work or even if it's the best way of doing things but dhcpcd man page reports an infinite timeout may be set by setting the timeout parameter, ( -t ), to 0.

I believe this may be achieved by adding a setting to /etc/rc.d/rc.inet1.conf. Add a line to the file:-
Code:

DHCP_TIMEOUT[X]="0"
- where X is the interface number - i.e. set X to 0 for eth0, 1 for eth1 etc.

Looking at the /etc/rc.d/rc.inet1 script this should set the -t value of the dhcpcd call to 0.

It may work but as I said - this may not be the best way of getting the desired results.

Ken-ji 06-17-2008 06:39 AM

I've tried that before, but that cause boot up to hang until net comes back on - not the ideal scenario...

I was hoping more for a backgrounded type of thing.

C-Sniper 06-17-2008 10:25 AM

put it on a cron job to run every 10 sec?

Ken-ji 06-18-2008 12:30 AM

That might work. A script with lockfiles, set to be invoked every minute or so...


All times are GMT -5. The time now is 01:08 PM.