Matching IP addresses

Matthew Newton mcn at freeradius.org
Mon Dec 4 16:10:01 CET 2017


On Mon, 2017-12-04 at 15:05 +0000, Paul Thornton wrote:
> 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) {
> 

if (NAS-IP-Address < "192.168.0.32/27") {
  ...
}

-- 
Matthew



More information about the Freeradius-Users mailing list