How to assing a dynamic route to a routing table

Hi, I’ve an important task, the LAN network /24 is splitted in two parts, the first 127 addresses using the devault gateway with main routing table, the second half of the subnet should use another gateway, this i ssimple to obtain, I mangle the 192.168.0.128/25 addresses to use another routing table which I created.
Now the problem is that this second gateway is givng me an internal IP which may change in future, and by DHCP client I can’t define the routing table it has to be assigned, where I can mangle the traffic. To solve the problem I had to create a static default route to the gateway which actually I see on the DHCP client datas, works, but how can I created it automatic if the gateway address change?
Thanks

In the picture I show the differences between a dynamic route entry and a static one, it’s the same also for 0.0.0.0/0 route. I can’t uplead that scren because I’m afraid to activate it, I can loose the router remotely, I think you understood already
routeingtable.jpg

Dynamic rules are intended for Ros use.

Maybe you want to add a script to DHCP client to update the gateway on your static route ?
http://forum.mikrotik.com/t/completing-a-script-for-checking-and-updating-dynamic-isps-gateway/147715/1

Thank you for kind answer, what is a Ros use? Mikrotik router OS? where are these dynamic rules and how can I use them? Sounds strange to me
I can use the script, but I consider it a dirty work, why Mikrotik simply don’t let us to assing a default gateway from dynamic connection to a routing table? This is also a mystery.
The only script posted there is this

:if ($bound=1) do={/ip route set [find where dst-address=0.0.0.0/0 routing-mark=ISP1] gateway=$"gateway-address" }

reading it it seams a partial solutin only, much more interesing is the script in the Mikrotik guide, but I don’t know how it behaves after the expiraiton (if it may be dangerous)

/ip dhcp-client
add add-default-route=no dhcp-options=hostname,clientid disabled=no interface=ether2 script="{\r\
    \n    :local rmark \"WAN1\"\r\
    \n    :local count [/ip route print count-only where comment=\"WAN1\"]\r\
    \n    :if (\$bound=1) do={\r\
    \n        :if (\$count = 0) do={\r\
    \n            /ip route add gateway=\$\"gateway-address\" comment=\"WAN1\" routing-mark=\$rmark\r\
    \n        } else={\r\
    \n            :if (\$count = 1) do={\r\
    \n                :local test [/ip route find where comment=\"WAN1\"]\r\
    \n                :if ([/ip route get \$test gateway] != \$\"gateway-address\") do={\r\
    \n                    /ip route set \$test gateway=\$\"gateway-address\"\r\
    \n                }\r\
    \n            } else={\r\
    \n                :error \"Multiple routes found\"\r\
    \n            }\r\
    \n        }\r\
    \n    } else={\r\
    \n        /ip route remove [find comment=\"WAN1\"]\r\
    \n    }\r\
    \n}\r\
    \n"

You should read “Dynamic” as “automatically created/managed by the (Router) Operating System, NOT by user”.

Yes, this is the script that may (if I got your question right) solve the issue:

:if ($bound=1) do={/ip route set [find where dst-address=0.0.0.0/0 routing-mark=ISP1] gateway=$"gateway-address" }

I don’t see in any way how it is dirty or partial, it simply detects when a change in DHCP settings happens and updates the route with the current (new) gateway.

I completely agree! And I truly hope Mikrotik implements a simpler solution like /routing/rule src-interface=xxxx or similar. Currently, you can only use /routing/rule src-address=xxxx which needs to be updated using a DHCP script, giving it a “dirty” feel.