以下是本人整理脚本代码
:local zconfIP
:local zcurIP
:local znewIP
:local znum1
:local znum2
:local znum3
:local znum4
:local ztmpstr1
:local ztmpstr2
:local ztmpstr3
:local ztmpstr4
:local zconfIP [/ip address get [/ip address find interface=("ether2")] network]
:set znum1 [:find $zconfIP "."]
:set ztmpstr1 [:pick $zconfIP 0 $znum1]
:set znum2 [:find $zconfIP "." $znum1]
:set ztmpstr2 [:pick $zconfIP ($znum1+1) $znum2]
:set znum3 [:find $zconfIP "." $znum2]
:set ztmpstr3 [:pick $zconfIP ($znum2+1) $znum3]
:set ztmpstr4 [:pick $zconfIP ($znum3+1) [:len $zconfIP]]
:set znewIP ($ztmpstr1 . "." . $ztmpstr2 . "." . $ztmpstr3 . "." . 1)
/ip route set [/ip route find comment=("10-newang")] gateway=$znewIP