80% found this document useful (5 votes)
8K views1 page

3 Wan Load Balancing Script Mikrotik

This document configures IP addresses, DNS, firewall rules, NAT, and static routes on a router with 3 WAN interfaces (ether1, ether2, ether3) and 1 LAN interface (ether5). Connections are marked and routed based on their destination address to balance traffic across the 3 WAN links. DNS and NAT are also configured.

Uploaded by

Eusevjo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
80% found this document useful (5 votes)
8K views1 page

3 Wan Load Balancing Script Mikrotik

This document configures IP addresses, DNS, firewall rules, NAT, and static routes on a router with 3 WAN interfaces (ether1, ether2, ether3) and 1 LAN interface (ether5). Connections are marked and routed based on their destination address to balance traffic across the 3 WAN links. DNS and NAT are also configured.

Uploaded by

Eusevjo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
  • Network Configuration Script

/ip address

add address=[Link]/24 interface=ether1


add address=[Link]/24 interface=ether2
add address=[Link]/24 interface=ether3
add address=[Link]/24 interface=ether5

/ip dns
set allow-remote-requests=yes cache-size=5000KiB max-udp-packet-size=2048
servers=[Link],[Link],[Link]

/ip firewall mangle


add chain=input in-interface=ether1 action=mark-connection new-connection-
mark=WAN1_con
add chain=input in-interface=ether2 action=mark-connection new-connection-
mark=WAN2_con
add chain=input in-interface=ether3 action=mark-connection new-connection-
mark=WAN3_con
add action=mark-routing chain=output connection-mark=WAN1_con new-routing-
mark=to_WAN1
add action=mark-routing chain=output connection-mark=WAN2_con new-routing-
mark=to_WAN2
add action=mark-routing chain=output connection-mark=WAN3_con new-routing-
mark=to_WAN3
add chain=prerouting dst-address=[Link]/24 in-interface=ether5
add chain=prerouting dst-address=[Link]/24 in-interface=ether5
add chain=prerouting dst-address=[Link]/24 in-interface=ether5
add action=mark-connection chain=prerouting dst-address-type=!local hotspot=auth
in-interface=ether5 new-connection-mark=WAN1_con per-connection-classifier=both-
addresses-and-ports:3/1
add action=mark-connection chain=prerouting dst-address-type=!local hotspot=auth
in-interface=ether5 new-connection-mark=WAN2_con per-connection-classifier=both-
addresses-and-ports:3/2
add action=mark-connection chain=prerouting dst-address-type=!local hotspot=auth
in-interface=ether5 new-connection-mark=WAN3_con per-connection-classifier=both-
addresses-and-ports:3/3
add action=mark-routing chain=prerouting connection-mark=WAN1_con in-
interface=ether5 new-routing-mark=to_WAN1
add action=mark-routing chain=prerouting connection-mark=WAN2_con in-
interface=ether5 new-routing-mark=to_WAN2
add action=mark-routing chain=prerouting connection-mark=WAN3_con in-
interface=ether5 new-routing-mark=to_WAN3

/ip firewall nat


add action=masquerade chain=srcnat out-interface=ether1
add action=masquerade chain=srcnat out-interface=ether2
add action=masquerade chain=srcnat out-interface=ether3

/ip route
add check-gateway=ping distance=1 gateway=[Link] routing-mark=to_WAN1
add check-gateway=ping distance=1 gateway=[Link] routing-mark=to_WAN2
add check-gateway=ping distance=1 gateway=[Link] routing-mark=to_WAN3
add check-gateway=ping distance=1 gateway=[Link]
add check-gateway=ping distance=2 gateway=[Link]
add check-gateway=ping distance=3 gateway=[Link]

You might also like