So in general, you have to configure both houses' routers the same way as described here. The critical point is to avoid application of the load distribution rules on connections initiated by packets coming from the other house; these packets must always be sent out via local WAN.I take advantage of the two gateways by configuring the routes directly on the laptop
I do not have routers on the second home is all a single lan , in the second home I added a LTE gateway that provides only a static ip.You have provided only configuration from one of the houses plus I don't understand the remarkSo in general, you have to configure both houses' routers the same way as described here. The critical point is to avoid application of the load distribution rules on connections initiated by packets coming from the other house; these packets must always be sent out via local WAN.I take advantage of the two gateways by configuring the routes directly on the laptop
Sorry, I've missed that. So actually the only interface of the router in house 1 which hosts the 192.168.8.0/24 subnet is ether5, and when you connect a laptop to that router, the laptop gets its IP address from some other subnet associated to bridge, right? And when the laptop is connected in house1, those routes on it which it uses for load balancing when connected in house2 (I still don't know how that should be working unless it is a linux laptop) are replaced by a default route to Mikrotik's IP address associated to bridge1?
If the above is correct, what exactly does not work?
OK, I wasn't sure so I wanted to avoid doubt.
- There are two computers; one laptop in house 1 and another laptop in house 2.
That's not a big surprise as from the perspective of the Mikrotik, packets from the laptop to the LTE gateway are forwarded ones, so the way your mangle rules are currently set, the PCC handling affects these packets too. I haven't found a way how to check how the both-addresses-and-ports hash treats icmp packets - as there is no port in icmp, unless the hash includes the icmp id instead of one of the ports in the calculation, you may end up marking all packets for 192.168.8.1 coming from the address of your laptop for getting routed via pppoe-out1. You can check whether it is the case by swapping the current mapping of the remainder value to connection-mark in the two rules (i.e. by making packets with reminder 0 be connection-marked with WAN2_conn and packets with reminder 1 with WAN1_conn).
- From the laptop in the house 1 the ping test on the gateway LTE 192.168.8.1 does not work even if I assigned static ip.
If I do the ping test directly from the RB3011 on the LTE gateway it works instead.
It's not a problem, it's the goal and it was clear, so I wanted to know what are the actual problems which prevent achieving of this goal
- The problem is that I would like to combine the two gateways to achieve load balancing and failover without using static routes on laptops.
Where exactly in the second house? On the laptop which lives there? I suppose that if its gateway is the 192.168.8.1, it uses the LTE box, and if the gateway is 192.168.8.2, it uses the PPPoE via the MikrotikIn the second house there is always the gateway with only the static ip and the access to the whole LAN works normally.
This way, the route with distance=2 is only used if the other one (with default value of distance which is 1) is down; it can happen that the gateway of the higher priority route is pingable but you cannot get anywhere further through it so it is not a good approach. Plus, in your case, 10.0.0.1 is in the LAN subnet, so it cannot be a gateway; a gateway must be either the pppoe-out1 itself as an interface or, better if possible, the remote address indicated by the PPPoE server because in such case you can use the recursive next-hop search to track the link state all the way to the Internet.I tried doing so:
/ip route add gateway=10.0.0.1 check-gateway=ping
/ip route add gateway=192.168.8.1 distance=2
This is what happens if you don't post the complete configuration You've only posted part of the firewall configuration but it wasn't clear from the posting, and in some other similar topics someone has stated he had no firewall at all and I have mixed the two together, concluding that firewall cannot be what prevents the load distribution in your case.but there is something in the firewall that prevents you from reaching the LTE gateway.
I did so:Please add in-interface=bridge to the rule action=accept chain=forward comment="accetta pacchetti che usano LTE come gateway" out-interface=bridge to improve security. Your setup is so unusual that I haven't realized immediately that this condition should be there. It's not a big deal that it was missing for a while as there's NAT on the pppoe-out1, otherwise it would have been a serious security hole.
/ip firewall mangle
add chain=input in-interface=pppoe-out1 action=mark-connection new-connection-mark=WAN1_conn
add chain=input src-address=192.168.8.1 action=mark-connection new-connection-mark=WAN2_conn
add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2
add chain=prerouting dst-address=192.168.8.0/24 action=accept src-address=192.168.8.1
add chain=prerouting dst-address-type=!local in-interface=bridge per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection new-connection-mark=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=bridge per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection new-connection-mark=WAN2_conn passthrough=yes
add chain=prerouting connection-mark=WAN1_conn in-interface=bridge action=mark-routing new-routing-mark=to_WAN1
add chain=prerouting connection-mark=WAN2_conn in-interface=bridge action=mark-routing new-routing-mark=to_WAN2
/ip route
add dst-address=0.0.0.0/0 gateway=pppoe-out1 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.8.1 routing-mark=to_WAN2 check-gateway=ping
/ip firewall nat
add chain=srcnat dst-address=192.168.8.1 action=masquerade
The reason is again the fact that you use the unusual network setup with two subnets on the same interface but your firewall rules are copied from a setup which relies on interface name as an unambiguous information about packet source. So what actually happens is that you assign a routing-mark also to packets coming from the LTE gateway and destined to your LAN devices, which makes them use the default route with that routing-mark because the routing-mark wins over the fact that the destination address is in a locally present subnet.This morning I was convinced I could finally get the load balancing instead as soon as I add the rules below the lan freezes.
You are another victim of a common misconception. The packets which come from the internet via the LTE gateway do not have the LTE gateway's IP address as source one. They keep the actual IP address of the remote sender. So to identify such packets, you have to use a different set of conditions in that rule, such as in-interface=bridge src-address=!10.0.0.0/24.I thought that having a gateway on the bridge, it was enough to replace in-interface=ether5 with src-address=192.168.8.1 instead the issue is more complex.
You can use DHCP to force a specific configuration to a specific host, but it is not possible to force a gateway from some subnet to a device which doesn't have an IP address from that same subnet. So a device which has only an address from 10.0.0.0/24 cannot be given a gateway from 192.168.8.0/24.Also, can you, via DHCP server, force the use of the LTE gateway to a certain host?
/ip route
add dst-address=0.0.0.0/0 gateway=pppoe-out1 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.8.1 routing-mark=to_WAN2 check-gateway=ping
I do not understand what you mean by,you can explain better?you must srcnat traffic going to gateways, it's easy for gateways with master interface.
no does not work.If you modify that /ip route rule to deal with dst-address=10.0.0.0/24 and enable the two routes with routing-marks again, does it work or not?
Unfortunately you haven'tI hope I have fully understood what needs to be done.
/ip firewall nat print
Flags: X - disabled, I - invalid, D - dynamic
0 ;;; defconf: masquerade
chain=srcnat action=masquerade out-interface-list=WAN ipsec-policy=out,none
1 chain=srcnat action=masquerade out-interface=pppoe-out1
2 chain=srcnat action=src-nat to-addresses=192.168.8.2 src-address=192.168.8.0/24 dst-address=!10.0.0.0/24 out-interface=bridge log=no log-prefix=""
3 chain=srcnat action=src-nat to-addresses=192.168.8.2 src-address=10.0.0.0/24 dst-address=!10.0.0.0/24 out-interface=bridge log=no log-prefix=""
/ip firewall filter
add chain=forward action=fasttrack-connection connection-state=established,related connection-mark=!WAN2_conn log=no log-prefix="" comment="defconf: fasttrack"
add chain=forward action=accept in-interface=bridge out-interface=bridge log=no log-prefix="" comment="accetta pacchetti che usano LTE come gateway"
add chain=forward action=drop
/ip firewall nat
add chain=srcnat action=src-nat to-addresses=192.168.8.2 src-address=10.0.0.0/24 dst-address=!10.0.0.0/24 out-interface=bridge log=no log-prefix=""
/ip firewall mangle
add chain=input action=mark-connection new-connection-mark=WAN1_conn connection-mark=no-mark in-interface=pppoe-out1 comment="PCC for LTE"
add chain=input action=mark-connection new-connection-mark=WAN2_conn src-address=!10.0.0.0/24 connection-mark=no-mark in-interface=bridge
add chain=output action=mark-routing new-routing-mark=to_WAN1 connection-mark=WAN1_conn
add chain=output action=mark-routing new-routing-mark=to_WAN2 connection-mark=WAN2_conn
add chain=prerouting action=mark-connection new-connection-mark=WAN1_conn passthrough=yes dst-address-type=!local connection-mark=no-mark in-interface=bridge per-connection-classifier=both-addresses-and-ports:2/0
add chain=prerouting action=mark-connection new-connection-mark=WAN2_conn passthrough=yes dst-address-type=!local connection-mark=no-mark in-interface=bridge per-connection-classifier=both-addresses-and-ports:2/1
add chain=prerouting action=mark-routing new-routing-mark=to_WAN1 passthrough=yes connection-mark=WAN1_conn in-interface=bridge
add chain=prerouting action=mark-routing new-routing-mark=to_WAN2 passthrough=yes connection-mark=WAN2_conn in-interface=bridge log=no log-prefix=""
/ip route
add dst-address=0.0.0.0/0 gateway=pppoe-out1 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.8.1 routing-mark=to_WAN2 check-gateway=ping
/ip route rule:
add action=lookup-only-in-table table=main dst-address=10.0.0.0/24
add action=lookup-only-in-table table=main dst-address=192.168.8.0/24
I eliminated src-address=192.168.8.0/24 it at least remains as a summary , for those in the future looking for help .The first src-nat rule in the list above (the one with src-address=192.168.8.0/24) seems unnecessary to me