Community discussions

MikroTik App
 
ezhangiso
newbie
Topic Author
Posts: 28
Joined: Tue Feb 23, 2021 9:07 am

Automatically change gateway and firewall addresses

Tue Sep 05, 2023 4:15 pm

Hello.
Due to configuration requirements, add default route=yes cannot be set. A script needs to be used to modify the gateway and firewall address list. However, the following script reported an error during runtime. Please take a look and help modify it. Thank you.(v7.10.2)

{
:local v6i "3"
:for v6ii from=1 to=$v6i do={
:local v6gateway [/ipv6 route get [/ipv6 route find comment=("pppoe-out".$v6ii)] gateway]
:set v6gateway [:pick $v6gateway 0 [:find $v6gateway "%"]]
:local v6adlist [/ipv6 firewall address-list get [/ipv6 firewall address-list find comment=("pppoe-out".$v6ii)] address]
:local v6ser [/ipv6 dhcp-client get [/ipv6 dhcp-client find interface=("pppoe-out".$v6ii) dhcp-server-v6]
:local prefix [/ipv6 dhcp-client get [/ipv6 dhcp-client find interface=("pppoe-out".$v6ii) prefix]
:if ($v6gateway != $v6ser) do={
/ipv6 route set [/ipv6 route find comment=("pppoe-out".$v6ii)] gateway=($v6ser."%".("pppoe-out".$v6ii))}
:if ($v6adlist != $prefix) do={
/ipv6 firewall address-list set [/ipv6 firewall address-list find comment=("pppoe-out".$v6ii)] address=$prefix}
}
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: No registered users and 6 guests