Community discussions

MikroTik App
 
User avatar
netcomp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jul 08, 2004 5:55 pm

'Smart' FailOver

Mon Nov 29, 2004 5:18 pm

Hi.

I have 2 links to the internet.

My ISP's provided me with public IP addresses. I need a script which will 'smartly' check if first default link is down and switch over all users to second link.

I thought about netwatch, but if I ping my first gateway and I am working with second link, I will have replies because I have public IP's from both ISP's and my gateway has public IP, also I have to switch over to first link if first link is available again. Also if second link doesnt work at all, everybody has to switch to first one.

I would distribute first link to half of my users and second link to other half with routes.
 
edzix
Member
Member
Posts: 333
Joined: Thu Jul 01, 2004 3:01 pm
Location: Latvia

Mon Nov 29, 2004 5:20 pm

 
User avatar
netcomp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jul 08, 2004 5:55 pm

Mon Nov 29, 2004 5:41 pm

You mean at example 'Load-balancing 1' or you ment 'read it/learn how to do it yourself' :)
 
edzix
Member
Member
Posts: 333
Joined: Thu Jul 01, 2004 3:01 pm
Location: Latvia

Mon Nov 29, 2004 7:57 pm

i meant fail over example. There is shown how to accomplish the task you have doubts about.

Edgars
 
User avatar
netcomp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jul 08, 2004 5:55 pm

Tue Nov 30, 2004 12:19 pm

hmmmm,

are you sure that that example will do failover the way I want, be aware that my both ISP's gateways are on public IP's, so if first link fails, it is simple to switch to second, but if you switch to second link that first gateway will be reachable because it is with public IP so link would be switched back to first and forever I will not have internet :(, this is my doubt :( .
 
cmit
Forum Guru
Forum Guru
Posts: 1547
Joined: Fri May 28, 2004 12:49 pm
Location: Germany

Tue Nov 30, 2004 12:24 pm

The "/tool traceroute" command has a parameter "max-hops". Perhaps there is a possibility to check if a "/tool traceroute <your-first-ip> max-hops=1" fails because of "max-hops reached". This would be the case if you "other, first" public ip would be reachable over your second ISP's connection, right?

Just a thought...
 
User avatar
netcomp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jul 08, 2004 5:55 pm

Tue Nov 30, 2004 12:38 pm

hmmm, I like your idea of watching hop numbers, otherwise how can you know if first link is working back?

so now we need just solution :)
 
cmit
Forum Guru
Forum Guru
Posts: 1547
Joined: Fri May 28, 2004 12:49 pm
Location: Germany

Tue Nov 30, 2004 12:44 pm

Perhaps our "human script wizard" Eugene will jump in? :D
 
User avatar
netcomp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jul 08, 2004 5:55 pm

Tue Nov 30, 2004 12:48 pm

I think solution for this problem would be very helpfull to plenty of users, because simple fail-over will work fine if you have private IP's from your ISP but wont for public (real) ones.
 
cmit
Forum Guru
Forum Guru
Posts: 1547
Joined: Fri May 28, 2004 12:49 pm
Location: Germany

Tue Nov 30, 2004 1:00 pm

I don't have an idea right now how to read out the hop count from this command in a script, nor how to catch the error message "max-hops reached"...
Let's see if Eugene is reading this ;)
 
User avatar
Eugene
Forum Veteran
Forum Veteran
Posts: 986
Joined: Mon May 31, 2004 5:06 pm
Location: Cranfield, UK

Tue Nov 30, 2004 5:39 pm

Thank you, Christian, I'm here :)

But I'll share the knowledge in a bit different way. There is no need to use /tool traceroute for this task. The script changes only gateway addresses under /ip route for the default route. Other routes remain unchanged. This way we are assured that ping to the gw1 will always go through the directly connected (DC) route to that gateway, because it has lower metric value, not through the gw2. Just make sure that disable-running-check value for the respective interface is set to yes (the default for ethernet).

Eugene
 
arqesa
just joined
Posts: 2
Joined: Sat Nov 20, 2004 1:32 pm
Location: europe

Tue Nov 30, 2004 10:35 pm

I tried to copy some scripts from MT, in order to get proper loadbalancing with failover, but useless.
Big question, what if I have ping to the gateway, but one of the providers has lost his connection to Internet, how can you do failover.

........

does BGP help in this case, does anyone know how to do BGP with loadbalancing !!??
 
User avatar
netcomp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jul 08, 2004 5:55 pm

Wed Dec 01, 2004 9:59 am

:idea: I got and idea, but honestly it is little bit complicated, but it will work.

So, I got one W2000 machine, I'll put another nic and give it a ip address (throught DHCP or static), then I'll make a smart application which does 'tracert x.x.x.x >file', and then I'll run text check on that file to chek for strings like 'Destination net unreachable.', 'Request timed out.' and simillar, so if that IP is more than thats say 3 hops, then I'll disable second nic card, and in that same time I'll netwatch IP of that second W2000 card, so in case if it is or not reachable (depends on tracert), I'll change gateways.

So cmit, what you think of my idea :P , btw, does anyone knows how to disable nic or change IP's via cmd line on W2000, I'll try with DHCP /release /renew, but I dont know if /release will release IP till next /renew :(, let me try and I'll let you know :P
 
User avatar
netcomp
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 50
Joined: Thu Jul 08, 2004 5:55 pm

Wed Dec 01, 2004 10:27 am

http://support.microsoft.com/kb/311272/EN-US/

heheh, here is answer to my question, devcon.exe

'The DevCon utility is a command line utility that acts as an alternative to Device Manager. Using DevCon, you can enable, disable, restart, update, remove, and query individual devices or groups of devices. DevCon provides information that is relevant to the developer and is not available in Device Manager.'

So, if anyone interested, i'll post my .exe when I finish it ;)
 
DirectWireless
Member Candidate
Member Candidate
Posts: 143
Joined: Wed Oct 06, 2004 8:09 am

Sat Dec 11, 2004 5:31 am

I figured this one out already:

Create these firewall output rules ( sourced from the PING src address (your router, for example)):

src=your router dst=gateway_2_IP out-interface=gateway1 action=deny protocol=icmp

src=your router dst=gateway_1_IP out-interface=gateway2 action=deny protocol=icmp

Do that for both of the interfaces, and when Gateway 1 is down, and gateway 2 comes online, the firewall rule will block gateway 1 from being pinged until gateway 1 comes back online itself. Same with pinging gateway1 from gateway2.

Who is online

Users browsing this forum: No registered users and 7 guests