regular expression to detect ipv4 IP address

Alex Sharaz alex.sharaz at york.ac.uk
Thu Sep 1 17:33:02 CEST 2016


Hi,

I'm in the process of upgrading one of my 2.2.9 servers to 3.0.12

and am trying to modify the policy.d/rewrite_calling_station_id to
check if there's an IPv4 address present in Calling-Station-Id and to
replace it with 00-00-00-00-00-00.

I've got
rewrite_calling_station_id {
        if (&Calling-Station-Id && (&Calling-Station-Id =~
/^${policy.mac-addr-regexp}$/i)) {
                update request {
                        &Calling-Station-Id :=
"%{toupper:%{1}-%{2}-%{3}-%{4}-%{5}-%{6}}"
                }
                updated
        }
        elsif (&Calling-Station-Id && (&Calling-Station-Id =~
/${policy.ipv4_regexp}/)) {
                update request {
                        &Calling-Station-Id := "00-00-00-00-00-00"
                }
                updated
        }
        else {
                noop
        }

with
ipv4_regexp = '^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$'

but am getting

Thu Sep  1 16:22:35 2016 : Error:
/etc/freeradius/policy.d/canonicalization[95]: Invalid regular
expression:
Thu Sep  1 16:22:35 2016 : Error:
/etc/freeradius/policy.d/canonicalization[95]:
^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$
Thu Sep  1 16:22:35 2016 : Error:
/etc/freeradius/policy.d/canonicalization[95]: ^ Pattern compilation
failed: Invalid preceding regular expression

Can anyone suggest a solution?
Rgds

A


More information about the Freeradius-Users mailing list