Static routing

Yaser Rahmti | یاسر رحمتی

Static routing in MikroTik RouterOS involves manually configuring routes in the router's routing table. This allows you to specify the exact path that packets should take to reach a specific destination.

Here’s a step-by-step guide to configuring static routing in MikroTik RouterOS with a simple example:

Scenario Example:

Assume you have two networks connected through a MikroTik router:

  • Network A: 192.168.1.0/24

  • Network B: 192.168.2.0/24

  • Router Interface for Network A: ether1

  • Router Interface for Network B: ether2

You want to set up static routing so that devices in Network A can communicate with devices in Network B.

1. Configuring Interfaces

Step 1: Assign IP Addresses to Interfaces

  1. Access MikroTik Router:

    • Connect to your MikroTik router using Winbox, WebFig, or SSH.

  2. Assign IP Addresses:

    • Using CLI:

      ip address add address=192.168.1.1/24 interface=ether1
      ip address add address=192.168.2.1/24 interface=ether2
    • Using Winbox/WebFig:

      • Go to IP -> Addresses.

      • Click + to add a new IP address.

      • Enter the IP address and subnet mask for ether1, select ether1 as the interface, and click OK.

      • Repeat for ether2 with the appropriate IP address.

2. Configuring Static Routes

Step 2: Add a Static Route

  1. Define the Route:

    • Using CLI:

      ip route add dst-address=192.168.2.0/24 gateway=192.168.1.1
      • dst-address=192.168.2.0/24: Specifies the destination network.

      • gateway=192.168.1.1: Specifies the IP address of the next-hop router or gateway for reaching the destination network.

    • Using Winbox/WebFig:

      • Go to IP -> Routes.

      • Click + to add a new route.

      • Set Dst. Address to 192.168.2.0/24.

      • Set Gateway to 192.168.1.1.

      • Click OK to add the route.

3. Verifying the Configuration

Step 3: Verify Routing Table

  1. Check Routes:

    • Using CLI:

      shellCopy code/ip route print
    • Using Winbox/WebFig:

      • Go to IP -> Routes.

      • Verify that the route to 192.168.2.0/24 is listed in the routing table.

  2. Test Connectivity:

    • From a device in Network A (e.g., with IP 192.168.1.10), try pinging a device in Network B (e.g., with IP 192.168.2.10).

    • Using CLI:

      ping 192.168.2.10
    • Using Winbox/WebFig:

      • Go to Tools -> Ping.

      • Enter the IP address 192.168.2.10 and click Start to test connectivity.

4. Advanced Configuration (Optional)

1. Static Route with Metric:

You can assign a metric to the route to influence the route selection process when multiple routes are available.

  • Using CLI:

    ip route add dst-address=192.168.2.0/24 gateway=192.168.1.1 distance=1
  • Using Winbox/WebFig:

    • When adding or editing the route, set the Distance field to 1.

2. Default Route:

If you want to set a default route for all destinations not explicitly covered by other routes:

  • Using CLI:

    ip route add dst-address=0.0.0.0/0 gateway=192.168.1.1
  • Using Winbox/WebFig:

    • Set Dst. Address to 0.0.0.0/0 to create a default route.

Summary

By following these steps, you’ve configured static routing on a MikroTik router to enable communication between two different networks. Static routing is suitable for simple or small networks where routes do not change frequently. For more complex or dynamic network environments, dynamic routing protocols might be more appropriate.

Keywords

MikroTik, RouterOS, RouterBOARD, wireless networking, ISP, WISP, networking equipment, routers, switches, Cloud Core Router, CCR, SXT, LTE integration, 5G, cybersecurity, network security, networking software, networking hardware, Latvia, John Trully, Arnis Riekstiņš, MikroTik Academy, MUM events, network management, hotspot, VLAN, firewall, VPN, QoS, bandwidth management, traffic shaping, wireless access point, CAPsMAN, WinBox, PoE, mesh networking, routing protocols, MPLS, OSPF, BGP, MikroTik training

میکروتیک, روتر او اس, روتر برد, شبکه بی‌سیم, آی اس پی, وایرلس آی اس پی, تجهیزات شبکه, روترها, سوییچ‌ها, کلود کور روتر, سی سی آر, اس ایکس تی, ادغام ال تی ای, 5G, امنیت سایبری, امنیت شبکه, نرم‌افزار شبکه, سخت‌افزار شبکه, لتونی, جان ترولی, آرنیس ریکسینش, آکادمی میکروتیک, رویدادهای مام, مدیریت شبکه, هات اسپات, وی‌لَن, فایروال, وی‌پی‌ان, کیو‌اُ‌اس, مدیریت پهنای باند, شکل‌دهی ترافیک, نقطه دسترسی بی‌سیم, کپزمن, وین‌باکس, پی او ای, شبکه مش, پروتکل‌های مسیریابی, ام پی ال اس, اُ اس پی اف, بی جی پی, آموزش میکروتیک

External Links

🌐 Personal Website 📄 Resume 🎥 Video Archive 💼 Finance Blog 🔐 Network & Security Notebook 🎬 Aparat Channel

Last updated