DHCP客户端网关自动更新到静态路由TR069IP的网关

:local rmark "tr069ip"

:local count [ /ip route print count-only where comment="tr069ip"]

if ($bound=1) do={

:if ($count = 0) do={ /ip route add gateway=$"gateway-address" comment="tr069ip" routing-mark=$rmark  } else=

:if ($count = 1) do={

:local test [/ip route find where comment="tr069ip"]

:if ([/ip route get $test gateway] != "gateway-address") do={ /ip route set $test gateway= $"gateway-address"

}} else={

:error "Multiple routes found"

 }

 }

 } else={

/ip route remove [find comment="tr069ip"] }

这个根据自己需要决定去留?

2022年3月6日,针对7.0更新精简脚本,interace的网口为自动获取IP地址的网口,自己手动去建立静态路由comment为tr069ip

{

:local rmark

:local markk

:local test [/ip route find where comment="tr069ip"]

set rmark [/ip dhcp-client get [/ip dhcp-client find interface=ether5] gateway]

set markk [/ip route get $test gateway]

:if ( $rmark != $markk) do={{/ip route set $test gateway= $rmark}

:log error "TR069网关地址不一致已更新" } else={

:log error "TR069网关地址一致不需要更新"

}}