# [dnsmasq] dhcp doesn't work (open)

## i92guboj

Hello,

This is the scenario:

PC A (192.168.0.1/255.255.255.0): this is a server, dnsmasq is supposed to run on it, and provide dhcp functionality.

PC B (should be 192.168.0.11/255.255.255.0): this is my desktop, and it conf.d/net file is this one:

```

config_eth0=( "192.168.0.11  broadcast 192.168.0.255 netmask 255.255.255.0" )

routes_eth0=( "default gw 192.168.0.1" )

#config_eth0=( "dhcp" )

config_eth1=( "null" )

```

At this state of the things, it works. But if I disable the two first lines and enable dhcp it doesn't.

Dnsmasq is loaded:

```

# rc-update show | grep dnsmasq

             dnsmasq |      default                  

# ps -A | grep dns

15737 ?        00:00:00 dnsmasq

```

In PC A (server) I have this on dnsmasq.conf:

```

interface=eth0

#except-interface=eth1

#no-dhcp-interface=eth1

expand-hosts

domain=homenetwork

dhcp-range=192.168.0.100,192.168.0.250

dhcp-host=00:16:17:13:93:A7,192.168.0.11

```

The last line is to fix the ip by mac, but it doesn't matter if I comment it out. Dhcp still doesn't work. Firewall is off, so that's not the problem.

eth0 is, of course, my lan nic:

```

# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:80:5A:46:CF:9B  

          inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0

          inet6 addr: fe80::280:5aff:fe46:cf9b/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:16524931 errors:0 dropped:0 overruns:0 frame:0

          TX packets:18877725 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:1668423834 (1591.1 Mb)  TX bytes:2657911298 (2534.7 Mb)

          Interrupt:17 Base address:0xef00

```

If I use dhcping on PC B (client) I get this:

```

# dhcping 192.168.0.1

no answer

```

Now I am lost. Any idea?

Thanks for reading and for your help  :Smile: 

----------

## mbreith

Well, I can't check my server's dnsmasq settings right now since I am not at home. My laptop (client) doesn't really have anything in "conf.d/net". I have the static ip and route information there (config_eth0 and routes_eth0), but it gets blown away when I start dhcp on it. 

If you run 

```
/etc/init.d/dnsmasq restart
```

 does it give any errors? I was playing with the settings on my system earlier and it wouldn't start if there was a syntax error in the config file.

----------

## i92guboj

 *mbreith wrote:*   

> Well, I can't check my server's dnsmasq settings right now since I am not at home. My laptop (client) doesn't really have anything in "conf.d/net". I have the static ip and route information there (config_eth0 and routes_eth0), but it gets blown away when I start dhcp on it. 
> 
> If you run 
> 
> ```
> ...

 

The config file (/etc/dnsmasq.conf on the server) seems to be alright. The service starts without any error, and as shown above, I can see it is running with ps. All seems ok, the only thing is that it seems not to be listening for any odd reason. The interfaces are ok as far as I can tell (all the config stuff is in the first post).

I am really annoyed by this, since this means I have to hardcode all the ips and manually copy my resolv.conf each time I reboot any machine in the lan from the server, so I can reach the internet using dns names like every mortal does nowadays. Well, lets google another bit   :Crying or Very sad: 

----------

## i92guboj

Anyone? If not, I would be willing to hear what do you use to achieve the same functionality.

----------

## mbreith

Your desktop has two ethernet cards it looks like. You are connecting through eth0, yes. Have you tried putting eth1 down before trying dhcp? 

I know that I was having problems at one point getting my wifi to work when I had my ethernet up and not connected. It doesn't bother me, I just put 'ifconfig eth0 down' in my local.start script. I just run either the wifi or the ethernet, but not both.

Sorry, I'm not much of a dnsmasq master either  :Embarassed: 

----------

## russK

I've been using dnsmasq for a long time with no problems ... and so now I just tried the dhcping tool against it and I got "no response" so I don't put much faith in that tool or I don't know how to use it.  My dnsmasq is obviously working, all of my machines get IPs from it and I find the log in /var/log/dnsmasq quite useful sometimes (I use metalog).

Some things to check, the /usr/share/doc/dnsmasq-2.39/FAQ.bz2 mentions some potential problems ... you may want to read if you haven't already.  They mention UDP ports 67 and 68.

I tried 'netstat -an' just now and I see something listening on udp 0.0.0.0:67 but not 68.

Good luck

----------

## i92guboj

 *mbreith wrote:*   

> Your desktop has two ethernet cards it looks like. You are connecting through eth0, yes. Have you tried putting eth1 down before trying dhcp? 
> 
> I know that I was having problems at one point getting my wifi to work when I had my ethernet up and not connected. It doesn't bother me, I just put 'ifconfig eth0 down' in my local.start script. I just run either the wifi or the ethernet, but not both.
> 
> Sorry, I'm not much of a dnsmasq master either 

 

I couldn't test these past days because the net has been busy. Now I tried.

Turning off my second nic did the trick. Now it works, so I suppose I will close this. I think that I need to study my config on the client side, since dnsmasq on the server seems to be working.

Thanks so much everyone for the help   :Very Happy: 

----------

## think4urs11

just guessing now

```
dhcp-host=00:16:17:13:93:A7,192.168.0.11
```

```
eth0      Link encap:Ethernet  HWaddr 00:80:5A:46:CF:9B
```

the MAC in the dnsmasq config is the one for eth1?

----------

## i92guboj

 *Think4UrS11 wrote:*   

> just guessing now
> 
> ```
> dhcp-host=00:16:17:13:93:A7,192.168.0.11
> ```
> ...

 

No, it's the mac for eth0 on the client machine, it's correct. In any case, that should not matter even if that was the case, because the client should still have the right to get an ip from the dhcp server, even if it is not 192.168.0.11 which is the intended one.

----------

