Unlang operations with IP addresses
Ľudovít Mikula
ludovit.mikula at mikori.sk
Tue Dec 10 18:44:02 UTC 2024
Ok, I've got the question wrong.
What I want to do: based on assigned IP address and subnet mask,
compute first IP address from the range from which the IP address was
assigned.
Example:
given:
DHCP-Your-IP-Address: 192.168.10.20
DHCP-Subnet-Mask: 255.255.255.0
would produce:
DHCP-Router-Address: 192.168.10.1
Ludo
On 10. 12. 2024 18:21, Alan DeKok wrote:
> 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.
>
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
More information about the Freeradius-Users
mailing list