Round-robin load balancing - 2 interfaces with dynamic IP

I want to achieve equal distribution between two PPP client interfaces with dynamically assigned IPs.
The purpose is to achieve:

  1. Double the bandwidth available for clients
  2. Failover in case one of the connections go down

I have the following setup:

/port
set 0 baud-rate=auto data-bits=8 flow-control=none name=serial0 parity=none \
    stop-bits=1
set 1 baud-rate=9600 data-bits=8 flow-control=none name=usb2 parity=none \
    stop-bits=1
set 2 baud-rate=9600 data-bits=8 flow-control=none name=usb3 parity=none \
    stop-bits=1


Flags: I - inactive 
 #   NAME                      CHANNELS   USED-BY                     BAUD-RATE
 0   serial0                   1          Serial Console              auto     
 1   usb2                      3          PPP <ppp-out1>              9600     
 2   usb3                      2          PPP <ppp-out2>              9600     


/interface ppp-client
add add-default-route=no allow=pap,chap,mschap1,mschap2 command-channel=0 \
    comment="" data-channel=0 dial-command="ATDT phone=*99***1#" \
    dial-on-demand=no disabled=no info-channel=0 max-mru=1500 max-mtu=1500 \
    modem-init=at&f mrru=disabled name=ppp-out1 null-modem=no password=cdma \
    phone="" port=usb2 profile=default use-peer-dns=no user=cdma
add add-default-route=no allow=pap,chap,mschap1,mschap2 command-channel=0 \
    comment="" data-channel=0 dial-command="ATDT phone=*99***1#" \
    dial-on-demand=no disabled=no info-channel=0 max-mru=1500 max-mtu=1500 \
    modem-init="AT+CGDCONT=1,\"IP\",\"internet\"" mrru=disabled name=ppp-out2 \
    null-modem=no password="" phone="" port=usb3 profile=default \
    use-peer-dns=no user=""

/ip firewall mangle
add action=mark-connection chain=prerouting comment=\
    "Mark every 2. new connection for PPP1" connection-state=new disabled=no \
    in-interface=ether1 new-connection-mark=ConnPPP1 nth=2,1 passthrough=yes
add action=mark-routing chain=prerouting comment=\
    "Mark all packets in conn ConnPPP1 with routing mark RoutingPPP1" \
    connection-mark=ConnPPP1 disabled=no in-interface=ether1 \
    new-routing-mark=RoutingPPP1 passthrough=no
add action=mark-connection chain=prerouting comment=\
    "Mark the rest of new connections for PPP2" connection-state=new \
    disabled=no in-interface=ether1 new-connection-mark=ConnPPP2 nth=2,2 \
    passthrough=yes
add action=mark-routing chain=prerouting comment=\
    "Mark all packets in conn ConnPPP2 with routing mark RoutingPPP2" \
    connection-mark=ConnPPP2 disabled=no in-interface=ether1 \
    new-routing-mark=RoutingPPP2 passthrough=no

/ip route
add comment="" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=ppp-out1
add check-gateway=ping comment="" disabled=no distance=1 dst-address=\
    0.0.0.0/0 gateway=ppp-out2 routing-mark=RoutingPPP2
add check-gateway=ping comment="" disabled=no distance=1 dst-address=\
    0.0.0.0/0 gateway=ppp-out1 routing-mark=RoutingPPP1

Flags: X - disabled, A - active, D - dynamic, 
C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, 
B - blackhole, U - unreachable, P - prohibit 
 #      DST-ADDRESS        PREF-SRC        G GATEWAY              DISTANCE IN..
 0 A S  0.0.0.0/0                          r ppp-out1             1        pp..
 1 A S  0.0.0.0/0                          r ppp-out2             1        pp..
 2 A S  0.0.0.0/0                          r ppp-out1             1        pp..
 3 ADC  10.0.0.0/24        10.0.0.1                               0        et..
 4 ADC  10.112.112.125/32  77.16.84.54                            0        pp..
 5 ADC  10.112.112.132/32  91.149.48.53                           0        pp..

As can be seen, every second new connection is connmarked for ConnPPP1 and ConnPPP2, respectively.
Then all packets belonging to these connmarked connections are assigned routing marks.

In my routing table I have 2 entries for 0.0.0.0/0, dealing with the routing marked packets.
In addition I have defined two routing entries, without routing marks, assuming they will take care of the packets from the router itself. When disabling one of the PPP clients, the associated route becomes blue.
I don’t need round-robin on this router-originated traffic, it’s okay to always use #1 and then just switch to #2 in case #1 fails. I think I have achieved this.

My question is: What happens with the packets routing-marked “RoutingPPP1” in case interface PPP-Out1 goes down? Will the packets be lost, and then retransmitted over the other gateway?

Because gateway addresses are unknown, my first two routes are specified to use a certain interface, not address. I assume for this reason they cannot be pinged? At least the routes don’t turn blue when disabling the associated interface.

So what is the correct way of doing this?
Demands:
-nth distribution (round-robin) of traffic through router
-any interface used for router originated traffic
-failover for all traffic

add

/ip route
add check-gateway=ping comment="" disabled=no distance=10 dst-address=\
    0.0.0.0/0 gateway=ppp-out1 routing-mark=RoutingPPP2
add check-gateway=ping comment="" disabled=no distance=10 dst-address=\
    0.0.0.0/0 gateway=ppp-out2 routing-mark=RoutingPPP1

So what you recommend is that I create another pair of routes with higher path cost, directing the connmarked packets to the opposite interface in case the first one is not available, right?
Sounds reasonable! :smiley:

But can I be certain that if the interface with the lowest path cost is disabled, the router will not try to push the packet there? How “does it know” that the interface is not up and running, I mean, does check-gateway=ping work if I’m routing to interface and not to IP address?
Will the router then ping the interface’s dynamically assigned IP address? The route does not turn blue-colored even if I disable the interface.

Anyone that can comment on this?

How did you get the second USB device to show in your ports list?

I have 2 x USB devices that independently both work as USB2, however when i have them both connected the ports list only shows:

 #   NAME                      CHANNELS   USED-BY                     BAUD-RATE
 0   serial0                   1          Serial Console              9600     
 1   usb2                      3          PPP <ppp-out2>              9600

Yet the USB list shows both are recognised…

 # DEVICE VENDOR                   NAME                  SPEED                 
 0 4:1                             OHCI Host Controller  12 Mbps               
 1 3:1                             OHCI Host Controller  12 Mbps               
 2 2:1                             OHCI Host Controller  12 Mbps               
 3 1:1                             EHCI Host Controller  480 Mbps              
 4 1:11   HUAWEI Technology        HUAWEI Mobile         480 Mbps              
 5 2:5    \FF\FF\FF\FF\FF\FF\FF... HUAWEI Mobile         12 Mbps

Any help would be awsome!

I don’t know, they always show up with their own USB port.
Try to upgrade to lastest version of ROS, reset config and start over again.

Thanks,

Tried that. Have a new RB on the way will try on that and if it still doesn’t work might have to log it with support.
Cheers.