# dhcp getting wrong adress from server/uses cache?

## ingemar

Hi!

I'm using Linksys router with DD-WRT firmware, but there's some sort of problem, and I think its my machine that's causing it. I have set up static leases for my computer, so that port forwarding and such can work easily, but I never seem to get the right ip adress! In the web interface for dd-wrt I can see all the active leases, and when they are bound to end, and my static is there, next to the new one, except for it having the wrong ip adress.

I've tried removing the faulty lease from the dd-wrt interface, and running dhclient (after removing some files from /var/lib/dhcp/), and that results in giving me the correct ip adress, but when using the standard way in gentoo (/etc/init.d/net.eth0 blah) which uses dhcpcd, it doesn't work. I keep getting the same ip, but it's not the desired one.. Could it be that dhcpcd uses some kind of cache it uses if it once have worked? I know dhclient has this feature.. Is there some file I can delete so that dhcpcd gets the correct adress?

----------

## darkphader

I think the dhcp client asks for the ip address it had previously but if you have a lease tied to a mac address the server should nak the old address and present the new one. Suggest a remerge of the latest dhcp client and a double-check of the mac address for the reservation in your dhcp server settings.

Chris

----------

## ingemar

The mac address specified in the router interface is of course correct. It exists two leases in the router with the exact same mac adress, one which is the one I want it to be, and the other, which isn't. And a reemerge doesn't help here..

----------

## cyrillic

If dhclient works better than dhcpcd for you, then just put this in /etc/conf.d/net

```
modules=( "dhclient" ) 
```

----------

## UberLord

dhcpcd-3.1 uses a DUID in the client ID instead of the MAC address.

This is RFC compliant as the Client ID could technically hold anything.

To change to a MAC address, use dhcpcd_eth0="-I ''" or emerge dhcpcd with the vram flag.

----------

## MickKi

 *UberLord wrote:*   

> dhcpcd-3.1 uses a DUID in the client ID instead of the MAC address.
> 
> This is RFC compliant as the Client ID could technically hold anything.
> 
> To change to a MAC address, use dhcpcd_eth0="-I ''" or emerge dhcpcd with the vram flag.

  Thanks, the vram flag solved my problem (different router, but it would not see the MAC address no matter what I passed on to it via dhcpcd and /etc/conf.d/net.eth0).  What does vram do?  What is it there for?

----------

## UberLord

vram = volatile ram.

Or in more simple terms, storage is nor permament.

This means we cannot store the DUID and use that in a client node identifier as it would change all the time.

Instead we revert to using the MAC address

----------

## darkphader

 *UberLord wrote:*   

> dhcpcd-3.1 uses a DUID in the client ID instead of the MAC address.

 

Is this what appears in the uid field when examaming the dhcpd.leases file?

```
lease 192.168.1.183 {

  starts 1 2007/11/19 17:49:54;

  ends 1 2007/11/19 19:49:54;

  binding state active;

  next binding state free;

  hardware ethernet 00:a0:d1:2c:19:1b;

  uid "\001\000\240\321,\031\033";
```

So that in the above case "\001\000\240\321,\031\033" would be the DUID you speak of?

Thanks.

Chris

----------

## UberLord

Right field, but wrong value - your's looke like a standard MAC address.

Here's how one looks with a Client Node Identifer (IAID + DUID)

```
uid "\377bge0\000\001\000\001\015\325\4444\000\0261!\372y";
```

As you can see, it's a little bit longer.

I've changed a few of my values to obscure it a little.

----------

## darkphader

It's just the value that is there. I didn't make it up :)

Just wondered if I can use that value as the data in the 'option dhcp-client-identifier' parameter for dhcpd instead of the MAC address as the data to 'hardware ethernet'.

As in:

```
host myhostname {

  option dhcp-client-identifier "\001\000\035\0150\226\371";

  fixed-address myhostname.mydomain;

  }
```

Intead of:

```
host myhostname {

  hardware ethernet 20:17:e9:01:67:5b;

  fixed-address myhostname.mydomain;

  }
```

It does appear to work just fine.

Thanks.

Chris

----------

## trailnut

I don't have one of those DD-WRT routers so I'll just throw this out here, if it doesn't apply sorry for the noise. I once had a router that allowed me to specify a static address that was inside my dynamic address range. This of course didn't work out very well and it silently ignored my static setting until I corrected it and moved it outside the range.

----------

## darkphader

I'm getting timeouts from dhcpd:

```
  * Stopping eth0

 *   Bringing down eth0

 *     Stopping dhcpcd on eth0 ...                                                             

 *     Shutting down eth0 ...                                                                  

 * Starting eth0

 *   Bringing up eth0

 *     dhcp

 *       Running dhcpcd ...

Error, eth0: timed out                                                                         

 *       eth0 received address 169.254.228.177/16
```

Yet in a about 40 more seconds ifconfig will finally show the dhcp assigned address:

```
ifconfig

eth0      Link encap:Ethernet  HWaddr 00:16:76:AA:BF:70

          inet addr:192.168.107.6  Bcast:192.168.107.255  Mask:255.255.255.0

          inet6 addr: fe80::216:76ff:feaa:bf70/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

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

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

          collisions:0 txqueuelen:1000

          RX bytes:37954624 (36.1 Mb)  TX bytes:105903847 (100.9 Mb)

          Base address:0x1000 Memory:e5000000-e5020000
```

I notice the same problem with my Sony PS3 - takes a long time to get an IP address. The server is a Gentoo box running net-misc/dhcp-3.1.0. Any clues on troubleshooting this?

----------

## MickKi

Is this new DUID thingy an IPv6 feature?  Googling for it shows it referenced within an IPv6 context and I do not have IPv6 enabled in my kernel.

----------

## UberLord

 *darkphader wrote:*   

> I'm getting timeouts from dhcpd:
> 
> Yet in a about 40 more seconds ifconfig will finally show the dhcp assigned address
> 
> I notice the same problem with my Sony PS3 - takes a long time to get an IP address. The server is a Gentoo box running net-misc/dhcp-3.1.0. Any clues on troubleshooting this?

 

Interesting. That shows a problem probably with the dhcp server as I doubt the PS3 uses dhcpcd.

Maybe postup your config (but not here directly lol) somewhere or try other dhcp versions in portage?

----------

## UberLord

 *MickKi wrote:*   

> Is this new DUID thingy an IPv6 feature?  Googling for it shows it referenced within an IPv6 context and I do not have IPv6 enabled in my kernel.

 

It's required for IPv6.

It's required for IPv4 over infiniband which dhcpcd-3.1 supports, hence it's enabled by default.

Aside from that it's optional.

----------

## darkphader

 *UberLord wrote:*   

> Interesting. That shows a problem probably with the dhcp server as I doubt the PS3 uses dhcpcd.

 

Turned out to be more nebulous than that. Stupid Dell switch defaults to STP and no portfast, wrecks havoc with dhcp. Arrrr...

Thanks again.

Chris

----------

