# Slow boot process (due to dhcp?)

## hoffimar

Hi,

my Linux with gentoo-dev-sources-2.6.9 boots up really slow. The problem seems to be DHCP with my Router (D-Link DI-514). It lasts about 50 seconds only for one thing (one line of boot output, maybe it does sth. else?): The screen shows "Bringing eth0 up via dhcp", then "Setting DNS domainname to local", and after about 50 sec "eth0 received address 192.168.0.xxx".

I enabled parallel startup in /etc/conf.d/rc, but i read it only works for processes in the 'boot' runlevel.

The only entry in my /etc/hosts, if that helps:

```
127.0.0.1       testname.local testname localhost
```

I tried with and without the ipv6 versions in /etc/hosts, no difference.

Another thing is that my router shows "unknown" instead of the hostname i set in /etc/hostname (e.g. testname). Using other OSs shows the right hostname, so it's not the router but my configuration.

Could someone help me?

Thanks, Martin

----------

## hoffimar

Any suggestions?  :Question: 

----------

## davidn

Hi hoffimar

I've got the same router and similar problems. I've got a feeling it's because it's a cheap router. I thought that having it set to static DHCP addresses would fix it, but no luck. Also it's internal clock seems kind of screwed... sometimes it's 2033 and sometimes it's the 1970s. Entering an NTP server fixed that.

I emailed D-Link and I'll post the response if I get one.

Did you find any work arounds?

----------

## hoffimar

Hi,

I've been in a gentoo IRC channel and the only hint I got was to try static IP addresses. I tried this once but the router displayed garbage on the page for DHCP after this. 

The router has several faults displaying the config pages. I also have the time problem as you stated. Of course ntp solves it, but when I reboot the router without internet connection the time is still messed up. Another problem is the ip updating with dyndns.org. But I read in a forum that the new firmware should solve this problem. So maybe some of the other problems are solved too. Now I have firmware version 1.03, but i will update the next days. Here is a link to version 1.04b1, in case you want to try: 

ftp://ftp.dlink.de/di-products/di-514/Treiber_Firmware/di514_fw_revb_eng_104b1_071004.zip

Or did you already install the new firmware?

But the problem could also be that it's not the router (because other OSs and even other linux distros start faster), but a wrong config of the runlevel scripts. I will have to look if anything else is done while it just says "bringing up eth0 ..." or "setting dns domain name to local". But i have no clue where to look at (I know where the init-scripts are, but I don't know when exactly which is executed). 

Is the right client name displayed at your router homepage under "Home->DHCP->Static DHCP->DHCP Client" ? Mine says "unknown", although my gentoo says the real name.

So no workarounds yet   :Sad: 

Bye, Martin

[edit]the new firmware didn't help with the slow bootup, so it may be something the configuration of the startup processes[/edit]

----------

## Mord

If I was having this kind of trouble with my laptop, I'd just switch it over to a static IP.  While D-links aren't my favorite brand, I seriously doubt its the router.  Do other boxes have trouble getting IPs from it as well?

----------

## Elorian

 *davidn wrote:*   

> Hi hoffimar
> 
> I've got the same router and similar problems. I've got a feeling it's because it's a cheap router. I thought that having it set to static DHCP addresses would fix it, but no luck. Also it's internal clock seems kind of screwed... sometimes it's 2033 and sometimes it's the 1970s. Entering an NTP server fixed that.
> 
> I emailed D-Link and I'll post the response if I get one.
> ...

 

I'm having a similar problem.  Takes 30s+ to obtain an IP address from the DHCP Server (Fedora).  My home network is run by a linksys router, no wait time.

----------

## UberLord

There is a dhcpcd problem with Gentoo - it quits using the -z option which releases the lease on the DHCP server, but keeps the lease on the Gentoo box. When dhcpcd is restarted, it requests the old lease - but the DHCP server has forgotten it. Unless the DHCP server is "authorative" (ie - it's told that it's the only DHCP server on the network) then the DHCP server correctly remains silent as another DHCP server may know about the lease.

Baselayout-1.11.8 has changed the way we deal with dhcpcd - by default we halt dhcpcd by sending it a TERM signal which closes dhcpcd without releasing the lease, so the next time it starts up it can request it's old lease and everything is fine.

For those that require the lease to be dropped, we supply the dhcp_eth0="release" generic dhcp option which calls dhcpcd -k which releases the lease on the DHCP server and destroys the local cache.

For those of you that need this now, you can change behaviour by editing /etc/init.d/net.eth0 and changing dhcpcd -z to dhcpcd -k for baselayout-1.10.x or worse. For baselayout-1.11.7-r2 or worse, change /lib/rcscripts/net.modules.d/dhcpcd.

Or just wait for baselayout-1.11.8 which should be available in ~ARCH soon

----------

## hoffimar

Many thanks to all the posters! 

Changing to dhcpcd -k solved the problem.  :Very Happy: 

Cheers, Martin

----------

## Karsten1973

 *Quote:*   

> Or just wait for baselayout-1.11.8 which should be available in ~ARCH soon

 

i have baselayout 1.11.8 and still seem to have that problem. Any help?

----------

## UberLord

Do you get the same problem with other dhcp clients? Such as udhcpc (udhcp), dhclient (dhcp) or pump?

If so, then it's another problem - mostlikely that it cannot actually find a DHCP server.

----------

## polle

I had the same problem and solved it like this:

in 

/etc/conf.d/net 

I added a line 

dhcpcd_eth0="-t 1" 

now it only takes one second to get an IP (if you get failures of receiving an IP you can use a higher number then 1)

----------

## UberLord

I would recommend a bare minimum of 3 seconds ..... the dhcp server may be under heavy load at the time. I find that 3 seconds I always get an address regardless of wireless link quality / server load.

Of course, YMMV

----------

## popcan

i don't know if it will make it respond any faster, but dhcpcd does not send the hostname of the machine by default to the dhcp server

```
iface_eth0="dhcp"

dhcpcd_eth0="-h yourhostname"
```

put that in /etc/conf.d/net and it will register in the router's table

----------

## Karsten1973

I'll try that.

----------

## <3

I was having the same problem. It would sometimes take almost 5 mins before it would get an ip address. Although i am not behind a firewall, as I had one of my two  ethernet cards connected directly to my cable modem, Adding this line to /etc/config.d/net solved the problem.

```

dhcpcd_eth0="-t 3" 

dhcpcd_eth1="-t 3"

```

THX polle

----------

## Erlend

I'm using baselayout 1.11.9-r1 and dhcpcd takes about 10s at boot, sometimes slightly longer.

I have a Netgear DG834 router.  Low load.

AHH Just found why: I commented out this line in /etc/conf.d/net

dhcpcd_eth0="-HD"

and it instant now.

I don't understand why that would cause a problem though.

Erlend

----------

## onlymee

I have just upgraded from the stable sys-apps/baselayout-1.9.4-r6 to the "~x86"  sys-apps/baselayout-1.11.9-r1

Since this setup contains better wireless support through the 

   module=( "wpa_suplicant" )

Stuff.

Anyway, now ALL my dhcp'd network connections start very slowly.  (am using stable net-misc/dhcpcd-1.3.22_p4-r5)

Uberlord mentioned the changes in >=1.11.8 to allow the

    dhcp_XXXX="release"

option to causes the dhcpd rc module to kill of dhcpcd with a HUP instead of a TERM signal.

Reading the code (/lib/rcscripts/net.modules.d/dhcpcd) the condition on this variable is clear to see.

It does not however call 'dhcpcd -k' described in the man page as:

```
 -k     Sends  SIGHUP signal to the dhcpcd process that is currently running. 

                   If dhcpcd receives SIGHUP it will send DHCP_RELEASE message to 

                   the server and destroy dhcpcd cache. In a case dhcpcd receives SIGTERM 

                   which is normally used by shutdown(8) when rebooting the system 

                   dhcpcd will not send DHCP_RELEASE and  will  not  destroy cache. 

                   When system boots dhcpcd will use cache to request the same IP address 

                   from DHCP server which was assigned before the system went down.

```

Rather it uses the SIGHUP method: "kill -s HUP" the pid.  

So the discussion about usage of -k above I suppose is synonomous.  Unfortunately NEITHER appear to work for me.

I can of course set "-t 5" or something, but that doesn't make dhcpcd run any quicker, rather it simply gives up after 5 seconds and I have no IP address  :Sad: 

So my problem reduces to, adding some debugging lines in the dhcpcd rc module I can check the command used to start dhcpcd and test this by hand:

```
wormhole ~ # time dhcpcd -h wormhole eth0 

real    0m28.248s

user    0m0.008s

sys     0m0.029s

wormhole ~ # time dhcpcd -k               

real    0m0.020s

user    0m0.003s

sys     0m0.005s

wormhole ~ # time dhcpcd -h wormhole eth0 

real    0m28.291s

user    0m0.004s

sys     0m0.032s

wormhole ~ # kill -s HUP `cat /var/run/dhcpcd-eth0.pid`

wormhole ~ # time dhcpcd -h wormhole eth0 

real    0m28.218s

user    0m0.004s

sys     0m0.027s

```

Seemingly neither have any effect.

What I can see in /var/log/everything/current is:

```
Feb 22 14:13:25 [kernel] b44: eth0: Link is up at 100 Mbps, full duplex.

Feb 22 14:13:30 [kernel] NETDEV WATCHDOG: eth0: transmit timed out

Feb 22 14:13:33 [kernel] b44: eth0: Link is up at 100 Mbps, full duplex.
```

Which suggests network is timing out somehow...  But I don't see how as this is the same kernel + net driver module

ar the same as before upgrading baselayout.

I have tried this on 2 different @Home networks (each with both wired and wireless)

and I have tried this with our University network (again both with wired and wireless)

and I have the same 25 secondish DHCP delay with all configurations.    

Windows however in all situations receives it's network details in moments.  As did Gentoo before the baselayout upgrade.

Ideas anyone? Please....  The new config stuff in baselayout is great.  This slow lease time sucks.

----------

## robotbill

I just did a fresh install of gentoo and i'm using sys-apps/baselayout-1.11.10 with a netgear wg511 and prism54 drivers.  At boot it takes over a minute for dhcpcd to get an IP.  In my previous install I had a much older version (i'm not sure which) and it was almost instantanious.  also at startup I get this  error right before it finds my ssid

```
/lib/rcscripts/net.modules.d/iwconfig: line 695: /dev/nul: Permission denied
```

Any ideas about what is happening?

thanks,

joe

----------

## UberLord

 *robotbill wrote:*   

> 
> 
> ```
> /lib/rcscripts/net.modules.d/iwconfig: line 695: /dev/nul: Permission denied
> ```
> ...

 

Yeah - typo on my part :/

It's fixed in baselayout-1.11.10-r2

----------

## robotbill

Thanks, that fixed it.

----------

