Use the RADIUS SQL IP Pool module to allocate addresses for DHCP
[freeradius.git] / raddb / policy.conf
index 3955429..7a64ac8 100644 (file)
@@ -333,4 +333,29 @@ policy {
                        noop
                }
        }
+
+       #  Assign compatibility data to request for sqlippool
+       dhcp_sqlippool.postauth {
+
+
+               #  Do some minor hacks to the request so that it looks
+               #  like a RADIUS request to the SQL IP Pool module.
+               update request {
+                       User-Name = "DHCP-%{DHCP-Client-Hardware-Address}"
+                       Calling-Station-Id = "%{DHCP-Client-Hardware-Address}"
+                       NAS-IP-Address = %{%{DHCP-Gateway-IP-Address}:-127.0.0.1}
+                       Acct-Status-Type = Start
+               }
+
+               #  Call the actual module
+               dhcp_sqlippool
+
+               #  Convert Framed-IP-Address to DHCP, but only if we
+               #  actually allocated an address.
+               if (ok) {
+                       update reply {
+                               DHCP-Your-IP-Address = "%{reply:Framed-IP-Address}"
+                       }
+               }
+       }
 }