Last active
August 26, 2026 16:54
-
-
Save ge0rg/bd9c8e5e690825557caa10dc7bbd360c to your computer and use it in GitHub Desktop.
MikroTik DHCPv6 client script to update firewall address-lists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # DHCPv6 script to create firewall address-lists for the parent and the delegated network | |
| # | |
| # Preparation: | |
| # /ipv6 firewall address-list add list=delegated_net | |
| # /ipv6 firewall address-list add list=parent_net | |
| # | |
| # change the prefix of your parent network: | |
| :local parentPrefix 59 | |
| :global stripNetmask do={ :return ([:toip6 [:pick $1 0 [:find $1 "/"]]]); } | |
| :if ($"pd-valid" = 1) do={ | |
| :local lanNetPrefix $"pd-prefix" | |
| :local lanNet [$stripNetmask $"pd-prefix"] | |
| # get bitmask for parent network, work around lack of dynamic ip6-prefix creation | |
| :local parentBitmask [[:parse ":return ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/$parentPrefix"]] | |
| :local parentNet ($lanNet & [$stripNetmask $parentBitmask]); | |
| :log info "Got $lanNetPrefix delegation from $parentNet/$parentPrefix"; | |
| /ipv6/firewall/address-list/set [ find list=parent_net ] address="$parentNet/$parentPrefix" | |
| /ipv6/firewall/address-list/set [ find list=delegated_net ] address="$lanNetPrefix" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment