• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

DHCP available range

Scheduled Pinned Locked Moved Development
4 Posts 2 Posters 3.5k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    MrMoo
    last edited by Aug 4, 2006, 4:41 AM

    A marginally improved algorithm to make the range more user friendly:

    
                              - 
    
    

    So before it would produce 10.0.0.0-10.0.0.255, now with an ip address of 10.0.0.1 it will produce 10.0.0.2-10.0.0.254.  I wonder why the original implementation used the beginning of the subnet?  If the ip address of the machine is not at the beginning of the subnet space this can lead to a shortened range, so something different could be done.

    
    $ip = ip2long($ifcfg['ipaddr']);
    
    /* remove network address */
    $from = ( $ip & gen_subnet_mask_long($ifcfg['subnet']) ) + 1;
    $from++;
    
    /* remove broadcast address */
    $to = ip2long($ifcfg['ipaddr']) | (~gen_subnet_mask_long($ifcfg['subnet'])) - 1;
    if ($to == $ip) $to--;
    
    if ($ip > $from && $ip < $to && ($to - $ip) > 1) {
            echo long2ip($from) . ' - ' . long2ip($ip - 1) . ', ';
    
            $from = $ip + 1;
    } else if (($to - $ip) == 1) {
            $to = $ip - 1;
    }
    
    echo long2ip($from);
    ?> - 
    
    

    So an IP address in the middle at 10.0.0.100 would produce a range 10.0.0.1-10.0.0.99, 10.0.0.101-10.0.0.254, and the end case of an ip address of 10.0.0.254 would yield a range 10.0.0.1-10.0.0.253.

    1 Reply Last reply Reply Quote 0
    • S
      sullrich
      last edited by Aug 4, 2006, 3:51 PM

      Really not sure which file this even belongs in.

      Can you start supplying diff -rub patches if you wish for these types of changes to be commited?

      Thanks

      1 Reply Last reply Reply Quote 0
      • M
        MrMoo
        last edited by Aug 5, 2006, 2:31 AM

        Okie dokie.

        :D

        services_dhcp.php.patch.txt

        1 Reply Last reply Reply Quote 0
        • S
          sullrich
          last edited by Aug 5, 2006, 8:29 PM

          Commited, thanks!

          1 Reply Last reply Reply Quote 0
          4 out of 4
          • First post
            4/4
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
            This community forum collects and processes your personal information.
            consent.not_received