100% found this document useful (1 vote)
227 views1 page

PBR Wan Dinamicas

This document defines variables for route markings and monitors then checks if monitoring routes exist and either creates them or updates the gateways if they already exist. It will remove the routes if monitoring is not enabled.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
227 views1 page

PBR Wan Dinamicas

This document defines variables for route markings and monitors then checks if monitoring routes exist and either creates them or updates the gateways if they already exist. It will remove the routes if monitoring is not enabled.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

{

# CREAR VARIABLES
:local rmark "to_ISP_X"
:local bmark "backup_to_ISP_X"
:local monitormessage "monitor_ISP_X"
:local monitor "a.b.c.d"
:local dmonitor "a.b.c.d/32"
:local bmonitor "w.x.y.z"

# NO MODIFICAR DE AQUI HACIA ABAJO

#BUSCAR RUTAS EXISTENTES


:local count [/ip route print count-only where comment=$monitormessage]

# PROCEDER SI SE TOMO UNA IP


:if ($bound=1) do={

#CREAR RUTAS SI NO EXISTEN


:if ($count = 0) do={
/ip route add gateway=$"gateway-address" scope=10 dst-
address=$dmonitor comment=$monitormessage
/ip route add gateway=$monitor comment=$rmark check-gateway=ping
routing-mark=$rmark
/ip route add gateway=$bmonitor comment=$bmark distance=2 check-
gateway=ping routing-mark=$rmark
} else={

#ACTUALIZAR RUTAS SI YA EXISTE UNA


:if ($count = 1) do={
:local test [/ip route find where comment=$monitormessage]
:if ([/ip route get $test gateway] != $"gateway-address") do={
/ip route set $test gateway=$"gateway-address"
}
:local test [/ip route find where comment=$rmark]
:if ([/ip route get $test gateway] != $"gateway-address") do={
/ip route set $test gateway=$"gateway-address"
}
:local test [/ip route find where comment=$bmark]
: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=$rmark]
/ip route remove [find comment=$bmark]
/ip route remove [find comment=$monitormessage]
}
}

You might also like