Trying to be as quick as possible here so you don’t have to read ten pages:-
- Two upstream links to two different ISPs
- Dynamic IPs provided to me using DHCP
- A list of remote IP addresses I wish to split connections evenly between the two links (Getting the link with the most available bandwidth would be preferred, but using random 50% is fine too) – currently stored in the address list ‘RandomConnectionIPs’.
My current mangle configuration looks something like this:-
/ip firewall mangle
add action=mark-connection chain=prerouting connection-mark=no-mark connection-state=new dst-address-list="RandomConnectionIPs" log=yes log-prefix=isp1 new-connection-mark=isp1 passthrough=no random=50
add action=mark-connection chain=prerouting connection-mark=no-mark connection-state=new dst-address-list="RandomConnectionIPs" log=yes log-prefix=isp2 new-connection-mark=isp2
add action=mark-routing chain=prerouting connection-mark=isp2 new-routing-mark=isp2
add action=mark-routing chain=prerouting connection-mark=isp1 new-routing-mark=isp1
And routing:-
/ip route
add check-gateway=ping disabled=yes distance=1 gateway=${ISP2Gateway} pref-src=${MyIP2} routing-mark=isp2
add check-gateway=ping disabled=yes distance=1 gateway=${ISP1Gateway} pref-src=${MyIP1} routing-mark=isp1
The issue with this is that I need to constantly update the gateway/preferred source address. I know I could have a script that runs every few minutes and grabs my current gateway/source from
/ip dhcp-client
and set it in
/ip route
, but that seems highly inefficient (and can also result in several minutes worth of downtime if my script ran just before DHCP allocated me a new IP), is there a better way of doing this?
Without the gateway/preferred-source it doesn’t work, haven’t looked much into it, but I have to assume the router is attempting to send it’s local IP as the source to my ISP which then just drops it (The internet doesn’t like 192.168.0.0/16 addresses).