-
Notifications
You must be signed in to change notification settings - Fork 0
/
MikroTik dynamic IPv6 script
26 lines (26 loc) · 1.02 KB
/
MikroTik dynamic IPv6 script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Restart the IPv6, and change addresslists for desired machines
:delay 7.5
{
#Array with machine names and address suffix pairs
:local machines ({"srv01"="aa11:bb22:cc33:dd44"})
#Settings
#IPv6 pool:
:local poolname "digi"
:local desiredif "br-lan"
:local pppoeif "digi-pppoe"
#DO NOT MODIFY IF YOU DON'T KNOW WHAT YOU are DOING!!!
#Turn off DHCPv6 client
:execute [/ipv6 dhcp-client disable [find interface=$pppoeif]]
#Wait 0.5 secs before get a new prefix (and address)
:delay 0.5
#Turn on DHCPv6 client
:execute [/ipv6 dhcp-client enable [find interface=$pppoeif]]
#Wait 3 secs to get a prefix (and an address)
:delay 3
#Get local IP6
:local ip6address [/ipv6 address get [find from-pool=$poolname interface=$desiredif] address]
#Get the /64 prefix
:local ip6prefix [tostr [pick $ip6address 0 [find $ip6address "::/"]]]
#Write prefix to addresslist
:foreach k,v in $machines do={:execute [/ipv6 firewall address-list remove [find list="$k"]]; :execute [/ipv6 firewall address-list add list="$k" address=($ip6prefix.":".$v) timeout="10w"]}
}