Unlang operations with IP addresses
Alan DeKok
aland at deployingradius.com
Tue Dec 10 17:21:58 UTC 2024
On Dec 10, 2024, at 12:13 PM, Ľudovít Mikula <ludovit.mikula at mikori.sk> wrote:
> I am trying to figure out how to compute IP address from a range and netmask in freeradius v3.
I'm not sure what that means. There's no "range" in the server, just IP addresses such as 192.168.0.1, and IPs with prefixes, such as 192.168/16
> Actually something similar like this expression in v4: %{eval:%{DHCP-Your-IP-Address} & %{DHCP-Subnet-Mask} + 1}
That's not the v4 syntax, as v4 is much, much, simpler than that. But whatever...
Do you want to convert an IP + mask into an IP address prefix?
In v3, you should be able to this by simply treating the IP/prefix as a string:
something prefix = "%{DHCP-Your-IP-Address}/%{DHCP-Subnet-Mask}"
The parser won't care that there are "too many" things in the IP address. It will take care of clearing the lower bits automatically.
Alan DeKok.
More information about the Freeradius-Users
mailing list