# Poweroutages and Ethernet, net.eth0 starting too fast

## npaust

I have three gentoo boxes on a college campus network and I ran into an interesting problem over the weekend.  Campus lost power and my machines gracefully went down after 15 minutes of running on their UPSs.  Then, after an hour, power came back and I ran into an interesting problem.  My machines rebooted before the ethernet switches powered back up, so they failed to get dhcp addresses.  That made them inaccessible remotely until I physically logged into them an rebooted.

Is there an easy way to fix this problem?  I was thinking about something like a cron job that does 

```
/etc/init.d/net.eth0 start
```

 once an hour.  If it's already up, the command won't do anything.  If it's down, it should start it.

Or, I'm using dhcp to get static addresses.  Would it work to just hard code the IP address and gateway information, or would net.eth0 still fail to start without the reply from the switches?

Or, is there some other better solution?  (One that doesn't require the tech services people to do their jobs and install UPSs on their multi-thousand dollar switches.)

----------

## py-ro

Try ifplugd, just install and enjoy.

Py

----------

## djdunn

eh dhcpcd should do everything ifplugd does cable detection wise.  I unplug my router all the time and dhcpcd always picks it back up again when i plug it back in.  So your problem wont go away by using ifplugd

do you have dhcpcd service added to the runlevel or are you only calling it once when you boot?

----------

## npaust

net.eth0 stars in the default runlevel.  I'm not running dhcpcd...  actually, that seems like it might be a problem!  How exactly have my systems been running for the past years without dhcpcd running?

That's actually a serious question.  How do I get a dhcp assigned IP address when I'm not running the dhcp client?

----------

## Etal

I think net.eth0 script starts dhcpcd somehow, but it seems it does not work well in all cases.

If you just use DHCP (no special configuration in /etc/conf.d/net), you can just remove net.eth0 from default runlevel and add dhcpcd instead. dhcpcd handles connecting and disconnecting of interfaces well by itself.

----------

## dmpogo

 *npaust wrote:*   

> net.eth0 stars in the default runlevel.  I'm not running dhcpcd...  actually, that seems like it might be a problem!  How exactly have my systems been running for the past years without dhcpcd running?
> 
> That's actually a serious question.  How do I get a dhcp assigned IP address when I'm not running the dhcp client?

 

In usual сетуп dhcpcd is not run as independent service.  Client is called from network scripts

----------

