Compare commits

..

70 commits

Author SHA1 Message Date
Christian Hesse
2612045644 ipv6-update: handle global variable $IPv6DHCPClientEnvVars...
... set by ipv6-dhcp-client-script.
2026-04-13 17:39:06 +02:00
Christian Hesse
1029c39973 ipv6-update: add a provide for ipv6-dhcp-client-script 2026-04-13 17:39:06 +02:00
Christian Hesse
64a024833e WIP: introduce ipv6-dhcp-client-script 2026-04-13 17:39:06 +02:00
Christian Hesse
78bd74c544 dhcp-to-dns: support to ignore networks
Closes: https://github.com/eworm-de/routeros-scripts/issues/119
2026-04-10 20:27:02 +02:00
Christian Hesse
c033f90d0c bump required RouterOS version for all scripts 2026-04-10 20:27:02 +02:00
Christian Hesse
32d6eca81c global-functions: $NetMask6: use shift operator...
... and drop the workaround. This requires RouterOS 7.22beta3.
2026-04-10 20:27:02 +02:00
Christian Hesse
2d3f4f9f25 Merge branch 'break-in-loop' into next 2026-04-10 20:27:02 +02:00
Christian Hesse
0b824e8de7 Merge branch 'continue-in-loop' into next 2026-04-10 20:27:02 +02:00
Christian Hesse
89e1ad5a96 telegram-chat: fix indention 2026-04-10 20:27:02 +02:00
Christian Hesse
35776a7f37 Merge branch 'early-exit-with-exit' into next 2026-04-10 20:27:02 +02:00
Christian Hesse
d942721f6d dhcp-to-dns: fix indention 2026-04-10 20:27:02 +02:00
Christian Hesse
7b6e43f2ce telegram-chat: use :break in loop 2026-04-10 20:27:02 +02:00
Christian Hesse
d4eb95873b Merge branch 'compare-ids' into next 2026-04-10 20:27:02 +02:00
Christian Hesse
a1abfc5436 global-functions: deprecate $ExitError 2026-04-10 20:27:02 +02:00
Christian Hesse
83d04bfa90 dhcp-to-dns: use another :continue in loop 2026-04-10 20:27:02 +02:00
Christian Hesse
b23c74f2d9 check-certificates: use :break in loop 2026-04-10 20:27:02 +02:00
Christian Hesse
5ec53fe5c5 Merge branch 'drop-builtin-trust-anchors' into next 2026-04-10 20:27:02 +02:00
Christian Hesse
ded5fdd6b4 global-functions: deprecate $HexToNum 2026-04-10 20:27:02 +02:00
Christian Hesse
bc2453c867 update-tunnelbroker: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
79d9b9ea59 dhcp-to-dns: use :continue in loop 2026-04-10 20:27:02 +02:00
Christian Hesse
8a86e88731 mod/notification-email: use errors from command...
... instead of reading status from properties. This was introduced in
RouterOS 7.21beta2 (and we bump to 7.21 instead).
2026-04-10 20:27:02 +02:00
Christian Hesse
7a1fb0281d INITIAL-COMMANDS: drop the old builtin-trust-anchors 2026-04-10 20:27:02 +02:00
Christian Hesse
a2225bf817 log-forward: fix indention 2026-04-10 20:27:02 +02:00
Christian Hesse
4abe208793 update-gre-address: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
d815b67847 telegram-chat: use :continue in loop 2026-04-10 20:27:02 +02:00
Christian Hesse
ab23d1e352 mod/ssh-keys-import: drop old property
The property name changed in RouterOS 7.21beta2, so bump required
version to 7.21.
2026-04-10 20:27:02 +02:00
Christian Hesse
adf26e7600 global-functions: $CertificateAvailable: drop the old builtin-trust-anchors 2026-04-10 20:27:02 +02:00
Christian Hesse
a13f2fba4a log-forward: use comparison for ids
This was introduced with RouterOS 7.22beta1.

Initializing $LogForwardLast with boolean value looks odd, but this is
reuqired to match the very first message.
2026-04-10 20:27:02 +02:00
Christian Hesse
cee91cf3dc telegram-chat: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
99c1d11b8b netwatch-dns: fix indention 2026-04-10 20:27:02 +02:00
Christian Hesse
79288a64d6 README: drop the old builtin-trust-anchors 2026-04-10 20:27:02 +02:00
Christian Hesse
7c4f8414fa sms-forward: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
e89f22e3b6 netwatch-dns: use :continue in loop 2026-04-10 20:27:02 +02:00
Christian Hesse
197eb7a7d4 sms-action: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
e0a92529dc netwatch-dns: fix indention 2026-04-10 20:27:02 +02:00
Christian Hesse
7ea381e7d2 ppp-on-up: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
b372f10bdc netwatch-dns: use :continue in loop 2026-04-10 20:27:02 +02:00
Christian Hesse
4b6de32beb packages-update: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
ce1333ab90 global-functions: $ScriptInstallUpdate: fix indention 2026-04-10 20:27:02 +02:00
Christian Hesse
56ab927c68 ospf-to-leds: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
f752feb79c global-functions: $ScriptInstallUpdate: use :continue in loop 2026-04-10 20:27:02 +02:00
Christian Hesse
0e29bd1aa1 netwatch-notify: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
82e6e30b12 fw-addr-lists: fix indention 2026-04-10 20:27:02 +02:00
Christian Hesse
cfa63a1702 netwatch-dns: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
4b704110f8 fw-addr-lists: use :continue in loop 2026-04-10 20:27:02 +02:00
Christian Hesse
dc81ad54c9 log-forward: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
edba8593e2 lease-script: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
2197170de0 ipv6-update: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
5c7b4066a4 ipsec-to-dns: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
3ff2bf3c13 hotspot-to-wpa-cleanup: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
e3a33aff99 hotspot-to-wpa: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
ae9f072fff gps-track: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
787d129b74 fw-addr-lists: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
f33f2a3b74 firmware-upgrade-reboot: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
ef54be4f7d dhcp-to-dns: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
a8086b31d1 dhcp-lease-comment: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
3c7748cf6f daily-psk: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
fffc3c9b09 collect-wireless-mac: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
ddc0d0a6a3 check-routeros-update: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
76884cd4d8 check-perpetual-license: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
8bd9c65c2d check-lte-firmware-upgrade: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
c583373c84 check-health: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
e919ccd9cb check-certificates: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
99dba4ff78 certificate-renew-issued: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
6f0d229b5e capsman-rolling-upgrade: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
46b8f722c8 capsman-download-packages: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
f100c247f3 backup-upload: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
194e50cd63 backup-partition: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
7329869aca backup-email: early exit with :exit 2026-04-10 20:27:02 +02:00
Christian Hesse
55c85abe29 backup-cloud: early exit with :exit 2026-04-10 20:27:02 +02:00
30 changed files with 165 additions and 239 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Before After
Before After

View file

@ -254,8 +254,8 @@ Some events can run a script. If you want your DHCP hostnames to be available
in DNS use `dhcp-to-dns` with the events from dhcp server. For a regular
cleanup add a scheduler entry.
$ScriptInstallUpdate dhcp-to-dns,dhcpv4-server-lease;
/ip/dhcp-server/set lease-script="dhcpv4-server-lease" [ find ];
$ScriptInstallUpdate dhcp-to-dns,lease-script;
/ip/dhcp-server/set lease-script=lease-script [ find ];
/system/scheduler/add name="dhcp-to-dns" interval=5m start-time=startup on-event="/system/script/run dhcp-to-dns;";
![screenshot: setup lease script](README.d/12-setup-lease-script.avif)
@ -282,8 +282,6 @@ Available scripts
* [Use wireless network with daily psk](doc/daily-psk.md) (`daily-psk`)
* [Comment DHCP leases with info from access list](doc/dhcp-lease-comment.md) (`dhcp-lease-comment`)
* [Create DNS records for DHCP leases](doc/dhcp-to-dns.md) (`dhcp-to-dns`)
* [Run other scripts on IPv4 DHCP server lease](doc/dhcpv4-server-lease.md) (`dhcpv4-server-lease`)
* [Run other scripts on IPv6 DHCP client lease](doc/dhcpv6-client-lease.md) (`dhcpv6-client-lease`)
* [Automatically upgrade firmware and reboot](doc/firmware-upgrade-reboot.md) (`firmware-upgrade-reboot`)
* [Download, import and update firewall address-lists](doc/fw-addr-lists.md) (`fw-addr-lists`)
* [Wait for global functions und modules](doc/global-wait.md) (`global-wait`)
@ -292,6 +290,7 @@ Available scripts
* [Create DNS records for IPSec peers](doc/ipsec-to-dns.md) (`ipsec-to-dns`)
* [Update configuration on IPv6 prefix change](doc/ipv6-update.md) (`ipv6-update`)
* [Manage IP addresses with bridge status](doc/ip-addr-bridge.md) (`ip-addr-bridge`)
* [Run other scripts on DHCP lease](doc/lease-script.md) (`lease-script`)
* [Manage LEDs dark mode](doc/leds-mode.md) (`leds-day-mode`, `leds-night-mode` & `leds-toggle-mode`)
* [Forward log messages via notification](doc/log-forward.md) (`log-forward`)
* [Mode button with multiple presses](doc/mode-button.md) (`mode-button`)

View file

@ -3,7 +3,7 @@
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# provides: dhcpv4-server-lease, order=40
# provides: lease-script, order=40
# requires RouterOS, version=7.22
#
# collect wireless mac adresses in access list

View file

@ -3,7 +3,7 @@
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# provides: dhcpv4-server-lease, order=40
# provides: lease-script, order=40
# requires RouterOS, version=7.22
#
# collect wireless mac adresses in access list

View file

@ -3,7 +3,7 @@
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# provides: dhcpv4-server-lease, order=40
# provides: lease-script, order=40
# requires RouterOS, version=7.22
#
# collect wireless mac adresses in access list

View file

@ -3,7 +3,7 @@
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# provides: dhcpv4-server-lease, order=40
# provides: lease-script, order=40
# requires RouterOS, version=7.22
#
# collect wireless mac adresses in access list

View file

@ -91,10 +91,6 @@ Notes
/save dhcp-to-dns Create DNS records for DHCP leases with [dhcp-to-dns](https://rsc.eworm.de/doc/dhcp-to-dns.md).
#### dhcpv4-server-lease
/save dhcpv4-server-lease Run other scripts on IPv4 DHCP server lease with [dhcpv4-server-lease](https://rsc.eworm.de/doc/dhcpv4-server-lease.md).
#### firmware-upgrade-reboot
/save firmware-upgrade-reboot Automatically upgrade firmware and reboot with [firmware-upgrade-reboot](https://rsc.eworm.de/doc/firmware-upgrade-reboot.md).
@ -127,6 +123,10 @@ Notes
/save ip-addr-bridge Manage IP addresses with [ip-addr-bridge](https://rsc.eworm.de/doc/ip-addr-bridge.md).
#### lease-script
/save lease-script Run other scripts on DHCP lease with [lease-script](https://rsc.eworm.de/doc/lease-script.md).
#### leds-mode
/save leds-mode Manage LEDs dark mode with [leds-mode](https://rsc.eworm.de/doc/leds-mode.md).

View file

@ -3,7 +3,7 @@
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# provides: dhcpv4-server-lease, order=60
# provides: lease-script, order=60
# requires RouterOS, version=7.22
#
# update dhcp-server lease comment with infos from access-list

View file

@ -3,7 +3,7 @@
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# provides: dhcpv4-server-lease, order=60
# provides: lease-script, order=60
# requires RouterOS, version=7.22
#
# update dhcp-server lease comment with infos from access-list

View file

@ -3,7 +3,7 @@
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# provides: dhcpv4-server-lease, order=60
# provides: lease-script, order=60
# requires RouterOS, version=7.22
#
# update dhcp-server lease comment with infos from access-list

View file

@ -3,7 +3,7 @@
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# provides: dhcpv4-server-lease, order=60
# provides: lease-script, order=60
# requires RouterOS, version=7.22
#
# update dhcp-server lease comment with infos from access-list

View file

@ -3,7 +3,7 @@
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# provides: dhcpv4-server-lease, order=20
# provides: lease-script, order=20
# requires RouterOS, version=7.22
#
# check DHCP leases and add/remove/update DNS entries

View file

@ -1,61 +0,0 @@
#!rsc by RouterOS
# RouterOS script: dhcpv4-server-lease
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# requires RouterOS, version=7.22
#
# run scripts on IPv4 DHCP server lease
# https://rsc.eworm.de/doc/dhcpv4-server-lease.md
:onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50;
:local ScriptName [ :jobname ];
:global Grep;
:global IfThenElse;
:global LogPrint;
:global ParseKeyValueStore;
:global ScriptLock;
:if ([ :typeof $leaseActIP ] = "nothing" || \
[ :typeof $leaseActMAC ] = "nothing" || \
[ :typeof $leaseServerName ] = "nothing" || \
[ :typeof $leaseBound ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from ip dhcp-server.");
:exit;
}
$LogPrint debug $ScriptName ("DHCP Server " . $leaseServerName . " " . [ $IfThenElse ($leaseBound = 0) \
"de" "" ] . "assigned lease " . $leaseActIP . " to " . $leaseActMAC);
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
:exit;
}
:if ([ :len [ /system/script/job/find where script=$ScriptName ] ] > 1) do={
$LogPrint debug $ScriptName ("More invocations are waiting, exiting early.");
:exit;
}
:local RunOrder ({});
:foreach Script in=[ /system/script/find where source~("\n# provides: dhcpv4-server-lease\\b") ] do={
:local ScriptVal [ /system/script/get $Script ];
:local Store [ $ParseKeyValueStore [ $Grep ($ScriptVal->"source") ("\23 provides: dhcpv4-server-lease, ") ] ];
:set ($RunOrder->($Store->"order" . "-" . $ScriptVal->"name")) ($ScriptVal->"name");
}
:foreach Order,Script in=$RunOrder do={
:onerror Err {
$LogPrint debug $ScriptName ("Running script with order " . $Order . ": " . $Script);
/system/script/run $Script;
} do={
$LogPrint warning $ScriptName ("Running script '" . $Script . "' failed: " . $Err);
}
}
} do={
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
}

View file

@ -64,14 +64,14 @@ Usage and invocation
Run this script from a dhcp server as lease-script to collect the MAC
address when a new address is leased. You may want to use
[dhcpv4-server-lease](dhcpv4-server-lease.md).
[lease-script](lease-script.md).
See also
--------
* [Comment DHCP leases with info from access list](dhcp-lease-comment.md)
* [Create DNS records for DHCP leases](dhcp-to-dns.md)
* [Run other scripts on IPv4 DHCP server lease](dhcpv4-server-lease.md)
* [Run other scripts on DHCP lease](lease-script.md)
---
[⬅️ Go back to main README](../README.md)

View file

@ -50,14 +50,14 @@ Usage and invocation
Run this script from a dhcp server as lease-script to update the comment
just after a new address is leased. You may want to use
[dhcpv4-server-lease](dhcpv4-server-lease.md).
[lease-script](lease-script.md).
See also
--------
* [Collect MAC addresses in wireless access list](collect-wireless-mac.md)
* [Create DNS records for DHCP leases](dhcp-to-dns.md)
* [Run other scripts on IPv4 DHCP server lease](dhcpv4-server-lease.md)
* [Run other scripts on DHCP lease](lease-script.md)
---
[⬅️ Go back to main README](../README.md)

View file

@ -28,7 +28,7 @@ Just install the script:
$ScriptInstallUpdate dhcp-to-dns;
Then run it from dhcp server as lease script. You may want to use
[dhcpv4-server-lease](dhcpv4-server-lease.md).
[lease-script](lease-script.md).
A scheduler cares about cleanup:
@ -106,8 +106,8 @@ See also
* [Collect MAC addresses in wireless access list](collect-wireless-mac.md)
* [Comment DHCP leases with info from access list](dhcp-lease-comment.md)
* [Run other scripts on IPv4 DHCP server lease](dhcpv4-server-lease.md)
* [Create DNS records for IPSec peers](ipsec-to-dns.md)
* [Run other scripts on DHCP lease](lease-script.md)
---
[⬅️ Go back to main README](../README.md)

View file

@ -1,54 +0,0 @@
Run other scripts on IPv4 DHCP server lease
===========================================
[![GitHub stars](https://img.shields.io/github/stars/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/routeros-scripts/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/routeros-scripts/network)
[![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/routeros-scripts/watchers)
[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.22-yellow?style=flat)](https://mikrotik.com/download/changelogs/)
[![Telegram group @routeros_scripts](https://img.shields.io/badge/Telegram-%40routeros__scripts-%2326A5E4?logo=telegram&style=flat)](https://t.me/routeros_scripts)
[![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)
[⬅️ Go back to main README](../README.md)
> **Info**: This script can not be used on its own but requires the base
> installation. See [main README](../README.md) for details.
Description
-----------
This script is supposed to run from IPv4 DHCP server as lease script. On a
DHCP lease it runs each script containing the following line, where `##` is
a decimal number for ordering:
# provides: dhcpv4-server-lease, order=##
Currently it runs if available, in order:
* [dhcp-to-dns](dhcp-to-dns.md)
* [collect-wireless-mac](collect-wireless-mac.md)
* [dhcp-lease-comment](dhcp-lease-comment.md)
* `hotspot-to-wpa-cleanup`, which is an optional cleanup script
of [hotspot-to-wpa](hotspot-to-wpa.md)
Requirements and installation
-----------------------------
Just install the script:
$ScriptInstallUpdate dhcpv4-server-lease;
... and add it as `lease-script` to your dhcp server:
/ip/dhcp-server/set lease-script="dhcpv4-server-lease" [ find ];
See also
--------
* [Collect MAC addresses in wireless access list](collect-wireless-mac.md)
* [Comment DHCP leases with info from access list](dhcp-lease-comment.md)
* [Create DNS records for DHCP leases](dhcp-to-dns.md)
* [Use WPA network with hotspot credentials](hotspot-to-wpa.md)
---
[⬅️ Go back to main README](../README.md)
[⬆️ Go back to top](#top)

View file

@ -1,64 +0,0 @@
Run other scripts on IPv6 DHCP client lease
===========================================
[![GitHub stars](https://img.shields.io/github/stars/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/routeros-scripts/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/routeros-scripts/network)
[![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/routeros-scripts/watchers)
[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.22-yellow?style=flat)](https://mikrotik.com/download/changelogs/)
[![Telegram group @routeros_scripts](https://img.shields.io/badge/Telegram-%40routeros__scripts-%2326A5E4?logo=telegram&style=flat)](https://t.me/routeros_scripts)
[![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)
[⬅️ Go back to main README](../README.md)
> **Info**: This script can not be used on its own but requires the base
> installation. See [main README](../README.md) for details.
Description
-----------
This script is supposed to run from IPv6 DHCP client as lease script. On a
DHCP leasse it runs each script containing the following line, where `##` is
a decimal number for ordering:
# provides: dhcpv6-client-lease, order=##
The lease script is started with some variables injected, but these are not
available in child scripts. However this script makes these variables
available with a global variable. This code is required in child script:
:global EitherOr;
:global DHCPv6ClientLeaseVars;
:local NaAddress [ $EitherOr $"na-address" ($DHCPv6ClientLeaseVars->"na-address") ];
:local NaValid [ $EitherOr $"na-valid" ($DHCPv6ClientLeaseVars->"na-valid") ];
:local PdPrefix [ $EitherOr $"pd-prefix" ($DHCPv6ClientLeaseVars->"pd-prefix") ];
:local PdValid [ $EitherOr $"pd-valid" ($DHCPv6ClientLeaseVars->"pd-valid") ];
The values are available under different name then, use `$PdPrefix` instead
of `$"pd-prefix"`, and so on. The resulting script supports both, being a
lease script itself or being run as child.
Currently it runs if available, in order:
* [ipv6-update](ipv6-update.md)
Requirements and installation
-----------------------------
Just install the script:
$ScriptInstallUpdate dhcpv6-client-lease;
... and add it as `lease-script` to your dhcp client:
/ipv6/dhcp-client/set lease-script="dhcpv6-client-lease" [ find ];
See also
--------
* [Update configuration on IPv6 prefix change](ipv6-update.md)
---
[⬅️ Go back to main README](../README.md)
[⬆️ Go back to top](#top)

View file

@ -49,24 +49,24 @@ and add a scheduler.
For `wifi`:
$ScriptInstallUpdate hotspot-to-wpa-cleanup.wifi,dhcpv4-server-lease;
/system/scheduler/add interval=1d name="hotspot-to-wpa-cleanup" on-event="/system/script/run hotspot-to-wpa-cleanup.wifi;" start-time=startup;
$ScriptInstallUpdate hotspot-to-wpa-cleanup.wifi,lease-script;
/system/scheduler/add interval=1d name=hotspot-to-wpa-cleanup on-event="/system/script/run hotspot-to-wpa-cleanup.wifi;" start-time=startup;
For legacy CAPsMAN:
$ScriptInstallUpdate hotspot-to-wpa-cleanup.capsman,dhcpv4-server-lease;
/system/scheduler/add interval=1d name="hotspot-to-wpa-cleanup" on-event="/system/script/run hotspot-to-wpa-cleanup.capsman;" start-time=startup;
$ScriptInstallUpdate hotspot-to-wpa-cleanup.capsman,lease-script;
/system/scheduler/add interval=1d name=hotspot-to-wpa-cleanup on-event="/system/script/run hotspot-to-wpa-cleanup.capsman;" start-time=startup;
And add the lease script and matcher comment to your wpa interfaces' dhcp
server. You can add more information to the comment, separated by comma. In
this example the server is called `hotspot-to-wpa`.
/ip/dhcp-server/set lease-script="dhcpv4-server-lease" comment="hotspot-to-wpa=wpa" hotspot-to-wpa;
/ip/dhcp-server/set lease-script=lease-script comment="hotspot-to-wpa=wpa" hotspot-to-wpa;
You can specify the timeout after which a device is removed from leases and
access-list. The default is four weeks.
/ip/dhcp-server/set lease-script="dhcpv4-server-lease" comment="hotspot-to-wpa=wpa, timeout=2w" hotspot-to-wpa;
/ip/dhcp-server/set lease-script=lease-script comment="hotspot-to-wpa=wpa, timeout=2w" hotspot-to-wpa;
Configuration
-------------
@ -117,7 +117,7 @@ passphrase from hotspot credentials.
See also
--------
* [Run other scripts on IPv4 DHCP server lease](dhcpv4-server-lease.md)
* [Run other scripts on DHCP lease](lease-script.md)
---
[⬅️ Go back to main README](../README.md)

View file

@ -77,7 +77,6 @@ start with "`ipv6-pool-`" and actual pool name, followed by a comma,
See also
--------
* [Run other scripts on IPv6 DHCP client lease](dhcpv6-client-lease.md)
* [Run scripts on ppp connection](ppp-on-up.md)
---

View file

@ -1 +1,54 @@
This script has been renamed. Please see [dhcpv4-server-lease](dhcpv4-server-lease.md).
Run other scripts on DHCP lease
===============================
[![GitHub stars](https://img.shields.io/github/stars/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/routeros-scripts/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/routeros-scripts/network)
[![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/routeros-scripts/watchers)
[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.22-yellow?style=flat)](https://mikrotik.com/download/changelogs/)
[![Telegram group @routeros_scripts](https://img.shields.io/badge/Telegram-%40routeros__scripts-%2326A5E4?logo=telegram&style=flat)](https://t.me/routeros_scripts)
[![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)
[⬅️ Go back to main README](../README.md)
> **Info**: This script can not be used on its own but requires the base
> installation. See [main README](../README.md) for details.
Description
-----------
This script is supposed to run from dhcp server as lease script. On a dhcp
lease it runs each script containing the following line, where `##` is a
decimal number for ordering:
# provides: lease-script, order=##
Currently it runs if available, in order:
* [dhcp-to-dns](dhcp-to-dns.md)
* [collect-wireless-mac](collect-wireless-mac.md)
* [dhcp-lease-comment](dhcp-lease-comment.md)
* `hotspot-to-wpa-cleanup`, which is an optional cleanup script
of [hotspot-to-wpa](hotspot-to-wpa.md)
Requirements and installation
-----------------------------
Just install the script:
$ScriptInstallUpdate lease-script;
... and add it as `lease-script` to your dhcp server:
/ip/dhcp-server/set lease-script=lease-script [ find ];
See also
--------
* [Collect MAC addresses in wireless access list](collect-wireless-mac.md)
* [Comment DHCP leases with info from access list](dhcp-lease-comment.md)
* [Create DNS records for DHCP leases](dhcp-to-dns.md)
* [Use WPA network with hotspot credentials](hotspot-to-wpa.md)
---
[⬅️ Go back to main README](../README.md)
[⬆️ Go back to top](#top)

View file

@ -36,7 +36,6 @@ Just install the script:
See also
--------
* [Run other scripts on IPv6 DHCP client lease](dhcpv6-client-lease.md)
* [Update configuration on IPv6 prefix change](ipv6-update.md)
* [Update tunnelbroker configuration](update-tunnelbroker.md)

View file

@ -15,7 +15,7 @@
# Git commit id & info, expected configuration version
:global CommitId "unknown";
:global CommitInfo "unknown";
:global ExpectedConfigVersion 141;
:global ExpectedConfigVersion 139;
# global variables not to be changed by user
:global GlobalFunctionsReady false;

View file

@ -3,7 +3,7 @@
# Copyright (c) 2021-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# provides: dhcpv4-server-lease, order=80
# provides: lease-script, order=80
# requires RouterOS, version=7.22
# requires device-mode, hotspot
#

View file

@ -3,7 +3,7 @@
# Copyright (c) 2021-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# provides: dhcpv4-server-lease, order=80
# provides: lease-script, order=80
# requires RouterOS, version=7.22
# requires device-mode, hotspot
#

View file

@ -3,7 +3,7 @@
# Copyright (c) 2021-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# provides: dhcpv4-server-lease, order=80
# provides: lease-script, order=80
# requires RouterOS, version=7.22
# requires device-mode, hotspot
#

View file

@ -1,12 +1,12 @@
#!rsc by RouterOS
# RouterOS script: dhcpv6-client-lease
# RouterOS script: ipv6-dhcp-client-script
# Copyright (c) 2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# requires RouterOS, version=7.22
#
# run scripts on IPv6 DHCP client lease
# https://rsc.eworm.de/doc/dhcpv6-client-lease.md
# TODO
# https://rsc.eworm.de/doc/ipv6-dhcp-client-script.md
:onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady;
@ -19,7 +19,7 @@
:global ParseKeyValueStore;
:global ScriptLock;
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
:if ([ $ScriptLock $ScriptName ] = false) do={
:exit;
}
@ -29,16 +29,16 @@
:exit;
}
:global DHCPv6ClientLeaseVars {
:global IPv6DHCPClientEnvVars {
"na-address"=$"na-address";
"na-valid"=$"na-valid";
"pd-prefix"=$"pd-prefix";
"pd-valid"=$"pd-valid" };
:local RunOrder ({});
:foreach Script in=[ /system/script/find where source~("\n# provides: dhcpv6-client-lease\\b") ] do={
:foreach Script in=[ /system/script/find where source~("\n# provides: ipv6-dhcp-client-script\\b") ] do={
:local ScriptVal [ /system/script/get $Script ];
:local Store [ $ParseKeyValueStore [ $Grep ($ScriptVal->"source") ("\23 provides: dhcpv6-client-lease, ") ] ];
:local Store [ $ParseKeyValueStore [ $Grep ($ScriptVal->"source") ("\23 provides: ipv6-dhcp-client-script, ") ] ];
:set ($RunOrder->($Store->"order" . "-" . $ScriptVal->"name")) ($ScriptVal->"name");
}
@ -52,8 +52,8 @@
}
}
:set DHCPv6ClientLeaseVars;
:set IPv6DHCPClientEnvVars;
} do={
:global DHCPv6ClientLeaseVars; :set DHCPv6ClientLeaseVars;
:global IPv6DHCPClientEnvVars; :set IPv6DHCPClientEnvVars;
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
}

View file

@ -4,7 +4,7 @@
# https://rsc.eworm.de/COPYING.md
#
# requires RouterOS, version=7.22
# provides: dhcpv6-client-lease, order=40
# provides: ipv6-dhcp-client-script, order=40
#
# update firewall and dns settings on IPv6 prefix change
# https://rsc.eworm.de/doc/ipv6-update.md
@ -20,12 +20,12 @@
:global ParseKeyValueStore;
:global ScriptLock;
:global DHCPv6ClientLeaseVars;
:global IPv6DHCPClientEnvVars;
:local NaAddress [ $EitherOr $"na-address" ($DHCPv6ClientLeaseVars->"na-address") ];
:local NaValid [ $EitherOr $"na-valid" ($DHCPv6ClientLeaseVars->"na-valid") ];
:local PdPrefix [ $EitherOr $"pd-prefix" ($DHCPv6ClientLeaseVars->"pd-prefix") ];
:local PdValid [ $EitherOr $"pd-valid" ($DHCPv6ClientLeaseVars->"pd-valid") ];
:local NaAddress [ $EitherOr $"na-address" ($IPv6DHCPClientEnvVars->"na-address") ];
:local NaValid [ $EitherOr $"na-valid" ($IPv6DHCPClientEnvVars->"na-valid") ];
:local PdPrefix [ $EitherOr $"pd-prefix" ($IPv6DHCPClientEnvVars->"pd-prefix") ];
:local PdValid [ $EitherOr $"pd-valid" ($IPv6DHCPClientEnvVars->"pd-valid") ];
:if ([ $ScriptLock $ScriptName ] = false) do={
:exit;

View file

@ -1,3 +1,61 @@
#!rsc by RouterOS
# RouterOS script: lease-script
# Copyright (c) 2013-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# dummy for migration
# requires RouterOS, version=7.22
#
# run scripts on DHCP lease
# https://rsc.eworm.de/doc/lease-script.md
:onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50;
:local ScriptName [ :jobname ];
:global Grep;
:global IfThenElse;
:global LogPrint;
:global ParseKeyValueStore;
:global ScriptLock;
:if ([ :typeof $leaseActIP ] = "nothing" || \
[ :typeof $leaseActMAC ] = "nothing" || \
[ :typeof $leaseServerName ] = "nothing" || \
[ :typeof $leaseBound ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from ip dhcp-server.");
:exit;
}
$LogPrint debug $ScriptName ("DHCP Server " . $leaseServerName . " " . [ $IfThenElse ($leaseBound = 0) \
"de" "" ] . "assigned lease " . $leaseActIP . " to " . $leaseActMAC);
:if ([ $ScriptLock $ScriptName 10 ] = false) do={
:exit;
}
:if ([ :len [ /system/script/job/find where script=$ScriptName ] ] > 1) do={
$LogPrint debug $ScriptName ("More invocations are waiting, exiting early.");
:exit;
}
:local RunOrder ({});
:foreach Script in=[ /system/script/find where source~("\n# provides: lease-script\\b") ] do={
:local ScriptVal [ /system/script/get $Script ];
:local Store [ $ParseKeyValueStore [ $Grep ($ScriptVal->"source") ("\23 provides: lease-script, ") ] ];
:set ($RunOrder->($Store->"order" . "-" . $ScriptVal->"name")) ($ScriptVal->"name");
}
:foreach Order,Script in=$RunOrder do={
:onerror Err {
$LogPrint debug $ScriptName ("Running script with order " . $Order . ": " . $Script);
/system/script/run $Script;
} do={
$LogPrint warning $ScriptName ("Running script '" . $Script . "' failed: " . $Err);
}
}
} do={
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
}

View file

@ -64,17 +64,14 @@
137="Added support to send notifications via Gotify (gotify.net).";
138="RouterOS 7.19 is suffering an issue with certificate store. Fixing trust state for all certificates...";
139="Certificate Authorities will reduce the leaf certificate validity times soon. Thus the defaults for renewal and warning in 'check-certificates' were decreased.";
140="The scripts 'lease-script' was renamed to 'dhcpv4-server-lease', configuration was updated automatically.";
141="Introduced script 'dhcpv6-client-lease' to run several scripts on IPv6 DHCP client lease.";
};
# Migration steps to be applied on script updates
:global GlobalConfigMigration {
97=":local Rec [ /ip/dns/static/find where comment~\"^managed by dhcp-to-dns for \" ]; :if ([ :len \$Rec ] > 0) do={ /ip/dns/static/remove \$Rec; /system/script/run dhcp-to-dns; };";
100=":global ScriptInstallUpdate; :if ([ :len [ /system/script/find where name=\"ssh-keys-import\" source~\"^#!rsc by RouterOS\\r?\\n\" ] ] > 0) do={ /system/script/set name=\"mod/ssh-keys-import\" ssh-keys-import; \$ScriptInstallUpdate; };";
97=":local Rec [ /ip/dns/static/find where comment~\"^managed by dhcp-to-dns for \" ]; :if ([ :len \$Rec ] > 0) do={ /ip/dns/static/remove \$Rec; /system/script/run dhcp-to-dns; }";
100=":global ScriptInstallUpdate; :if ([ :len [ /system/script/find where name=\"ssh-keys-import\" source~\"^#!rsc by RouterOS\\r?\\n\" ] ] > 0) do={ /system/script/set name=\"mod/ssh-keys-import\" ssh-keys-import; \$ScriptInstallUpdate; }";
104=":global CharacterReplace; :global ScriptInstallUpdate; :foreach Script in={ \"capsman-download-packages\"; \"capsman-rolling-upgrade\"; \"hotspot-to-wpa\"; \"hotspot-to-wpa-cleanup\" } do={ /system/script/set name=(\$Script . \".capsman\") [ find where name=\$Script ]; :foreach Scheduler in=[ /system/scheduler/find where on-event~(\$Script . \"([^-.]|\\\$)\") ] do={ /system/scheduler/set \$Scheduler on-event=[ \$CharacterReplace [ get \$Scheduler on-event ] \$Script (\$Script . \".capsman\") ]; }; }; /ip/hotspot/user/profile/set on-login=\"hotspot-to-wpa.capsman\" [ find where on-login=\"hotspot-to-wpa\" ]; \$ScriptInstallUpdate;";
111=":local Rec [ /ip/dns/static/find where comment~\"^managed by dhcp-to-dns for \" ]; :if ([ :len \$Rec ] > 0) do={ /ip/dns/static/remove \$Rec; /system/script/run dhcp-to-dns; };";
132=":if ([ :len [ /system/script/find where name=\"check-health\" ] ] > 0) do={ :local Code \":local Install \\\"check-health\\\"; :if ([ :len [ /system/health/find where type=\\\"\\\" name~\\\"-state\\\\\\\$\\\" ] ] > 0) do={ :set Install (\\\$Install . \\\",check-health.d/state\\\"); }; :if ([ :len [ /system/health/find where type=\\\"C\\\" ] ] > 0) do={ :set Install (\\\$Install . \\\",check-health.d/temperature\\\"); }; :if ([ :len [ /system/health/find where type=\\\"V\\\" ] ] > 0) do={ :set Install (\\\$Install . \\\",check-health.d/voltage\\\"); }; :global ScriptInstallUpdate; \\\$ScriptInstallUpdate \\\$Install;\"; :global ValidateSyntax; :if ([ \$ValidateSyntax \$Code ] = true) do={ :do { [ :parse \$Code ]; } on-error={ }; }; };";
111=":local Rec [ /ip/dns/static/find where comment~\"^managed by dhcp-to-dns for \" ]; :if ([ :len \$Rec ] > 0) do={ /ip/dns/static/remove \$Rec; /system/script/run dhcp-to-dns; }";
132=":if ([ :len [ /system/script/find where name=\"check-health\" ] ] > 0) do={ :local Code \":local Install \\\"check-health\\\"; :if ([ :len [ /system/health/find where type=\\\"\\\" name~\\\"-state\\\\\\\$\\\" ] ] > 0) do={ :set Install (\\\$Install . \\\",check-health.d/state\\\"); }; :if ([ :len [ /system/health/find where type=\\\"C\\\" ] ] > 0) do={ :set Install (\\\$Install . \\\",check-health.d/temperature\\\"); }; :if ([ :len [ /system/health/find where type=\\\"V\\\" ] ] > 0) do={ :set Install (\\\$Install . \\\",check-health.d/voltage\\\"); }; :global ScriptInstallUpdate; \\\$ScriptInstallUpdate \\\$Install;\"; :global ValidateSyntax; :if ([ \$ValidateSyntax \$Code ] = true) do={ :do { [ :parse \$Code ]; } on-error={ }; }; }";
138="/certificate/set trusted=yes [ find where trusted=yes ];";
140=":if ([ :len [ /system/script/find where name=\"lease-script\" ] ] > 0) do={ /system/script/set name=\"dhcpv4-server-lease\" \"lease-script\"; :global ScriptInstallUpdate; \$ScriptInstallUpdate; /ip/dhcp-server/set lease-script=\"dhcpv4-server-lease\" [ find where lease-script=\"lease-script\" ]; };";
};