1

I'm new here.

I have a freeradius 3 with sqlippool and LDAP authentication (with a "guest" file-configured user), all working fine. I have 2 sqlippools:

-main_pool

-guest_pool

I want to do the following:

if the user is "guest" then offer an IP from guest_pool, else offer from main_pool. My idea is to have the guests and the other users in differents vlans.

¿How can I tell to the radius dhcp "if the user is guest offer from guest_pool?

Sory for my bad english.

Thanks.

Pixel
  • 11
  • 4

1 Answers1

0

I solved it!

Thanks to Arran Cudbard-Bell for the clue!

First, created a table called "userhardaddr" with username and mac(PK) both varchar.

In (radius conf dir)/sites-enabled/defaul (section post-auth) I made a "REPLACE" query:

post-auth {
    ...
    update reply {
        Tmp-String-0 := "%{sql:REPALCE INTO userhardaddr(username,mac) VALUES(%{User-Name},%{Calling-Station-Id})}"
    ... 
    }
}

This replace the user for a connected MAC in the table if exist. If not exist, REPLACE creates the row as in INSERT.

Then, in sites-enabled/dhcp (discover and request sections):

dhcp DHPC-Discover {
    update request {
        ...
        User-Name = "%{sql:SELECT username FROM userhardaddr where mac = REPLACE ('%{DHCP-Client-Hardware-Address}',':','-')}"
        ...
    }
    ...
    if(&User-Name=='guest') {
        &Pool-Name = "guest_pool"
    }
    else {
        &Pool-Name = "main_pool"
    }
...
}
...
dhcp DHPC-Request {
    (same in discover)
}

With this I get the user name from the DB according to the mac address.

In the IF statement I compare the value returned by the query to "guest" and assign the corresponding IP pool.

Thanks again.

Regards.

Pixel
  • 11
  • 4