IP Addr Comparison

BOUILLOUD Corentin cbouilloud at systra.com
Fri May 31 14:48:03 UTC 2024


Hi Team,

I would like to ask your help about IP address comparisons in FreeRADIUS 3.0.27.
I want to restrict a mac-address to a network, but comparison of ip address with a subnet doesn't seems to work as a check items :

11-22-33-44-55-66       NAS-IP-Address < 192.168.8.0/22
/etc/freeradius/3.0/authorized_macs[10]: Parse error (check) for entry 11-22-33-44-55-66: Invalid IPv4 mask length "/22".  Only "/32" permitted for non-prefix types

Yet, documentation says it should be possible.

"The syntax allows conditions such as 192.0.2.1 < 192.0.2/24.
This condition will return true, as the IP address 192.0.2.1' is within the network `192.0.2/24."

I also tried casting the attribute, without success :

11-22-33-44-55-66       <ipaddr>NAS-IP-Address < "192.168.8.0/22"
/etc/freeradius/3.0/authorized_macs[10]: Parse error (check) for entry 11-22-33-44-55-66: Invalid attribute name


Do user files have a different behaviour for comparisons and casting ?
I could use regex as a backup solution but it's quickly going to get difficult to read in the file :

11-22-33-44-55-66      NAS-IP-Address =~ "/^192\.168\.(8|9|10|11)\./"

https://freeradius.org/documentation/freeradius-server/4.0.0/raddb/mods-config/files/users.html#_format
https://freeradius.org/documentation/freeradius-server/3.0.27/unlang/condition/cmp.html#_ip_address_comparisons
https://freeradius.org/documentation/freeradius-server/3.0.27/unlang/condition/cmp.html#_casting

Regards,
Corentin BOUILLOUD


========================================================
This message has been scanned for malware. This message and any attachments (the "message") are confidential, intended solely for the addressees, and may contain legally privileged information. Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration. Neither our company or any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified.
=========================================================
Ce message a ete verifie et ne contient pas de programme malveillant. Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et susceptibles de contenir des informations couvertes par le secret professionnel. Ce message est etabli a l'intention exclusive de ses destinataires. Toute utilisation ou diffusion non autorisee est interdite. Tout message electronique est susceptible d'alteration. Notre societe et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme falsifie. O
=========================================================


More information about the Freeradius-Users mailing list