Matching IP addresses

Paul Thornton paul at
Mon Dec 4 16:05:40 CET 2017

Hi all,

I currently have some unlang code that looks like this (I've fixed the 
wrapping to make it legible:

if ((&request:NAS-IP-Address =~ /^[2-9]/) ||
     (&request:NAS-IP-Address =~ /^192.168.0.[45][0-9]/) ||
     (&request:NAS-IP-Address =~ /^[0-3]/)) {
   ... do stuff

This is a check for "Is the NAS-IP-Address in"?

Is there a neater way to do this? - the obvious option:
if (&request:NAS-IP-Address == {
doesn't work, and I can't see any anything else in a rummage through the 
documentation that might work.

It isn't a big deal, the regex option works; it just isn't very elegant.



More information about the Freeradius-Users mailing list