-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-discovery-dns.rsc
60 lines (58 loc) · 1.66 KB
/
update-discovery-dns.rsc
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# config ipv6 discovery dns and update ipv6 firewall list
:local IPv6;
:local value;
:local prefix 128;
:local list "{firewall-list-for-internet-ip}";
:local name "{internet-connection-name}";
:delay 2s;
/ipv6 address;
# getting global external ipv6 address
:foreach address in=[find where global !disabled !invalid] do={
:if ([get $address interface] = $name) do={
:set value [get $address address];
:set value [:pick $value 0 [:find $value "/"]];
:set IPv6 $value;
};
};
# setting ipv6 dns address for all interface
:if ([:len $IPv6] != 0) do={
/ipv6 nd;
:foreach discovery in=[find where !disabled] do={
:if ([get $discovery dns] != $IPv6) do={
:set value [get $discovery interface];
:log info "change discovery dns address $IPv6 for $value";
set $discovery dns=$IPv6;
};
};
};
# setting ipv6 address in firewall list
:if ([:len $IPv6] != 0) do={
/ipv6 firewall address-list;
# update ipv6 address in firewall list
:foreach record in=[find where !disabled !dynamic] do={
:if ([get $record list] = $list) do={
:if ([:len $IPv6] != 0) do={
:set value "$IPv6/$prefix";
:if ([get $record address] != $value) do={
:log info "change address $IPv6 in list $list";
set $record address=$value;
};
:if ([get $record comment] != $name) do={
set $record comment=$name;
};
:set IPv6;
} else={
:set value [get $record address];
:log info "remove address $value in list $list";
remove $record;
};
};
};
# add ipv6 address in firewall list
:if ([:len $IPv6] != 0) do={
:set value "$IPv6/$prefix";
:log info "add address $IPv6 in list $list";
add list=$list address=$value comment=$name;
:set IPv6;
};
};