Matching IP addresses
Paul Thornton
paul at prt.org
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 =~ /^192.168.0.3[2-9]/) ||
(&request:NAS-IP-Address =~ /^192.168.0.[45][0-9]/) ||
(&request:NAS-IP-Address =~ /^192.168.0.6[0-3]/)) {
... do stuff
}
This is a check for "Is the NAS-IP-Address in 192.168.0.32/27"?
Is there a neater way to do this? - the obvious option:
if (&request:NAS-IP-Address == 192.168.0.32/27) {
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.
Thanks
Paul.
More information about the Freeradius-Users
mailing list