0% found this document useful (0 votes)
32 views1 page

DHCP Route Management for ISP4

The document contains a script for managing network routes based on DHCP client information. It checks for existing routes and updates or adds new routes with specific parameters such as gateway, distance, and comments. The script ensures that the routes are configured for the interface 'ether4' and the routing table 'ISP4'.

Uploaded by

jobel.mindac
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
0% found this document useful (0 votes)
32 views1 page

DHCP Route Management for ISP4

The document contains a script for managing network routes based on DHCP client information. It checks for existing routes and updates or adds new routes with specific parameters such as gateway, distance, and comments. The script ensures that the routes are configured for the interface 'ether4' and the routing table 'ISP4'.

Uploaded by

jobel.mindac
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

:local interfaceName "ether4"

:local routeComment "to_wan4"

# Get the gateway from the DHCP client


:local GWay [/ip dhcp-client get [find interface=$interfaceName] gateway]

# Check if the route with the specified comment exists


:local routeExists [/ip route find where comment=$routeComment]

# If the route exists, update the gateway. If not, add a new route.
:if ($routeExists != "") do={
/ip route set [$routeExists] gateway=($GWay."%ether4")
} else={
/ip route add dst-address=[Link]/0 gateway=($GWay."%ether4") check-
gateway=ping comment=$routeComment
}

# Add/Update the route with check-gateway=ping, distance=4, and routing-table=ISP4


:local routeISP4Exists [/ip route find where comment=$routeComment and routing-
table=ISP4]

:if ($routeISP4Exists != "") do={


/ip route set [$routeISP4Exists] gateway=($GWay."%ether4") check-gateway=ping
distance=4
} else={
/ip route add dst-address=[Link]/0 gateway=($GWay."%ether4") check-
gateway=ping distance=4 routing-table=ISP4 comment=$routeComment
}

You might also like