Time for action – using the if statement in unlang

The if statement itself is not very complex. It has the following format:


The condition part can become complex due to its many possibilities.

Obtaining a return code using the if statement

We will now look at the return code of a module and use this code to compare against the specified condition. Each module in FreeRADIUS is required to return a code after it is called. The value of this code can subsequently be used as a conditional check in the if statement.

Authorizing a user using the if statement

This exercise uses the if condition to reject an Access-Request if the user is not in the users file.

  1. Edit the sites-available/default virtual server under the FreeRADIUS configuration ...

Get FreeRADIUS Beginner's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.