Unlang operations with IP addresses
petr.linke at seznam.cz
petr.linke at seznam.cz
Tue Dec 10 21:49:38 UTC 2024
"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"
Hi Ludo,
If you use mysql in your freeradius configuration, it is possible to create
a function that returns what you need:
CREATE FUNCTION get_gw (`ip` VARCHAR(15), `mask` VARCHAR(15)) RETURNS
VARCHAR(15) RETURN INET_NTOA(( INET_ATON(ip) & CONV(CONCAT(REPEAT(1, BIT_
COUNT(INET_ATON(mask))), REPEAT(0, 32 - BIT_COUNT(INET_ATON(mask)))), 2,
10)) +1);
select get_gw("192.168.10.20","255.255.255.0")\G
*************************** 1. row ***************************
get_gw("192.168.10.20","255.255.255.0"): 192.168.10.1
Petr
More information about the Freeradius-Users
mailing list