3.110.4. FindQuery Previous topic Parent topic Child topic Next topic

This optional parameter allows you to define a custom SQL query to find an available address or prefix. The default is:
select TIME_STAMP, YIADDR, SUBNETMASK, DNSSERVER from RADPOOL where POOL=’%0’
       and STATE=0 order by TIME_STAMP
The variables are replaced as follows:
  • %0 by the pool hint
  • %1 by the user name
  • %2 with the lease expiry time
  • %3 by SQL quoted NasId value
Tip
You can get a substantial speedup during address allocation with mysql by adding ‘limit 1’ to the end of the FindQuery.
This example uses NAS_ID column to allocate an IPv6 prefix from the range assigned to the user's NAS. The pool has been previously initialised with NAS_IDs belonging to known NASes.
# Our NASes all send NAS-IPv6-Address, e.g. 2001:db8:2::2
NasId %{NAS-IPv6-Address}
FindQuery select TIME_STAMP, YIADDR, SUBNETMASK, DNSSERVER from RADPOOL
          where POOL=’%0’ and STATE=0 and NAS_ID=%3 order by TIME_STAMP