Dear Mikrotik Geeks; Hi! I have a question that maybe many of you know about its answer, but i really could not find it. so i go here for asking it:
Consider we have 2 WAN and 1 LAN Interface in our Mikrotik as the bellow:
Int name Mikrotik IP Address Modem IP
WAN#1 (To-ISP 1): 192.168.1.1/24 -------> 192.168.1.254/24 (Modem PPOE) ISP#1 *(Public IP also Automatically Assigned by DHCP From ISP1)
WAN#2 (To-ISP 2): 192.168.2.1/24 -------> 192.168.2.254/24 (Modem PPOE) ISP#2 *(Public IP also Automatically Assigned by DHCP From ISP2)
LAN :192.168.10.1/24
what we want is to prepare a method for routing through main and backup ISP interface as act Fail-Over Automatically base on specific condition. For example: Set Default route to ISP#1, Check ping “www.yahoo.com”, IF it is not reachable through ISP#1, Then switch default route through the next (ISP#2).
I also read Mikrotik simple fail-over article but it seems that this is not useful much in this case in fact. because check-gateway using ping in this method always answer successfully but maybe without any internet access. also it seems that’s because of all of our IP is internal and we didn’t put any public IP directly in our interface. (if we put public IP, the solution is completely OK)
Thanks for your attention.
Thanks Black VS. Actually i have read it many before. but i couldn’t understand some of lines. i would appreciate if anyone explain me more. These method consist 3 parts the same as bellow:
OK, Consider we want to do check for yahoo.com and google.com so Host1=www.Yahoo.com & Host2=www.google.com. Then we replace these values.
But there is a problem. we are check Host1 using GW1 and Host2 using GW2!
Consider the situation that ping request for Yahoo.com answered successful through ISP1, but google.com throgh ISP2 not!
Let me show it bellow:
| Int1 → (Modem 1) ISP 1 -------> Yahoo ping is OK, Google ping is not!
Mikrotik ----
| Int2 → (Modem 2) ISP 2 -------> Yahoo ping is OK, Google ping is not!
can we conclude that ISP1 is UP and ISP2 is Down at this senario? definitely Not. Because both of them are up now. It seems that we should check Unique conidtion for both GWs (ISPs) not two different. Of course two conditions method is useful more in case of we can define special operator like “AND” for ecah of two GWS. So let’s take it simple for now and use HOST1=HOST2=www.Yahoo.com for test the same condition for both Gateways (GWs).
Also can the scope be something different rather than ‘10’ but equal? does putting it necessary for checking at the same situation too?
Part 2)
Now we create rules for > ISP1> routing mark (one for main gateway, and another one for failover):
/ip route
add distance=1 gateway=> Host1 > routing-mark=ISP1 check-gateway=ping
add distance=2 gateway=> Host2 > routing-mark=ISP1 check-gateway=ping
How can Mikrotik find which out which ISP was used as gateway in case of seting Host1 as gateway?
It seems this part is going to mark outgoing traffic. its really good. but why we didn’t set Host1 as ‘dst-address’ and GW1 as ‘gaeway’ the same as bellow for marking its traffic:
add dst-address=Host1 gateway=GW1 routing-mark=ISP1
Part 3)
Then the same rules for > ISP2> mark:
/ip route
add distance=1 gateway=> Host2 > routing-mark=ISP2 check-gateway=ping
add distance=2 gateway=> Host1 > routing-mark=ISP2 check-gateway=ping
what does it mean changing distance in priority of routing mark? we didn’t change gateway order for marking ISP1 too.
You have misunderstood that article completely.
What is achieved through that method is using an external, not on your network, as gateway through recursive routing. By doing this, you can rely on check gateway by ping to see if gateway is up or not.
Basically, if your gateway is 192.168.1.1, using this method you use as gateway 4.2.2.2