hi
I need to store ip pool information like Owner-Address
how I can do this?
RouterOS v6 includes the dhcp-server lease-script command. Very little/no documentation exists, so try the following in a controlled environment first. Due to lack of documentation or lack of features, it may not be able to provide details on the specific lease that was just obtained, so the below outputs all IPs on every change. Because of this simplicty, in versions prior to 6, you should just be able to run this as a scheduler event every so often, per your requirements.
Setup syslogging (update this invalid IP to your syslog server):
/system logging
action add name=syslog target=remote remote=192.168.999.999
add action=syslog topics=script,info
In the dhcp-server script on v6 or a scheduler event, use the :log command to log the appropriate data like so:
:global IpPoolUsedAddresses ""
:foreach lease in=[/ip pool used find owner=DHCP] do={
:if ([:len $IpPoolUsedAddresses]=0) do={
:global IpPoolUsedAddresses [/ip pool used get $lease value-name=address]
} else={
:global IpPoolUsedAddresses ($IpPoolUsedAddresses . ", " . [/ip pool used get $lease value-name=address])
}
}
:log info message= $IpPoolUsedAddresses