proposed patch for "stable" dhcp address assignmen

Discussion in 'HyperWRT Firmware' started by afyfe, Nov 25, 2004.

  1. afyfe

    afyfe Network Guru Member

    I've created a patch for udhcpd that changes the search for an available IP address. Instead of starting at the first available address, it now starts somewhere in the middle of the range, depending on the client's MAC address. This makes it likely that any given client will always get the same IP address assigned. If there is a conflict, changing the size of the dhcp address range is likely to avoid it.

    The patch (15 changed/added lines in 3 files) can be down loaded from

    I was able to build a new udhcpd, copy it to my router, kill off the existing process and substitute a new one using the revised binary. It works as expected -- my clients were assigned .102, .142, .112 and .117.

    It's not as good as static dhcp, but it's close.
  2. Avenger20

    Avenger20 Network Guru Member

    Thanks! This really looks nice :)

    Will do some tests with it and see if it can be included.
  3. ravn

    ravn Network Guru Member


    Even though we are still a lot of people just waiting for static DHCP in hyperwrt :(
  4. afyfe

    afyfe Network Guru Member

    Hi Avenger,

    I was playing around with this a bit more and discovered that the addresses assigned were not what I expected -- it looks like while the first 6 bytes of chaddr are the mac address, the remaining ones aren't necessarily 0, even though they appear to be so in the packets that are sent. Perhaps it would be better to simply assume the chaddr field is the mac address, and take the low order 32 bits:

    for (i=2; i<6; ++i) hash = hash * 256 + chaddr;

    It makes it really easy to predict what you're going to get.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice