Hi all!
Are there a form to force all clients of my DHCP server to get a new IP address without reboot the client device?
Thank in advance!
Fabrício
Hi all!
Are there a form to force all clients of my DHCP server to get a new IP address without reboot the client device?
Thank in advance!
Fabrício
That would be a DHCP server function as the client will at half point through the lease try to renew the lease, asking for the same IP address again. Usually the server OKs that, you would have to specifically configure the server to deny it. To the best of my knowledge the RouterOS DHCP server does not have that functionality.
at least, during renewal of the lease ROS makes RADIUS request, and you can change IP address ‘on the fly’ - seems like you can do it with local database
Hi fewy and Chupaka,
The renewal of DHCP server of RouterOS makes a new query to radius server but the IP address of the client isn’t renewed.
Sorry I was unhappy with my question. My biggest problem isn’t to renew the IP address of the client. My biggest problem is to recreate the simple queue of the client with new bandwidth values. Sometimes a customer want to change the bandwidth and we need to reboot the client radio and delete the lease of the dhcp server before the client radio turns on and get the IP address.
Fabrício
Simple queues are very limited.
Maybe instead of using rate limits pushed via DHCP you could make leases static after the client is established, and add that address to an address-list and then run simple queues (or even better, PCQ) based on packet-marks applied on merit of dst-address-list and src-address-list.
Hi fewi, thanks!
I prefer to use the simple queue because I’ve a lot of differents queues and some clients have burst.
Thanks
Fabrício
so, simple queue of DHCP Client is not refreshed on lease renewal? then you should write to support, I think =)
Thanks guys,
I’ll send a message to the support requesting this resource.
Thanks
Fabrício
In the meantime, here is a script that might help. I use it when testing some DNS update scripts for dhcp client leases. It forces a client to get a new IP each time they request a new dhcp lease.
First, create pools with separate IP ranges:
/ip pool
add name=LAN-pool1 next-pool=LAN-pool2 ranges=192.168.1.100-192.168.101.110
add name=LAN-pool2 next-pool=LAN-pool3 ranges=192.168.1.111-192.168.101.120
add name=LAN-pool3 next-pool=LAN-pool4 ranges=192.168.1.121-192.168.101.130
add name=LAN-pool4 next-pool=LAN-pool5 ranges=192.168.1.131-192.168.101.140
add name=LAN-pool5 next-pool=LAN-pool1 ranges=192.168.1.141-192.168.101.150
The next-pool is necessary so a client receives an IP, even if a current pool is full.
Here is the actual script:
# poolserver = lease active-server
# poolprefix = prefix for pools (ex. <poolprefix>1, <poolprefix>2, etc...)
:local poolserver "lan_dhcp"
:local poolprefix "LAN-pool"
# Internal processing here.....
# ----------------------------------
:local pools ""
# Get /ip pool list with prefix of $poolprefix
/ip pool {
:local poolname
:foreach p in=[find] do={
:set poolname [:tostr [get $p name]]
:if ([:pick $poolname 0 [:len $poolprefix]] = $poolprefix) do={
:if ([:len $pools] > 0) do={
:set pools ([:tostr $pools] . "," . $poolname) } else={
:set pools ($poolname) } }
}
# /ip pool
}
/ip dhcp-server lease {
:local activemac
:local activeaddress
:local poolused
:local newpool
# Convert dynamic leases to static and set it's address to lease pool
:foreach l in=[find] do={
:if ([get $l dynamic] = true && \
[get $l disabled] = false && \
[get $l active-server] = [:tostr $poolserver]) do={
:set activeaddress [get $l active-address]
:set activemac [get $l active-mac-address]
# Get lease's current pool
:set poolused ""
/ip pool used {
:foreach p in=[find] do={
:if ([get $p address] = [:toip $activeaddress] && [get $p info] = [:tostr $activemac]) do={
:set poolused [get $p pool] } }
}
:if ([:len $poolused] > 0) do={
:put ($activemac . " (" . $activeaddress . ") converting to static lease...")
make-static $l
:put ([:terminal cuu] . [:terminal el] . $activemac . " (" . $activeaddress . ") converting to static lease...[done]")
# Set new static lease's address to $poolused
:put ($activemac . " (" . $activeaddress . ") setting address to pool: " . $poolused . "...")
set $l address=[:tostr $poolused]
:put ([:terminal cuu] . [:terminal el] . $activemac . " (" . $activeaddress . ") setting address to pool: " . $poolused . "...[done]")
}
}
}
# Search /ip dhcp-server lease for bound static leases with address in pool from $pools list
:foreach l in=[find] do={
:set activemac [get $l active-mac-address]
:set activeaddress [:toip [get $l active-address]]
# If lease is static, bound, and has active-address and active-mac-address...
:if ([get $l dynamic] = false && [get $l status] = "bound" && \
[get $l active-server] = [:tostr $poolserver] && [get $l disabled] = false && \
[:len $activemac] > 0 && [:len $activeaddress] > 0) do={
# Get lease's current pool
:set poolused ""
/ip pool used {
:foreach p in=[find] do={
:if ([get $p address] = [:toip $activeaddress] && [get $p info] = [:tostr $activemac]) do={
:set poolused [get $p pool] } }
}
# If we found a matching pool...
:if ([:len $poolused] > 0) do={
# If lease's address is set to $poolused, increment to newpool
:if ([:tostr [get $l address]] = [:tostr $poolused]) do={
:set newpool [:find [:toarray $pools] [:tostr $poolused]]
:if ([:len $newpool] > 0) do={
:if ([:tonum $newpool] = ([:len [:toarray $pools]] - 1)) do={
:set newpool [:pick [:toarray $pools] 0] } else={
:set newpool [:pick [:toarray $pools] ([:tonum $newpool] + 1)] }
:put ($activemac . " - obtained lease from current pool: " . $poolused)
:put ($activemac . " - pool change: " . $poolused . " -> " . $newpool)
set $l address=[:tostr $newpool]
}
}
# end if [:len $poolused] > 0
}
# end if static, bound, and active lease addresses
}
# foreach l
}
# /ip dhcp-server lease
}
Each time a bound lease gets obtained, the pool is changed to the next available one. The next request from the same client will now obtain a lease from a different pool (this new IP).
I had the same problem, with both IP and rate-limit changes with my dhcp leases.
I fixed by sending Session-Timeout attribute to mikrotik from radius server for each user. Value of timeout is in seconds.
Once the timeout was reached, both IP and rate-limit rule was changed.
All this does is override the default dhcp-lease time set under dhcp-server config, but the attributes are re-read from radius server while using the local dhcp-server setting does not appear to.