# DNSMASQ DHCP very, very slow (60 + secs) [solved]

## OneInchMen

Hi there,

I have a small network at home and tried to set up a linux based DHCP/DNS server. Since dnsmasq has support for both and can serve addresses from the DHCP lease table, it must be the easiest solution around...

I successfuly set up the DNS/DHCP server, but it can take up to a minute to get an ipaddress from the server (!!!)

I tested it with:

```
genthree root # /etc/init.d/net.eth0 stop && sleep 1 && time /etc/init.d/net.eth0 start

 * Bringing eth0 down

 *   Releasing DHCP lease for eth0... 

 *   Stopping eth0...  

 * Bringing eth0 up via DHCP... 

 *   eth0 received address 192.168.0.54

real    1m0.102s

user    0m0.064s

sys     0m0.045s

```

If I switch back to my old dhcp server (dhcp itself) I get the following result:

```
genthree root # /etc/init.d/net.eth0 stop && sleep 1 && time /etc/init.d/net.eth0 start

 * Bringing eth0 down

 *   Releasing DHCP lease for eth0...                                                                      [ ok ]

 *   Stopping eth0...                                                                                      [ ok ]

 * Bringing eth0 up via DHCP...                                                                            [ ok ]

 *   eth0 received address 192.168.0.54

real    0m1.827s

user    0m0.072s

sys     0m0.032s

```

A difference of more than 58 seconds!!!  :Crying or Very sad: 

This is my dnsmasq.conf:

```
gentwo root # grep -v ^# /etc/dnsmasq.conf | grep -v ^$

domain-needed

bogus-priv

server=/localnet/192.168.0.1

local=/sait.intra/

expand-hosts

domain=sait.intra

  

dhcp-range=192.168.0.50,192.168.0.150,12h

dhcp-option=3,192.168.0.1

dhcp-option=6,0.0.0.0,192.168.0.1

dhcp-option=42,0.0.0.0

dhcp-option=40,sait.intra

```

Help? Please?   :Question: 

Thanx, Harold.Last edited by OneInchMen on Fri Feb 18, 2005 4:59 pm; edited 1 time in total

----------

## UberLord

https://forums.gentoo.org/viewtopic.php?t=256613

----------

## OneInchMen

UberLord, adding '-t 3' to the dhcp option is indeed a quick fix, but it doesn't work with my WLan card.

It takes my rt2500 card 10-20 seconds to get up and communicate with my accesspoint about the security before I have network activity. I had to add '-t 30' to my config to get a near 100% dhcp hit rate, but this way the boot process is pretty long...

What if I give the card a fixed IP and do a manual 'dhcpcd -t 3 -h `hostname` ra0' in local.start or something like that?

----------

## UberLord

Better options

1) upgrade to baselayout-1.11.8 or better (it has wireless support too)

2) edit the net.eth0 file to change the dhcp stopping option from -z to -k

----------

## Chris W

Another option that is good for dnsmasq (or the ISC DHCP daemon) is to add:

```
# Set the DHCP server to authoritative mode. In this mode it will barge in

# and take over the lease for any client which broadcasts on the network,

# whether it has a record of the lease or not. This avoids long timeouts

# when a machine wakes up on a new network. DO NOT enable this if there's

# the slighest chance that you might end up accidentally configuring a DHCP

# server for your campus/company accidentally. The ISC server uses the same

# the same option, and this URL provides more information:

# http://www.isc.org/index.pl?/sw/dhcp/authoritative.php

dhcp-authoritative

```

 but you'll need dnsmasq >= 2.16 which currently in unstable.

I've never understood why the dhcpcd -z option was used in the first place.

----------

## UberLord

 *Chris W wrote:*   

> I've never understood why the dhcpcd -z option was used in the first place.

 

https://bugs.gentoo.org/show_bug.cgi?id=23428

Thats the bug that caused it all.

Ah well, all solved for everyone when baselayout-1.11.x goes stable  :Smile: 

----------

