Skip to content
Back to Blog
MikroTik

Static Routing in MikroTik: Connecting Multiple Networks

Learn static routing in MikroTik to connect multiple subnets, configure default gateways, and troubleshoot routing issues.

Mar 2026
9 min read

Static Routing on MikroTik RouterOS

Routing is the process of deciding where to send a packet based on its destination IP address. RouterOS maintains a routing table — a list of known networks and how to reach them. This lesson covers static routes: routes you add manually.

The Routing Table

To see the current routing table:

TEXT
/ip route print

Example output:

TEXT
Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf
 #      DST-ADDRESS        PREF-SRC        GATEWAY            DISTANCE
 0 ADC  192.168.1.0/24     192.168.1.1     bridge             0
 1 ADC  10.0.0.0/30        10.0.0.1        ether1             0
 2 ADS  0.0.0.0/0                          10.0.0.254         1

Understanding the flags:

  • A — Active (this route is currently being used)
  • D — Dynamic (added automatically, e.g., by DHCP client or routing protocol)
  • C — Connected (created automatically when you add an IP address to an interface)
  • S — Static (manually added by you)

The Default Route

The most important static route is the default route — also called the gateway of last resort. It tells the router where to send traffic when no more specific route exists (which is most Internet traffic).

The default route has destination 0.0.0.0/0, which matches every IP address (with the lowest priority — more specific routes always win).

Adding a Default Route

TEXT
/ip route add dst-address=0.0.0.0/0 gateway=10.0.0.254

Here 10.0.0.254 is your ISP gateway address. Every packet destined for the Internet will be sent there.

Check Your Default Route

TEXT
/ip route print where dst-address=0.0.0.0/0

Adding Static Routes

The general syntax is:

TEXT
/ip route add dst-address=<NETWORK/PREFIX> gateway=<NEXT-HOP-IP>

Example: Route to a Remote Network

Suppose you have two offices connected via a VPN or leased line:

  • Your office: 192.168.1.0/24
  • Remote office: 192.168.2.0/24
  • The gateway to reach the remote office: 10.10.10.2
TEXT
/ip route add dst-address=192.168.2.0/24 gateway=10.10.10.2 comment=route-to-remote-office

Now packets going to 192.168.2.x will be sent to 10.10.10.2, which forwards them to the remote office.

Example: Multiple Hops

If you need to reach 172.16.0.0/16 through 192.168.1.254:

TEXT
/ip route add dst-address=172.16.0.0/16 gateway=192.168.1.254

Route Distance (Metric)

Every route has a distance value (also called administrative distance or metric). Lower distance = higher priority.

Default distances:

Route TypeDefault Distance
Connected0
Static1
eBGP20
OSPF110
RIP120

You can set the distance when adding a route:

TEXT
/ip route add dst-address=0.0.0.0/0 gateway=10.0.0.254 distance=1

Using Distance for Backup Routes (Floating Static Routes)

You can add two routes to the same destination with different distances to create a primary/backup setup:

TEXT
# Primary route (distance 1 — used first)
/ip route add dst-address=0.0.0.0/0 gateway=10.0.0.254 distance=1

# Backup route (distance 5 — only used if primary is inactive)
/ip route add dst-address=0.0.0.0/0 gateway=192.168.100.1 distance=5

RouterOS will always use the route with lower distance when both are active. If the primary gateway fails (and RouterOS detects this via the check-gateway feature), it automatically switches to the backup.

The check-gateway Feature

RouterOS can monitor whether a gateway is reachable and mark a route as inactive if it is not:

TEXT
/ip route add dst-address=0.0.0.0/0 gateway=10.0.0.254 check-gateway=ping

With check-gateway=ping, RouterOS periodically pings the gateway. If it stops responding, the route is marked inactive and the next-best route takes over.

Longest Prefix Match

When a packet arrives, RouterOS picks the most specific route (the longest prefix) that matches. For example:

  • Route A: 10.0.0.0/8 via gateway1
  • Route B: 10.10.0.0/16 via gateway2
  • Route C: 10.10.10.0/24 via gateway3

A packet going to 10.10.10.5 will use Route C (most specific, longest prefix /24).

A packet going to 10.10.5.5 will use Route B.

A packet going to 10.20.0.5 will use Route A.

Removing and Modifying Static Routes

Remove a route by number:

TEXT
/ip route remove 2

Remove a specific route:

TEXT
/ip route remove [find dst-address=192.168.2.0/24]

Modify a route:

TEXT
/ip route set 2 gateway=10.10.10.3

Disabling Routes

You can disable a route without removing it (useful for testing):

TEXT
/ip route disable 2
/ip route enable 2

A disabled route shows with X flag in print.

Testing Routing with ping and traceroute

Test if a destination is reachable:

TEXT
/ping 192.168.2.1 count=4

Trace the path packets take:

TEXT
/tool traceroute 8.8.8.8

This shows every hop along the path to the destination — very useful for diagnosing routing problems.

Viewing the Route Table With Filters

Show only static routes:

TEXT
/ip route print where static

Show only active routes:

TEXT
/ip route print where active

Summary

Static routing in RouterOS:

  • View routes: /ip route print
  • Add default route: /ip route add dst-address=0.0.0.0/0 gateway=X.X.X.X
  • Add specific route: /ip route add dst-address=NETWORK/PREFIX gateway=X.X.X.X
  • Lower distance = higher priority
  • Use floating static routes (different distances) for backup paths
  • Use check-gateway=ping to automatically failover when a gateway goes down