Hello,
I have a hap ax3 in my country house connected to a 5G router. Due to the inconsistency of the performance of 5G carrier i made a wifi connection with a local wisp.
Wisp connection is 30/30 and is far more reliable. I want to configure ax3 to saturate first the wisp connection and after that to go on on wan2 (5g).
I found this very helpful guide https://mum.mikrotik.com/presentations/US12/tomas.pdf and with help from chatgpt i have the folowing script:
# Interface Setup
/interface ethernet
set [ find default-name=ether1 ] name=wan1
set [ find default-name=ether2 ] name=wan2
set [ find default-name=ether3 ] name=lan
# IP Address Assignment
/ip address
add address=192.168.10.2/24 interface=wan1 comment="WAN1 (ISP1)"
add address=192.168.0.2/24 interface=wan2 comment="WAN2 (ISP2)"
add address=192.168.88.1/24 interface=lan comment="Local Network"
# NAT (Network Address Translation)
/ip firewall nat
add chain=srcnat out-interface=wan1 action=masquerade comment="NAT for WAN1"
add chain=srcnat out-interface=wan2 action=masquerade comment="NAT for WAN2"
# Routing Table Configuration
/ip route
add gateway=192.168.10.1 distance=1 routing-table=main comment="Primary Route through WAN1"
add gateway=192.168.0.1 distance=2 routing-table=main comment="Secondary Route through WAN2"
# Mangle Rules for Load Balancing
/ip firewall mangle
# Mark traffic from LAN for WAN1 or WAN2 based on load
add chain=prerouting connection-mark=no-mark in-interface=lan action=mark-connection new-connection-mark=lan->wan1 passthrough=yes comment="Mark new LAN connections to WAN1"
add chain=prerouting connection-mark=lan->wan1 in-interface=lan action=mark-routing new-routing-mark=to_wan1 passthrough=yes comment="Route marked LAN traffic to WAN1"
add chain=prerouting connection-mark=no-mark in-interface=lan action=mark-connection new-connection-mark=lan->wan2 passthrough=yes comment="Mark new LAN connections to WAN2"
add chain=prerouting connection-mark=lan->wan2 in-interface=lan action=mark-routing new-routing-mark=to_wan2 passthrough=yes comment="Route marked LAN traffic to WAN2"
# Mark Sticky Connections (Ensuring established connections stick to their WAN)
/ip firewall mangle
add chain=prerouting connection-mark=lan->wan1 routing-mark=to_wan1 action=mark-connection new-connection-mark=sticky_wan1 passthrough=no
add chain=prerouting connection-mark=lan->wan2 routing-mark=to_wan2 action=mark-connection new-connection-mark=sticky_wan2 passthrough=no
add chain=prerouting connection-mark=sticky_wan1 in-interface=lan action=mark-routing new-routing-mark=to_wan1 passthrough=yes
add chain=prerouting connection-mark=sticky_wan2 in-interface=lan action=mark-routing new-routing-mark=to_wan2 passthrough=yes
# Load Balancing based on Bandwidth
# Ensure traffic uses WAN1 until it hits the 27Mbps limit, then shifts to WAN2
/tool traffic-monitor add interface=wan1 name=wan1-monitor traffic=received threshold=27000000 trigger=above
/tool traffic-monitor add interface=wan1 name=wan1-monitor-down traffic=received threshold=25000000 trigger=below
# Script to shift traffic to WAN2 when WAN1 exceeds bandwidth limit
/system script add name=shift-to-wan2 source={
:log info "Shifting traffic to WAN2 due to high load on WAN1";
/ip route disable [find where gateway=192.168.10.1];
/ip route enable [find where gateway=192.168.0.1];
}
/system script add name=shift-to-wan1 source={
:log info "Shifting traffic back to WAN1";
/ip route enable [find where gateway=192.168.10.1];
/ip route disable [find where gateway=192.168.0.1];
}
# Traffic Monitor Events
/tool traffic-monitor set wan1-monitor on-event=shift-to-wan2
/tool traffic-monitor set wan1-monitor-down on-event=shift-to-wan1
# Failover Configuration (Using Netwatch to check the status of gateways)
/tool netwatch add host=192.168.10.1 down-script="/ip route disable [find where gateway=192.168.10.1]" up-script="/ip route enable [find where gateway=192.168.10.1]"
/tool netwatch add host=192.168.0.1 down-script="/ip route disable [find where gateway=192.168.0.1]" up-script="/ip route enable [find where gateway=192.168.0.1]"
# DHCP Client for WAN Interfaces
/ip dhcp-client
add interface=wan1 comment="DHCP Client for WAN1"
add interface=wan2 comment="DHCP Client for WAN2"
Due to remote location of the country house i cannot test it. Can anyone tell me if this script is up to date to v7.16 ROS ?
Thanks in advance