# MikroTik RouterOS DHCP lease push hook for Madagascar Local Authority. # # Edit hostManagerDhcpPushToken before import. If the DHCP server already has a # lease-script, merge this source manually instead of overwriting it. :global hostManagerDhcpPushUrl "https://hosts.madagascar.xdev.ro/api/collect/dhcp-leases"; :global hostManagerDhcpPushToken "CHANGE_ME_DHCP_PUSH_TOKEN"; /ip dhcp-server set [find] lease-script={ :global hostManagerDhcpPushUrl; :global hostManagerDhcpPushToken; :local leaseName $"lease-hostname"; :local leaseState "unbound"; :if ($leaseBound = 1) do={ :set leaseState "bound"; } :local payload ("worker_id=dhcp-router&ip_address=" . $leaseActIP . "&mac_address=" . $leaseActMAC . "&observed_name=" . $leaseName . "&lease_state=" . $leaseState . "&bound=" . $leaseBound); /tool fetch url=$hostManagerDhcpPushUrl \ http-method=post \ http-header-field=("Content-Type:application/x-www-form-urlencoded,X-DHCP-Push-Token:" . $hostManagerDhcpPushToken) \ http-data=$payload \ http-percent-encoding=yes \ check-certificate=no \ keep-result=no; }