Matching IP addresses

Arran Cudbard-Bell a.cudbardb at freeradius.org
Wed Dec 6 21:26:04 CET 2017



> On 4 Dec 2017, at 15:10, Matthew Newton <mcn at freeradius.org> wrote:
> 
> 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") {
>  ...
> }

You need to cast NAS-IP-Address to the IPv4 prefix type I think?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 874 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20171206/0e86318f/attachment.sig>


More information about the Freeradius-Users mailing list