I have some rewrites like this (in pre-proxy): attr_rewrite fixcboss6 { attribute = NAS-IP-Address searchin = "proxy" searchfor = "172.29.51.24" replacewith = "172.26.64.100" new_attribute = no append = no max_matches = 1 } Radius gets packet generated by radtest: User-Name = "guest" User-Password = "guest" NAS-IP-Address = 172.29.51.24 NAS-Port = 1 [...skipped...] +- entering group pre-proxy expand: 172.29.51.24 -> 172.29.51.24 fixcboss6: Does not match: NAS-IP-Address = ╛?3? fixcboss6: Could not find value pair for attribute NAS-IP-Address ++[fixcboss6] returns ok ++[pre_proxy_log] returns ok User-Name = "guest" User-Password = "guest" NAS-IP-Address = 172.29.51.24 NAS-Port = 1 Proxy-State = 0x3336 Proxying request 1 to home server 172.29.51.10 port 1812 User-Name = "guest" User-Password = "guest" NAS-IP-Address = 172.29.51.24 NAS-Port = 1 Proxy-State = 0x3336 Why it does not works? PS Here is the full debug - http://rafb.net/p/le0HmX69.html and here is parts of config: http://rafb.net/p/UB04Mr14.html -- With best regards, Evgeniy Kozhuhovskiy, Leader of Services team, Minsk State Phony Network, RUE Beltelecom.
Evgeniy Kozhuhovskiy wrote: ...
fixcboss6: Does not match: NAS-IP-Address = ╛?3?
It's trying to do a regex match against the packed (32-bit) IP address, not against the ASCII string describing the IP address. That can easily be fixed. But in any case, you *don't* need to use attr_rewrite for this. Just put the following into the pre-proxy section, instead of the "fixcboss6" line: ... if (proxy:NAS-IP-Address == 172.29.51.24) { update proxy { NAS-IP-Address := 172.26.64.100 } } ... It's that easy. See "man unlang" for details. Alan DeKok.
Alan DeKok wrote:
It's trying to do a regex match against the packed (32-bit) IP address, not against the ASCII string describing the IP address. That can easily be fixed.
But in any case, you *don't* need to use attr_rewrite for this. Just put the following into the pre-proxy section, instead of the "fixcboss6" line:
Yeah, this is possible too. attr_rewrite left from 1.x version PS Thanks :)
... if (proxy:NAS-IP-Address == 172.29.51.24) { update proxy { NAS-IP-Address := 172.26.64.100 } } ...
It's that easy. See "man unlang" for details.
Alan DeKok. - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-- With best regards, Evgeniy Kozhuhovskiy, Leader of Services team, Minsk State Phony Network, RUE Beltelecom.
Alan DeKok wrote:
if (proxy:NAS-IP-Address == 172.29.51.24) { update proxy { NAS-IP-Address := 172.26.64.100 } } It works, but instead of update proxy should be update proxy-request, and instead of proxy:NAS-IP-Address should be just an NAS-IP-Address
-- With best regards, Evgeniy Kozhuhovskiy, Leader of Services team, Minsk State Phony Network, RUE Beltelecom.
participants (2)
-
Alan DeKok -
Evgeniy Kozhuhovskiy