SQL query with unixodbc and freetds

Vieri rentorbuy at yahoo.com
Thu Dec 7 11:55:52 CET 2017


Hi,

I'm a bit confused as how I should configure an SQL unixodbc/freetds instance to do some custom queries. I do NOT require to set up the full radius schema. My goal is quite simple. Instead of looking up a MAC address in a plain text file, I'd like to look it up in a database.

Currently, I'm using a "usersfile" with a list of MAC addresses. I check it in the "authorize" section.

How do I do the same, but with a DB lookup?

I'd like to use something like: if ("%{sql:SELECT count(*) FROM MACTABLE WHERE MAC = '%{1}'}" > 0) {...
I also extract the host name from some messages, and do similar lookups such as:
if ("%{sql:SELECT count(*) FROM HOSTTABLE WHERE HOST = '%{1}' AND DOMAN = '%{2}'}" > 0) {...

I don't know if I need to configure mods-available/sql and how.

I found this in my system:

/usr/lib64/rlm_sql_unixodbc.so

Guides such as the one at http://wiki.freeradius.org/guide/SQL-HOWTO-for-freeradius-3.x-on-Debian-Ubuntu seem to be overkill in my case. I don't need to load a full radius schema. I just need to do a simple DB lookup.
Also, I haven't found a unixODBC example yet.

Thanks,

Vieri


More information about the Freeradius-Users mailing list