Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login
    Introducing Netgate Nexus: Multi-Instance Management at Your Fingertips.

    Fix for sorting DHCPv6 reservations

    Scheduled Pinned Locked Moved DHCP and DNS
    1 Posts 1 Posters 134 Views 1 Watching
    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.
    • B Offline
      b_chris
      last edited by

      Hi everyone,
      today I finally found the time to investigate why the DHCP reservation in Services -> DHCPv6 Server -> #Network# aren't sorted by IP address like they are in the DHCPv4 section.
      It turns out the fix is pretty easy and I'd like to share it here.
      The root cause is, that for sorting a PHP built-in function named ip2long is used. PHP.net states that this function only works for IPv4.

      The fix is, to use another (and simpler approach) in /usr/local/www/services_dhcpv6_edit.php for sorting:
      old (ipcomp calls some other functions an finally ip2long):

      function staticmapcmp($a, $b) {
        return ipcmp($a['ipaddrv6'], $b['ipaddrv6']);
      }
      

      new:

      function staticmapcmp($a, $b) {
        $ipA = inet_pton($a['ipaddrv6']);
        $ipB = inet_pton($b['ipaddrv6']);
        return strcmp($ipA, $ipB);
      }
      

      After changing, you only need to edit one entry for each network and save it (without changes) to trigger the sorting.
      Pretty easy after all :)

      This file can be used to patch pfSense (be careful! I'm just a random stranger! Make backups!).
      For some reason you have to copy/paste the content in System->Patches. pfSense rejects the file if you just upload (don't know why).
      Path strip count: 1
      Base directory: /
      IPv6DhcpReservationSort.diff

      Have fun with it but be careful!

      1 Reply Last reply Reply Quote 1
      • First post
        Last post
      Copyright 2026 Rubicon Communications LLC (Netgate). All rights reserved.
      Privacy Policy · Cookie Policy