Q&A: Can I match my Radius clients against station ID?

Question:

Can I match my clients against their station ID?

Answer

Yes it is possible by adding the following to your clients.conf:

<pre>
elsif ("%{Called-Station-Id}" =~ /:Schule$/ ) {
</pre>

Note: This check is case sensitive.

Option 1: Rewrite all clients to a valid format

To rewrite your clients IDs to a valid format use a new policy by adding the following to raddb/policy.conf:

#
# Rewrite called station id attribute into a standard format.
#
rewrite_calling_station_id {
        if (Calling-Station-Id =~ /([0-9a-f]{2})[-:]?([0-9a-f]{2})[-:.]?([0-9a-f]{2})[-:]?([0-9a-f]{2})[-:.]?([0-9a-f]{2})[-:]?([0-9a-f]{2})/i) {
                update request {
                        Calling-Station-Id := "%{tolower:%{1}-%{2}-%{3}-%{4}-%{5}-%{6}}"
                }
        }
        else {
                noop
        }
}

Option 2: Use regular expressions

clients.conf:

<pre>
elsif ("%{Called-Station-Id}" =~ /:[Ss]chule$/ ) {
</pre>
Mastodon