Can somebody show me a script to get gateway address from dst-address?
Can’t quite figure it out…
Thanks
Can somebody show me a script to get gateway address from dst-address?
Can’t quite figure it out…
Thanks
How do you mean it?
Something along the lines of:
{
:local gatewayWT [/ip address get [/ip route find gateway dst-address=10.4.0.0/16] ]
:put $gatewayWT
}
You can use the “/ip route check” command to get it on screen… But actually getting it as a value is a little more difficult. Your two best options are to either write to a file, and read from it 2s later, or to use the API. The former makes it difficult to extract the nexthop out of that, while the latter requires a separate device or metarouter.
this sorta works, put doesn’t give me a local to pass like $nexthop
/ip route check dst-ip=10.4.0.0 once
which gets me:
status: ok
interface: ether4-WT_5AC
nexthop: 10.251.250.4
need to grab the nexthop IP