Site icon DED9

How can you Check the Gateway of an IP for MikroTik VPS by CLI and with Winbox?

How can you check an IP’s Gateway for MikroTik VPS by CLI and with Winbox?

In this article, we want to show you How to Check the Gateway of an IP for MikroTik VPS by CLI and with Winbox, So let’s Learn.

And In the Following, we will show you some of the problems that MikroTik users encounter with it.

Some of the people are new to Mikrotik, and They are happy to see so many ways to load-balance and failover traffic when there are multiple upstream connections. However, it seems like performing a real check beyond “is the upstream router powered up” involves delving into scripting, which is a real pain, especially if you’re trying to use more than two upstream connections.

Many DSL, cable, EoC, T1, etc., connections will have a separate LAN block. Simply pinging the upstream router’s IP, which you use as a default gateway, tells you nothing about whether you have connectivity. Being able to specify, say, the first hop IP beyond your upstream router or a server upstream would be much more “real world” friendly.

For instance, how much more comfortable would this be:

Code:
ip route add dst-address=0.0.0.0/0 gateway=10.111.0.1 check-gateway=ping check-address=10.110.0.99

It really would be lovely if we could do that per route.

Code:
/ip route
add check-gateway=ping check-address=A.B.C.1 comment=Wireless distance=10 dst-address=0.0.0.0/1 gateway=\
    H.I.J.225
add check-gateway=ping comment=DSL distance=20 dst-address=0.0.0.0/1 gateway=\
    H.I.K.237
add distance=1 dst-address=A.B.C.1/32 gateway=H.I.J.225
add comment="open vpn server" distance=1 dst-address=D.E.F.9/32 gateway=pppoe-out1
add comment="make sure open vpn server is unreachable when pppoe-out1 is dead" \
    distance=200 dst-address=D.E.F.9/32 type=unreachable
add check-gateway=ping check-address=A.B.C.1 comment=Wireless distance=10 dst-address=128.0.0.0/1 gateway=\
    H.I.J.225
add check-gateway=ping comment=DSL distance=20 dst-address=128.0.0.0/1 gateway=\
    H.I.K.237

Maybe behind the scenes, MikroTik would be creating netwatch entries to automatically disable the routes like the mangle rules created to set MSS for tunnel interfaces.

Maybe Some people are mistaken, but this type of check exists already using recursive routing.

Create a route with the IP you want to use to check the connectivity and set the gateway as your default gateway/next hop. Then, specify the IP you are checking as the default route for your default route.

Here’s an example based on my config. 1.2.3.4 would be my “gateway,” while 2.3.4.5 is the upstream device. Some people are checking to verify connectivity. 3.4.5.6 will be a secondary route if your primary is down.

/IP route
add check-gateway=ping comment=”Primary Default Route – Midco” distance=1 gateway=2.3.4.5
add check-gateway=ping comment=”Backup Default Route – Midco” distance=2 gateway=3.4.5.6
add comment=”Validate Route” distance=1 DST-address=2.3.4.5/32 gateway=1.2.3.4 scope=10

If you cannot reach 2.3.4.5 via 1.2.3.4, the route is disabled, and it uses 3.4.5.6 for connectivity.

Also, we have provided A Useful Video about How to check an IP’s Gateway for MikroTik VPS by CLI and with Winbox step by Step.

Exit mobile version