regular expression to detect ipv4 IP address
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
Alex Sharaz <alex.sharaz@york.ac.uk> wrote:
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:
Either check into whether FR is configured to use pcre expressions, or write it out longhand. The latter is probably the faster resolution.
Yup was a bit quicker :-)) Thx A On 1 September 2016 at 16:40, Brian Julin <BJulin@clarku.edu> wrote:
Alex Sharaz <alex.sharaz@york.ac.uk> wrote:
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:
Either check into whether FR is configured to use pcre expressions, or write it out longhand. The latter is probably the faster resolution.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
participants (2)
-
Alex Sharaz -
Brian Julin