Hello!
I have the following scenario. The problem is on RouterOS v7.x. The model does not affect. Also tried in different location with different ISPs - no change.
Mikrotik, acting as the gateway for local users. It has two ISPs connected:
ether1_WAN - connected to ISP1 gateway with local address 10.110.110.11 (ISP1 local address is 10.110.110.10, and has public IP for access from the internet, 22 and 8728 ports are forwarded to 10.110.110.10).
ether5_WAN_reserve - connected to ISP2 gateway and has Public IP for access from the internet.
I have configured two default routes in main routing table:
- 0.0.0.0/0 via 10.110.110.10 with distance 1
- 0.0.0.0/0 via <ISP2_gateway> with distance 2
I’ve created two additional routing tables for each of the ISPs:
- PBR-to-ISP1
- PBR-to-ISP2
Then I’ve configured two default routes for each of the additional routing tables:
- 0.0.0.0/0 via 10.110.110.10 with distance 1 in PBR-to-ISP1 table
- 0.0.0.0/0 via <ISP2_gateway> with distance 1 in PBR-to-ISP2 table
Then I’ve configured the following mangle rules:
[admin@MikroTik] > ip firewall mangle print detail
Flags: X - disabled, I - invalid; D - dynamic
0 chain=input action=mark-connection new-connection-mark=ISP1-conn passthrough=yes in-interface=ether1_WAN
1 chain=input action=mark-connection new-connection-mark=ISP2-conn passthrough=yes in-interface=ether5_WAN_reserve
2 chain=output action=mark-routing new-routing-mark=PBR-to-ISP1 passthrough=yes connection-mark=ISP1-conn
3 chain=output action=mark-routing new-routing-mark=PBR-to-ISP2 passthrough=yes connection-mark=ISP2-conn
Now I have the opportunity to route traffic from certain local subnets to certain ISP using prerouting rules, as an exemple:
;;; bridge10_test_default_ISP
chain=prerouting action=mark-routing new-routing-mark=PBR-to-ISP1 passthrough=yes dst-address-type=!local in-interface=bridge10_test
And it works fine, but my issue is not linked to the local subnets, it is linked to an access to my router.
I need to connect to the router via ssh (port 22) and api (port 8728) periodiacly. In 90% times I can successfully connect to the router using both the ISP1 router address and ISP2 router address. But sometimes, I noticed that the connection is timed out either on port 22 or 8728 on both ISPs simultaneously.
I’ve started to troubleshoot this issue and implemented the monitoring of ports 22 and 8728 on both WAN interfaces of the router. Every 20 sec my monitor tries to establish 4 TCP connections using:
- ISP1 ip address and port 22
- ISP1 ip address and port 8728
- ISP2 ip address and port 22
- ISP2 ip address and port 8728
My monitor software is located in other network and I connect via Internet.
And the following problem has been detected. In a random moment my router doesn’t answer from either 22 or 8728 port. It is continuing for 2-3 times. It is 40-60 sec. And when it happens, I cannot connect using 22 port even from other host in the internet on both ISP IP addresses, while 8728 is responding on both ISP IP addresses and vice versa. Very rarely, but the problem is on both ports, just a random.
It happens several times in an hour for each port.
Current connections are not broken, the problem is only for new connections.
I’ve sniffed packets on all interfaces while the problem appearing. In the dump I see, that my monitor host tries to connect sending TCP SYN packet to mikrotik. Mikrotik receives it, but does not respond. After that I see several SYN Retries from monitor host and again, no respond from Mikrotik.
If I look in Connections table of the router, the TCP state of theese connections are “syn sent”. But actually the router does not even try to respond. There are no any respond packets from the router at all.
In 40-60 secons the problem is gone and the router starts to answer normally. It’s strange for me!
If I disconnect the cable from ether1_WAN or ehter5_WAN_reserve of the router, then the remaining uplink is working fine and there is no problem.
I’ve also tried to do this scenario without mangle rules but with routing rules and has still the same problem.
Can this be a bug or not? Maybe I should configure something else? But it seems to be a bug because the router does not even try to send and answer but marks tcp state of connection as “syn sent”.
Mikrotik experts, please help me…