Community discussions

MikroTik App
 
VeeDub
just joined
Topic Author
Posts: 11
Joined: Fri Jun 02, 2017 4:11 pm

How to obtain nexthop value in a variable

Wed Apr 16, 2025 4:52 am

Hello,

I'm using ROS 7.18.2

The router has two routes to the Internet and I'm using Check Gateway and that is working.

If the router switches to the backup link, I'd like to be notified.

I've worked out that I can monitor the uplink state by using the command:
/ip/route/check dst-ip=1.1.1.1 duration=1

This reports the following values:
status
interface
nexthop

I'm hoping that someone can tell me how to get nexthop into a variable.

I have done some searching, but the examples I have found are nothing like my situation and I can't figure out the syntax that I need to use or whether what I've described is actually possible.

Is this possible?

Thanks
VW
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4874
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: How to obtain nexthop value in a variable

Wed Apr 16, 2025 5:42 am

/routing/nexthop print
To see all routes, you can also use:
/routing/routes print
 
User avatar
loloski
Member
Member
Posts: 482
Joined: Mon Mar 15, 2021 9:10 pm
Location: Philippines

Re: How to obtain nexthop value in a variable  [SOLVED]

Wed Apr 16, 2025 5:45 am

:global nexthop ([/ip/route/check dst-ip=1.1.1.1 once as-value]->"nexthop")
:put $nexthop