# DHCP in DNSMASQ not working [SOLVED]

## LoermansA

I want to ditch DHCPD in favor of the built-in DHCP server of DNSMASQ, but whatever I try, all my clients (both Linux and Windows) keep getting time-outs when requesting their IP address. DHCPD works perfectly.

When running DNSMASQ, the logs (/v/l/messages)  don't even show a request coming in, so it seems as if DNSMASQ isn't listening on the right interfaces, but I've removed all restrictions and tried to tell it to listen to a certain interface, no dice. DHCPD is stopped, ofcourse.

I've tried most of the dnsmasq.conf's i could find on this forum (after adapting it to my network topology ofcourse).

I know this information is sparse, but I'd rather not post logs 'n stuff until someone needs to see it.

ArjanLast edited by LoermansA on Fri Jun 18, 2004 7:51 am; edited 1 time in total

----------

## dsd

which version of dnsmasq are you using? dhcp is a recent feature...

have you specified dhcp-range in your config? the dhcp server is not enabled otherwise.

----------

## davidblewett

Yeah, just make sure to have the address range not include the server's internal addy.  :Very Happy: 

----------

## LoermansA

I have version 2.5-r2 and specified a range correctly (i think)

Here's my dnsmasq.conf (taken from another post on this forum):

```

# Generic options

domain=arjan.net

domain-suffix=arjan.net

domain-needed

expand-hosts

filterwin2k

log-queries

no-poll

no-resolv

user=dhcp

group=dhcp

# Any requests for ubernet are ALWAYS handled by us

local=/arjan.net/

# DHCP options

dhcp-range=192.168.0.100,192.168.0.150

dhcp-lease=/var/lib/dhcp/dhcpd.leases

# Set the default route to the router

dhcp-option=3,192.168.0.254

# Set the timeserver address

#dhcp-option=42,0.0.0.0

# Set the printer address

#dhcp-option=9,0.0.0.0

# Set the smtp address

#dhcp-option=69,0.0.0.0

# Upstream DNS servers

server=81.18.1.17

server=213.196.40.12

server=62.58.62.132

```

The server has address 192.168.0.254 as address (so there's no overlap)

The DHCPD works perfectly:

```

# dhcpd.conf

#

# Configuration file for ISC dhcpd

#

# option definitions common to all supported networks...

option domain-name "arjan.net";

option domain-name-servers 192.168.0.254;

option routers 192.168.0.254;

default-lease-time 600;

max-lease-time 7200;

ddns-update-style ad-hoc;

# If this DHCP server is the official DHCP server for the local

# network, the authoritative directive should be uncommented.

authoritative;

# The range 192.168.0.100 - 192.168.0.253 is available, the first 100 are for static assignments

subnet 192.168.0.0 netmask 255.255.255.0 {

  range 192.168.0.100 192.168.0.253;

}

# Fixed IP assignments, a crude way to get DistCC to work across the network

host hulk {

        hardware ethernet       00:50:8D:F1:EE:8C;

        fixed-address           192.168.0.10;

}

host tww996 {

        hardware ethernet       00:02:3f:6f:19:72;

        fixed-address           192.168.0.11;

}

host xbox {

        hardware ethernet       00:50:F2:64:6C:1F;

        fixed-address           192.168.0.12;

}

```

Forget about the static entries I needed a quick hack because resolving through the dhcp.leases file didn't work.

Arjan

----------

## Plaz

Looks pretty reasonable to me.  I'd take out the domain-suffix line (I think it's redundant) and maybe try deleting the old dhcpd.leases file before starting the dnsmasq server.  If you do that, does a new dhcpd.leases file get created?

Have you tried running strace on dnsmasq to see if some internal call is failing?  Are you using any command line args when you start it up (other than -x <pidfile>)?

----------

## think4urs11

Hi!

May be a dump question, but did you stop DHCPD before starting dnsmasq?

What gives 

```
netstat -plunt | grep 67
```

HTH

T.

----------

## LoermansA

@Think4UrS11: Yes, DHCP is stopped (like I wrote in the start of this thread), the netstat command returns nothing.

After disabling dhcpd and running dnsmasq as dhcp server, the netstat command gives the following result:

```

root # netstat -plunt | grep 67

udp       0      0 0.0.0.0:67           0.0.0.0:*

13459/dnsmasq

```

@Plaz: I've taken out the domain-suffix, didn't do anything (didn't think it would). I deleted the leases file and a new one does get created. It seems as if dnsmasq doesn't listen on the correct interface. in /etc/conf.d/dnsmasq these are the options:

DNSMASQ_OPTS="--log-queries --dhcp-lease=/var/lib/dhcp/dhcpd.leases"

I've never done anything with strace, but I would reckon that (since dns still works) if something internal goes wrong, I would see something in my logs.[/code]

----------

## think4urs11

try to add the interface statement to your dnsmasq.conf and/or remove the dhcp-lease statement

plus

remove the options from /etc/conf.d/dnsmasq and add log-queries in /etc/dnsmasq.conf instead.

HTH

T.

----------

## gmichels

Here's my /etc/conf.d/dnsmasq file, it works very fine for me:

```
DNSMASQ_OPTS="-S 200.189.175.33 -S 200.189.175.34 -R -c=500 -I=eth1 -D --dhcp-range=192.168.0.11,192.168.0.40,12h"
```

eth0 is lan, eth1 is internet.

----------

## LoermansA

I've tried all options mentioned, no dice.

Does anybody know of a way to get this thing troubleshooted? I'm running out of options.

Arjan

----------

## think4urs11

Hi again!

Only difference i see is that you are using user/group statements... could be some sort of rights problem (dhcp beeing one of the <1023 ports, requiring root(?) rights)

Maybe a 'known to work' config helps

/etc/dnsmasq.conf

```
interface=eth0

interface=eth2

query-port=32123

bogus-priv

filterwin2k

resolv-file=/etc/resolv.dnsmasq

local=/my.local/

cache-size=5000

domain-needed

domain=my.local

expand-hosts

dhcp-range=10.20.1.2,10.20.1.59,144h

dhcp-range=10.20.1.114,10.20.1.126,48h

dhcp-host=00:33:12:4c:96:02,10.20.1.2,id:*

dhcp-option=42,0.0.0.0     # NTP server on this machine
```

additional infos

```
prompt# dnsmasq -v

dnsmasq version 2.8

prompt# cat /etc/conf.d/dnsmasq

DNSMASQ_OPTS=""

prompt# netstat -plunt | grep 67   

udp        0      0 0.0.0.0:67              0.0.0.0:*                           5549/dnsmasq
```

HTH

T.

----------

## dsd

you can probably run dnsmasq in debug mode, where it just spits out debug info onto the console (instead of starting with init.d, just run dnsmasq and the appropriate parameters to enable the debug mode).

then get another PC to request an IP over dhcp and see what happens

----------

## LoermansA

@ Think4UrS11:

I've tried with and without user and group directive, no change.

@dsd:

I've done exactly that, 'dnsmasq -d' I believe, but nothing seems to get through. Messages don't say anything about a dhcp request being made. Nothing. Client just waits until it times out...

Ive noticed a newer version in portage, i'll be trying that one (I have 2.5something and 2.8something is availeable).

I'll let you know if anything changes.

Arjan

----------

## LoermansA

Tried the latest version in portage (2. :Cool: , no luck, still the exact same behaviour. DNSMasq is not getting any DHCP requests, yet DHCPD works just fine.

I've tried DNSMasq 2.8 with the default dnsmasq.conf, only very minor changes (like uncommenting the first 'dhcp-range' option)

I'm really stumped, I have no idea where to look now, dnsmasq -d (dump debug messages to commandline) shows nothing out of the ordinary. I have a feeling something low-level goes wrong, as dnsmasq doesn't appear to even get the dhcp requests, but my firewall is not restricitive on it's internal interface at all (monmotha firewall script, by the way).

Help? Anybody?

----------

## LoermansA

Yeeeehaaaa, finally, it works.

I figured as I previously said that I had the feeling it had to be something lowlevel, I doublechecked my (monmotha) firewall script and found an entry:

DHCP_SERVER = "FALSE"

I changed this to TRUE and now it works. It makes sense and seems pretty dumb (in hindsight), but remember, DHCPD works just fine with this setting in my FW script. Because DHCPD worked, I figured it couldn't have something to with my firewall...

Now to get it properly configured. Thanks to all who helped.

Arjan

----------

