Different DHCP Pools based on User

Alan DeKok aland at deployingradius.com
Sat Jun 16 16:12:35 CEST 2018


On Jun 16, 2018, at 9:27 AM, Paul via Freeradius-Users <freeradius-users at lists.freeradius.org> wrote:
> thanks for your answer! I'm using MySQL for my current setup
> (pretty much standard setup with standard schema)
> 
> My problem is:
> * How to save the MAC <-> User Associations in the Database?

  Since this is non-standard, you will have to create this association yourself.

  Create a new table in SQL.  Have 2 columns: MAC and User-Name.  Make in index on User-Name.

  Then in the post-auth section, add something like:

	update reply {
		Tmp-String-0 := "%{sql:REPLACE INTO table (username, mac) VALUES (%{User-Name}, %{Calling-Station-Id})}"
	}

  You'll need to use the real table name instead of "table".

> * How to configure DHCP to use this Association?

  In the DHCP configuration, SELECT the User-Name from the MAC address:

dhcp DHCP-Discover {
	...
	update request {
		User-Name := "%{sql:SELECT username FROM table WHERE mac = '%{DHCP-Client-Hardware-Address}'}"
	}
	...
}

  And then the User-Name *should* show up.

  As with anything, you will need to test this.  Ensure that the MAC *is* in the Calling-Station-Id.  Make sure it's the same format as DHCP-Client-Hardware-Address.

  The details need finishing, but the above configuration should get you over the most complex portion.

  Alan DeKok.




More information about the Freeradius-Users mailing list