dynamic-clients supporting CDIR entries in v3
Hi all, It was previously mentioned on the list (by Arran) that:
Just to note that adding IP ranges dynamically does work in v3.0.x. The check is then relaxed to ensure the src IP address is in the range which was just added.
I'd really like to get his working. So I've converted my config to v3, installed the release v3.0.4 and with read_clients = no, I've setup my dynamic-clients server thus: server vs3001 { listen { ipaddr = * port = 3001 type = auth } client dynamic_all_3001 { ipaddr = 0.0.0.0/0 dynamic_clients = dynamic_client_server lifetime = 3600 } ... } server dynamic_client_server { authorize { if ("%{sql:SELECT nasname FROM nas WHERE udp_port = %{Packet-Dst-Port} LIMIT 1}") { update control { FreeRADIUS-Client-IP-Address = "%{Packet-Src-IP-Address}" FreeRADIUS-Client-Shortname = "%{sql: SELECT nasname FROM nas WHERE udp_port = %{Packet-Dst-Port} LIMIT 1}" FreeRADIUS-Client-Secret = "%{sql: SELECT secret FROM nas WHERE udp_port = %{Packet-Dst-Port} LIMIT 1}" FreeRADIUS-Client-Virtual-Server = "%{sql: SELECT server FROM nas WHERE udp_port = %{Packet-Dst-Port} LIMIT 1}" FreeRADIUS-Client-NAS-Type = "other" } } ok } } With a nas table that looks like: nasname secret server udp_port ========================================== 0.0.0.0/1, testing1 vs3001 3001 128.0.0.0/1 testing1 vs3001 3001 When I test from another host, I get: Received Access-Request Id 8 from 10.0.0.2:48920 to 10.0.0.3:3001 length 86 server dynamic_client_server { ... (0) EXPAND %{sql:SELECT nasname FROM nas WHERE udp_port = %{Packet-Dst-Port} LIMIT 1} (0) --> 128.0.0.0/1 ... (0) EXPAND %{Packet-Src-IP-Address} (0) --> 10.0.0.2 (0) FreeRADIUS-Client-IP-Address = 10.0.0.2 ... (0) EXPAND %{sql: SELECT nasname FROM nas WHERE udp_port = %{Packet-Dst-Port} LIMIT 1} (0) --> 128.0.0.0/1 (0) FreeRADIUS-Client-Shortname = "128.0.0.0/1" ... (0) EXPAND %{sql: SELECT secret FROM nas WHERE udp_port = %{Packet-Dst-Port} LIMIT 1} (0) --> testing1 (0) FreeRADIUS-Client-Secret = "testing1" ... (0) EXPAND %{sql: SELECT server FROM nas WHERE udp_port = %{Packet-Dst-Port} LIMIT 1} (0) --> vs3001 (0) FreeRADIUS-Client-Virtual-Server = "vs3001" (0) FreeRADIUS-Client-NAS-Type = 'other' ... } # server dynamic_client_server - Added client 10.0.0.2 with shared secret testing1 So it's adding the client by just its single source IP address, not the CIDR network it gets from SQL. This is backed up by radmin with: radmin> show client list 0.0.0.0/0 10.0.0.2 So how do you setup the dynamic-clients server fields to load the CIDR network entry? They load perfectly with read_clients = yes, but not with dynamic-clients. If I set FreeRADIUS-Client-IP-Address to anything other than the source IP address of the packet (here it's set to nasname), I get an unknown client error: (0) EXPAND %{sql: SELECT nasname FROM nas WHERE udp_port = %{Packet-Dst-Port} LIMIT 1} (0) --> 128.0.0.0/1 (0) } # update control = fail (0) } # if ("%{sql:SELECT nasname FROM nas WHERE udp_port = %{Packet-Dst-Port} LIMIT 1}") = fail (0) } # authorize = fail } # server dynamic_client_server Ignoring request to auth address * port 3001 as server vs3001 from unknown client 10.0.0.2 port 58887 proto udp But of course I was expecting that! :-) Also, can or would it be would it be possible, for radmin to show the virtual server that a client is associated with? Cheers very much all, I'm so close to the final config I'm after!!! Kev/.
Kev Pearce wrote:
(0) FreeRADIUS-Client-Shortname = "128.0.0.0/1"
That's just a name, a string. It's not an IP address. It could be "foo" instead of "128.0.0.1/1".
So it's adding the client by just its single source IP address, not the CIDR network it gets from SQL.
The single source address is stored in the attribute FreeRADIUS-Client-IP-Address. Which is an IP address, not a CIDR.
So how do you setup the dynamic-clients server fields to load the CIDR network entry?
Right now you don't. That code has to be written.
If I set FreeRADIUS-Client-IP-Address to anything other than the source IP address of the packet (here it's set to nasname), I get an unknown client error:
Yes. There is no "FreeRADIUS-Client-IP-Prefix" attribute. It's probably not hard to add. But it still has to be done.
Also, can or would it be would it be possible, for radmin to show the virtual server that a client is associated with?
With some changes... that code is in src/main/command.c. :) Alan DeKok.
Kev Pearce wrote:
Thank you Alan. So I wonder what Arran meant by his comment: "Just to note that adding IP ranges dynamically does work in v3.0.x"
It turns out that does work. Just set the prefix in the correct attribute. Instead of using FreeRADIUS-Client-IP-Address, use: FreeRADIUS-Client-IP-Prefix = 1.2.3.0/24 And it should work. Alan DeKok.
On 14 Sep 2014, at 12:11, Alan DeKok <aland@deployingradius.com> wrote:
Kev Pearce wrote:
Thank you Alan. So I wonder what Arran meant by his comment: "Just to note that adding IP ranges dynamically does work in v3.0.x"
It turns out that does work. Just set the prefix in the correct attribute. Instead of using FreeRADIUS-Client-IP-Address, use:
FreeRADIUS-Client-IP-Prefix = 1.2.3.0/24
And it should work.
Yeah, I added that when I rewrote some of the client code between 3.0.3/3.0.4. I think the actual attribute was there before that, but it wouldn't have worked, probably just have produced an error. -Arran Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
Hi All,
It turns out that does work. Just set the prefix in the correct attribute. Instead of using FreeRADIUS-Client-IP-Address, use: FreeRADIUS-Client-IP-Prefix = 1.2.3.0/24
So I had a go at testing this... what I have is my SQL database is for my virtual server (vs3001) I have two entries: 128.0.0.0/1 and 0.0.0.0/1 both with the same secret. I have my dynamic_clients setup as 0.0.0.0/0. I have a test machine with two interfaces, one in a 10.x subnet and one in a 192.x subnet. This allows me to test both halves of my nas CIDR ranges. When I test to the 192 address, all works fine, it adds the 128.0.0.0/1 CIDR subnet perfect: Received Access-Request Id 127 from 192.168.26.132:56120 to 192.168.26.131:3001 length 86 server dynamic_client_server { ... (0) EXPAND %{sql: SELECT nasname FROM nas WHERE udp_port = %{Packet-Dst-Port} AND INET_ATON('%{Packet-Src-IP-Address}') >= ip_dec_start AND INET_ATON('%{Packet-Src-IP-Address}') <= ip_dec_end LIMIT 1} (0) --> 128.0.0.0/1 (0) FreeRADIUS-Client-IP-Prefix = 128.0.0.0/1 ... (0) EXPAND %{sql: SELECT nasname FROM nas WHERE udp_port = %{Packet-Dst-Port} AND INET_ATON('%{Packet-Src-IP-Address}') >= ip_dec_start AND INET_ATON('%{Packet-Src-IP-Address}') <= ip_dec_end LIMIT 1} (0) --> 128.0.0.0/1 (0) FreeRADIUS-Client-Shortname = "128.0.0.0/1" ... (0) EXPAND %{sql: SELECT secret FROM nas WHERE udp_port = %{Packet-Dst-Port} AND INET_ATON('%{Packet-Src-IP-Address}') >= ip_dec_start AND INET_ATON('%{Packet-Src-IP-Address}') <= ip_dec_end LIMIT 1} (0) --> testing1 (0) FreeRADIUS-Client-Secret = "testing1" ... (0) EXPAND %{sql: SELECT server FROM nas WHERE udp_port = %{Packet-Dst-Port} AND INET_ATON('%{Packet-Src-IP-Address}') >= ip_dec_start AND INET_ATON('%{Packet-Src-IP-Address}') <= ip_dec_end LIMIT 1} (0) --> vs3001 (0) FreeRADIUS-Client-Virtual-Server = "vs3001" (0) FreeRADIUS-Client-NAS-Type = 'other' (0) } # update control = noop (0) } # if ("%{sql:SELECT nasname FROM nas WHERE udp_port = %{Packet-Dst-Port} AND INET_ATON('%{Packet-Src-IP-Address}') >= ip_dec_start AND INET_ATON('%{Packet-Src-IP-Address}') <= ip_dec_end LIMIT 1}") = noop (0) [ok] = ok (0) } # authorize = ok } # server dynamic_client_server - Added client 128.0.0.0 with shared secret testing1 Radmin also backs this up: radmin> show client list 0.0.0.0/0 0.0.0.0/0 128.0.0.0/1 radmin> But... when I connect from the 10 network (where it should match 0.0.0.0/1) I get: Received Access-Request Id 151 from 10.0.0.2:43792 to 10.0.0.3:3001 length 86 server dynamic_client_server { ... (0) EXPAND %{sql: SELECT nasname FROM nas WHERE udp_port = %{Packet-Dst-Port} AND INET_ATON('%{Packet-Src-IP-Address}') >= ip_dec_start AND INET_ATON('%{Packet-Src-IP-Address}') <= ip_dec_end LIMIT 1} (0) --> 0.0.0.0/1 (0) FreeRADIUS-Client-IP-Prefix = 0.0.0.0/1 ... (0) EXPAND %{sql: SELECT nasname FROM nas WHERE udp_port = %{Packet-Dst-Port} AND INET_ATON('%{Packet-Src-IP-Address}') >= ip_dec_start AND INET_ATON('%{Packet-Src-IP-Address}') <= ip_dec_end LIMIT 1} (0) --> 0.0.0.0/1 (0) FreeRADIUS-Client-Shortname = "0.0.0.0/1" ... (0) EXPAND %{sql: SELECT secret FROM nas WHERE udp_port = %{Packet-Dst-Port} AND INET_ATON('%{Packet-Src-IP-Address}') >= ip_dec_start AND INET_ATON('%{Packet-Src-IP-Address}') <= ip_dec_end LIMIT 1} (0) --> testing1 (0) FreeRADIUS-Client-Secret = "testing1" ... (0) EXPAND %{sql: SELECT server FROM nas WHERE udp_port = %{Packet-Dst-Port} AND INET_ATON('%{Packet-Src-IP-Address}') >= ip_dec_start AND INET_ATON('%{Packet-Src-IP-Address}') <= ip_dec_end LIMIT 1} (0) --> vs3001 (0) FreeRADIUS-Client-Virtual-Server = "vs3001" (0) FreeRADIUS-Client-NAS-Type = 'other' (0) } # update control = noop (0) } # if ("%{sql:SELECT nasname FROM nas WHERE udp_port = %{Packet-Dst-Port} AND INET_ATON('%{Packet-Src-IP-Address}') >= ip_dec_start AND INET_ATON('%{Packet-Src-IP-Address}') <= ip_dec_end LIMIT 1}") = noop (0) [ok] = ok (0) } # authorize = ok } # server dynamic_client_server Failed to add duplicate client 0.0.0.0/1 - Cannot add client 0.0.0.0: Internal error Ignoring request to auth address * port 3001 as server vs3001 from unknown client 10.0.0.2 port 43792 proto udp It thinks it has a duplicate entry... which leads me to believe it's not checking the mask, just comparing IP addresses. I also noted the text that is output when the CIDR range is successfully added only says the network id and not the CIDR mask. Same with the Cannot add client message too. When loading from SQL at start up this works great and adds both of my two nas clients per virtual server (exactly what I'm after :-) ). But not when it's done by dynamic clients, which I'm also after... Any ideas as to how to get FR to dynamically learn the 0.0.0.0/1 without complaining it's a duplicate of 0.0.0.0/0? Or might this be considered a bug...? Cheers very much Kev/.
Any ideas as to how to get FR to dynamically learn the 0.0.0.0/1 without complaining it's a duplicate of 0.0.0.0/0? Or might this be considered a bug...?
It is in fact a bug, yes. The config parser accepts '*' for ip addresses, to allow binding to wildcard addresses. When it gets a wildcard, it sets the IP address to INADDR_ANY usually 0.0.0.0. It also sets the prefix for the ip address to be /32 or /128 (ipv6), which of course defeats the purpose of a wildcard. There was code in the client_add function to fix that up, so when it got an INADDR_ANY value, it'd set the prefix to 0. It should have also been checking that the prefix was /32 (ipv4) or /128 (ipv6) before modifying it. I've pushed a fix. Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
Thanks very much Arran, I've give it a try. Kev/. -----Original Message----- From: freeradius-users-bounces+email.me=kevp.com@lists.freeradius.org [mailto:freeradius-users-bounces+email.me=kevp.com@lists.freeradius.org] On Behalf Of Arran Cudbard-Bell Sent: 17 September 2014 04:10 To: FreeRadius users mailing list Subject: Re: dynamic-clients supporting CDIR entries in v3
Any ideas as to how to get FR to dynamically learn the 0.0.0.0/1 without complaining it's a duplicate of 0.0.0.0/0? Or might this be considered a bug...?
It is in fact a bug, yes. The config parser accepts '*' for ip addresses, to allow binding to wildcard addresses. When it gets a wildcard, it sets the IP address to INADDR_ANY usually 0.0.0.0. It also sets the prefix for the ip address to be /32 or /128 (ipv6), which of course defeats the purpose of a wildcard. There was code in the client_add function to fix that up, so when it got an INADDR_ANY value, it'd set the prefix to 0. It should have also been checking that the prefix was /32 (ipv4) or /128 (ipv6) before modifying it. I've pushed a fix. Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
participants (3)
-
Alan DeKok -
Arran Cudbard-Bell -
Kev Pearce