Make Network Perfect : Step-by-Step Load Balancing Configuration on MikroTik

Setting Up a DHCP Server and Load Balancer on MikroTik RouterOS for ISPs and Enterprise Client

📡 MikroTik RouterOS provides a robust solution for internet service providers (ISPs) looking to configure and optimize network performance. This guide outlines the configuration process for setting up a DHCP server and load balancer on a MikroTik RB750Gr3 router. By implementing this configuration, ISPs can efficiently manage IP address allocation and ensure optimal internet connectivity for their clients. 🌐


Overview of Configuration

  1. Router Model: MikroTik RB750Gr3
  2. Features Configured:
  • DHCP Server for LAN
  • Load Balancing between two WAN connections: PPPoE (GTPL Input) and DHCP (Ethernet Input)
  • NAT for outgoing connections
  • IP address allocation and routing marks for traffic segmentation

🛠️ —

DHCP Server Configuration

📋 The DHCP server automatically assigns IP addresses to devices connected to the local network (LAN). Here is the detailed setup for a DHCP server on the MikroTik router:

Step 1: Define a Bridge for LAN

The bridge aggregates multiple LAN interfaces (ether3, ether4, and ether5). 🖧

/interface bridge
add name=bridge-lan

/interface bridge port
add bridge=bridge-lan interface=ether3
add bridge=bridge-lan interface=ether4
add bridge=bridge-lan interface=ether5

Step 2: Assign a Static IP Address to the Bridge

This address serves as the gateway for devices on the LAN. 🌐

/ip address
add address=192.168.1.1/24 comment="Bridge LAN Gateway" interface=bridge-lan network=192.168.1.0

Step 3: Configure the DHCP Server

  1. Create an IP pool for dynamic IP allocation. 📂
  2. Enable the DHCP server on the bridge.
/ip pool
add name=dhcp_pool_lan ranges=192.168.1.2-192.168.1.254

/ip dhcp-server
add address-pool=dhcp_pool_lan disabled=no interface=bridge-lan name=dhcp-lan

/ip dhcp-server network
add address=192.168.1.0/24 comment="LAN DHCP Network" dns-server=8.8.8.8,1.1.1.1 gateway=192.168.1.1

Step 4: Verify DHCP Server Status

Run the following command to check the status: ✅

/ip dhcp-server print

Ensure the X flag (indicating disabled) is not present. The server should be active and ready to assign IPs. 🖥️


Load Balancing Configuration

⚙️ Load balancing ensures efficient utilization of multiple WAN connections. This setup uses PPPoE (ether1) and DHCP client (ether2) as input sources for internet traffic.

Step 1: Configure WAN Inputs

  1. PPPoE Client:
/interface pppoe-client
add add-default-route=yes disabled=no interface=ether1 name=pppoe-out1 password=7096900814 use-peer-dns=yes user=gs0814_brc
  1. DHCP Client:
/ip dhcp-client
add disabled=no interface=ether2

Step 2: Mark Connections and Routes

Use mangle rules to differentiate traffic and assign routing marks. 🔄

/ip firewall mangle
add action=mark-connection chain=prerouting dst-address-type=!local in-interface=bridge-lan new-connection-mark=pppoe_conn passthrough=yes
add action=mark-connection chain=prerouting dst-address-type=!local in-interface=ether2 new-connection-mark=dhcp_conn passthrough=yes
add action=mark-routing chain=prerouting connection-mark=pppoe_conn new-routing-mark=to_pppoe passthrough=yes
add action=mark-routing chain=prerouting connection-mark=dhcp_conn new-routing-mark=to_dhcp passthrough=yes

Step 3: Configure NAT Rules

Enable NAT for both WAN connections to allow outgoing internet traffic. 🌍

/ip firewall nat
add action=masquerade chain=srcnat out-interface=pppoe-out1
add action=masquerade chain=srcnat out-interface=ether2

Step 4: Add Routes

Define the routing table for both connections. 🚦

/ip route
add check-gateway=ping distance=1 gateway=pppoe-out1 routing-mark=to_pppoe
add check-gateway=ping distance=1 gateway=ether2 routing-mark=to_dhcp

Validation and Testing

Testing DHCP Server

  1. Connect a device to one of the LAN ports. 📡
  2. Verify that the device receives an IP address from the 192.168.1.0/24 range. ✅
  3. Check the lease table:
/ip dhcp-server lease print

Testing Load Balancer

  1. Generate traffic from multiple devices. 📈
  2. Use the Torch tool in MikroTik to monitor traffic distribution across the two WAN connections.

Benefits of This Configuration

  1. Seamless IP Management: Automatically assigns and manages IP addresses for connected devices. 🌟
  2. Efficient Traffic Distribution: Balances load between two WAN connections, ensuring reliable internet access. 🛠️
  3. Scalability: Easy to expand and integrate additional LAN or WAN connections. 🔧

Conclusion

🌐 This configuration demonstrates how ISPs can leverage MikroTik RouterOS to provide efficient and reliable internet services to their clients. By setting up a DHCP server and implementing load balancing, ISPs can ensure seamless connectivity and optimized resource utilization. 📡

Feel free to implement this setup and share your experiences. For further assistance or custom configurations, reach out to us at Support@technosysonline.com. 📩

Leave a Comment

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

Scroll to Top