chenchunyen wrote:script的做法即將pool從一個範圍限縮到只剩一個ip,所以分配地址時只會套用這唯一的ip。
pool name...(恕刪)
(極重要,在使用script前您一定要將pool範圍先改為只有1個ip)
而dhcp將地址分配給裝置後,script會隨即將pool加1,並到arp尋找目前是否有人使用。
若有人使用則再往上加1,直至沒人使用才停止。
也因pool是由小往上累進,所以裝置地址的排序也是由小往大累進。
當然一直往上加1會到192.168.2.254,
超過時script會再讓pool回到192.168.2.2繼續搜尋未使用的地址。

:local pool [:toip [/ip pool get dhcp range]]
:if ($leaseBound=1) do={
:set pool ($pool+1)
:if ($pool>192.168.2.254) do={:set pool 192.168.2.2}}
:while ([:len [/ip arp find address=$pool complete]]>0) do={
:set pool ($pool+1)
:if ($pool>192.168.2.254) do={:set pool 192.168.2.2}}
/ip pool set dhcp range=$pool