Load balancing after routing table lookup

I’m trying to set up load balancing over two ISPs, but only for those outgoing packets, for which there is no route in a routing table. I can’t find how to apply PCC load balancing after routing table lookup was failed. Any suggestions would be appreciated.

Hi there

the idea is to use a mangle rule where you apply PCC to dst address NOT included in an ip address list containing the destination for which you had already defined a preferred rpute in the routing table.

Example :

if you have already the route for destination 192.168.1.0/24 well, add a new item in the

/ip firewall address-list add address=192.168.1.0/24 comment="already routed " disabled=no list=routed-destinations

and then you will use a mangle rule like this :
add action=mark-connection chain=prerouting comment=“” connection-state=new disabled=no in-interface=ether1 new-connection-mark=ISP_1 passthrough=yes per-connection-classifier=
dst-address:2/0 src-address-type=!local dst-address-list=!routed-destinations

and so on


where you get the goal to not use the PCC balancing with the condition dst-address-list=!routed-destinations


greencomputing

greencomputing, thank you for input. I achieved the same behaviour in a slightly different way. I apply PCC mangle rules to all packets before routing decision stage and then use custom route rules:

/ip firewall mangle
add action=mark-routing chain=prerouting disabled=no \
    in-interface=ether-local new-routing-mark=inet1 passthrough=no per-connection-classifier=\
    both-addresses:2/0
add action=mark-routing chain=prerouting disabled=no in-interface=ether-local \
    new-routing-mark=inet2 passthrough=no per-connection-classifier=both-addresses:2/1

/ip route rule
add action=lookup disabled=no table=main
add action=lookup-only-in-table disabled=no routing-mark=inet2 table=inet2
add action=lookup-only-in-table disabled=no table=inet1

If there is a route for some dst-address in the main routing table, the address will be resolved there and routing-marks will not be taken into account. Otherwise the address will be resolved in the routing table inet1 or inet2 according to its routing-mark.