Good day. I would like to cache queries in my dhcp configuration of freeradius and especially to cache sql queries. I have the next dhcp configuration section: dhcp DHCP-Discover { update reply { DHCP-Message-Type = DHCP-Offer } update reply { &DHCP-Domain-Name-Server[1] = 192.168.1.254 &DHCP-Domain-Name-Server[2] = 192.168.0.254 &DHCP-Subnet-Mask = 255.255.255.0 &DHCP-Renewal-Time = 86300 &DHCP-Rebinding-Time = 86330 &DHCP-IP-Address-Lease-Time = 86400 &DHCP-DHCP-Server-Identifier = 192.168.24.14 &DHCP-Relay-Circuit-Id := "%{request:DHCP-Relay-Circuit-Id}" &DHCP-Relay-Remote-Id := "%{request:DHCP-Relay-Remote-Id}" } mac2ip if ("%{request:DHCP-Relay-Circuit-Id}" =~ /0x....(....)..../i) { update control { &Pool-Name := "vlan-%{expr:0x%{1}}" } } dhcp_sqlippool if ("%{reply:DHCP-Your-IP-Address}" =~ /([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}).[0-9]{1,3}/i) { update reply { &DHCP-Router-Address = "%{1}.1" } } if ("%{reply:DHCP-Your-IP-Address}" =~ /(10.[0-9]{1,3}.[0-9]{1,3}).[0-9]{1,3}/i) { update reply { &DHCP-Renewal-Time := 580 &DHCP-Rebinding-Time := 590 &DHCP-IP-Address-Lease-Time := 600 } } linelog ok } dhcp DHCP-Request section has the same configuration. Here is the static database(pool) mac2ip and dynamyc sql database(pool) sqlippool. ma2ip is checked first if we have match in mac2ip then we use it, else we use dynamic ip-address from sqlpool. It works. mac2ip works fast but sqlippool uses mysql and get some CPU load -- there are some crazy devices in the network which ask dhcp all the time and fast (misconfigured or brocken routers?). Mysql eats the CPU :-). How can I use rlm_cache module in this configuration to speed up and reduce CPU load ? I cannot understand how to use rlm_cache. Please explain me with examples on my configuration. -- Anton, инженер отдела управления сетью связи, ООО "ИКА" (Томика) 634050 г. Томск пр. Ленина 55, оф. 101 Тел: 701-855
On Jul 21, 2016, at 9:29 AM, Anton <zav@tomica.ru> wrote:
Here is the static database(pool) mac2ip and dynamyc sql database(pool) sqlippool. ma2ip is checked first if we have match in mac2ip then we use it, else we use dynamic ip-address from sqlpool. It works.
That's good.
mac2ip works fast but sqlippool uses mysql and get some CPU load -- there are some crazy devices in the network which ask dhcp all the time and fast (misconfigured or brocken routers?). Mysql eats the CPU :-).
This is a common problem.
How can I use rlm_cache module in this configuration to speed up and reduce CPU load ?
Cache DHCP replies. Then when a request comes in, check the cache. If the request is received within a short time of the previous request, just return the same cached data, and avoid MySQL.
I cannot understand how to use rlm_cache. Please explain me with examples on my configuration.
Well, we're not going to do all of your work for you. Perhaps you can ask specific questions about the cache module. The cache module is documented in raddb/mods-available/cache. What part is unclear? What did you try to configure? Alan DeKok.
Ok. I cannot understand how to cache something. For example mac2ip or sqlpool set some variables ater modules call, how to place them in cache with timeout ? Timeot is configured at '/etc/raddb/mods-available/cache' in 'ttl' В Thu, 21 Jul 2016 12:11:01 +0200 Alan DeKok <aland@deployingradius.com> пишет:
On Jul 21, 2016, at 9:29 AM, Anton <zav@tomica.ru> wrote:
Here is the static database(pool) mac2ip and dynamyc sql database(pool) sqlippool. ma2ip is checked first if we have match in mac2ip then we use it, else we use dynamic ip-address from sqlpool. It works.
That's good.
mac2ip works fast but sqlippool uses mysql and get some CPU load -- there are some crazy devices in the network which ask dhcp all the time and fast (misconfigured or brocken routers?). Mysql eats the CPU :-).
This is a common problem.
How can I use rlm_cache module in this configuration to speed up and reduce CPU load ?
Cache DHCP replies. Then when a request comes in, check the cache. If the request is received within a short time of the previous request, just return the same cached data, and avoid MySQL.
I cannot understand how to use rlm_cache. Please explain me with examples on my configuration.
Well, we're not going to do all of your work for you. Perhaps you can ask specific questions about the cache module.
The cache module is documented in raddb/mods-available/cache.
What part is unclear? What did you try to configure?
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
On Jul 21, 2016, at 5:40 PM, Anton <zav@tomica.ru> wrote:
Ok. I cannot understand how to cache something.
The cache module contains examples. You can configure it to cache specific attributes.
For example mac2ip or sqlpool set some variables ater modules call, how to place them in cache with timeout ?
Read the comments in mods-available/cache. Look for the comments around "update".
Timeot is configured at '/etc/raddb/mods-available/cache' in 'ttl'
I'm aware of that, You need to set the various cache attributes before calling the cache module. See the comments at the end of the cache module for documentation. When checking the cache: update { &control:Cache-Status-Only = yes } cache if (ok) { # cache entry was found } When updating the cache: cache It's that simple. Alan DeKok.
participants (2)
-
Alan DeKok -
Anton