how to configure load balancing in MikroTik router NTH Method

This guide will walk you through the essential steps to configure NTH load balancing on your MikroTik router, ensuring both efficient traffic distribution and seamless failover

Step 1: Configure Your WAN Interfaces & DNS

First, set up your basic internet connectivity for both WAN links.

  1. IP Addresses: Assign IP addresses to your WAN interfaces (ether1/WAN 1 and ether2/WAN 2).

  2. DNS Servers: Go to IP > DNS and add your preferred DNS servers (e.g., your ISP’s DNS or public options like 8.8.8.8 and 1.1.1.1).

 

Step 2: Create NAT Masquerade Rules

You need a NAT rule for each outgoing WAN interface.

  1. Go to IP > Firewall > NAT.

  2. Create two srcnat rules:

    • Rule 1: Chain: srcnat, Out. Interface: WAN 1, Action: masquerade.

    • Rule 2: Chain: srcnat, Out. Interface: WAN 2, Action: masquerade.

 

Step 3: Implement the NTH Mangle Rules (The Core of Load Balancing)

This is the most critical step, where you create four Mangle rules under IP > Firewall > Mangle.

Rules 1 & 2: Mark Connections (Distribution)

These rules use the NTH parameter to split incoming traffic into two logical connection groups (con-wan1 and con-wan2).

  1. Rule for conn-wan1 (Packet 1 of 2):

    • General Tab: Chain: prerouting, In. Interface: [LAN Interface], Connection State: new.

    • Extra Tab: NTH: 2,1.

    • Action Tab: Action: mark connection, New Connection Mark: conn-wan1, Passthrough: yes.

  2. Rule for con-wan2 (Packet 2 of 2): Copy the first rule, but change Extra Tab > NTH to 2,2 and Action Tab > New Connection Mark to con-wan2.

Rules 3 & 4: Mark Routes (Routing)

These rules assign a routing mark to packets based on their connection mark.

  1. Rule for route-wan1:

    • General Tab: Chain: prerouting, Connection Mark: con-wan1.

    • Action Tab: Action: mark routing, New Routing Mark: route-wan1, Passthrough: yes.

  2. Rule for route-wan2: Copy the third rule, changing the Connection Mark to con-wan2 and the New Routing Mark to route-wan2.

 

Step 4: Add Routes for NTH Load Balancing 

You need four default routes under IP > Routes.

Routes 1 & 2: Primary Marked Routes

These routes use the marks created in Step 3 to direct traffic down the designated WAN link.

  1. Route to WAN 1: Dst. Address: 0.0.0.0/0, Gateway: [WAN 1 Gateway IP], Routing Mark: route-wan1.

  2. Route to WAN 2: Dst. Address: 0.0.0.0/0, Gateway: [WAN 2 Gateway IP], Routing Mark: route-wan2.

Testing Your NTH Configuration

 Check Live Traffic: Monitor Interfaces to see traffic on both WAN links.

Leave a Reply

Your email address will not be published. Required fields are marked *