Skip to content

Instantly share code, notes, and snippets.

@ge0rg
Last active August 26, 2026 16:54
Show Gist options
  • Select an option

  • Save ge0rg/bd9c8e5e690825557caa10dc7bbd360c to your computer and use it in GitHub Desktop.

Select an option

Save ge0rg/bd9c8e5e690825557caa10dc7bbd360c to your computer and use it in GitHub Desktop.
MikroTik DHCPv6 client script to update firewall address-lists
# 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