*....
- *Policy routing everything coming in a certain interface, to the Router itself, to go out the same (connection-mark @ input, routing mark @ output)
....
/ip firewall mangle
add action=mark-connection chain=input connection-state=new in-interface=ADSL2 new-connection-mark=ADSL2Con2R passthrough=yes
add action=mark-connection chain=input connection-state=new in-interface=ADSL1 new-connection-mark=ADSL1Con2R passthrough=yes
add action=mark-routing chain=output connection-mark=ADSL2Con2R new-routing-mark=ToADSL2 passthrough=yes
add action=mark-routing chain=output connection-mark=ADSL1Con2R new-routing-mark=ToADSL1 passthrough=yes
This means: mangle policy route them over one of the ADSLs.ECMP does exactly what it is supposed to do. Maybe the Wiki article needs to have more warnings that you have to understand protocols better. The real problem is up at Layer 7 where applications make assumptions about source IP addresses which are incongruent with IP networking. As a network engineer, it's your job to reconcile the lower layers of IP with the applications using it. I know none of that helps you, so here are some comments which might help.
...
Two, SMTP connections should not be affected in their basic form. The process of sending a message to an MTA should be a single TCP connection on port 25. When I say single connection I mean atomic for at least one whole email message. Now you may run into a problem with SPF or reverse DNS but given that you are a dynamic public IP, you pretty much can't use SPF and the reverse DNS is never going to point to your MX. You should sniff the outbound traffic during a failure case and confirm that an SMTP session with a server stays on a single interface until the TCP session is closed. Note that the very next SMTP session to the same or to a different server can go out either ECMP route.
Three, PPTP is composed of two IP sessions, a TCP session on port 1723 for session control and encapsulated data in using the GRE protocol. You have to keep these on the same outbound interface using policy routing to get PPTP to work. You could try setting up a different type of tunneling which uses a single IP session or is session-less.
So I have followed along with this thread in hopes of making this work. I have most functionality setup as you guys do with a few odd instances.
Hosted services behind the network do not always get connections.
i.e. stmp, imap and ssh sessions forwarded to hosts behind the nat are very sparadic in accepting the connections. When I do get replys and attempt to auth ssh authenticates but seems to not know how to get back to me from internet. Sometimes is does but then times out after a few minutes and drops me.
All connection attempts are on the same ADSL interface and public IP.
I have this setup with 2 PPPOE connections over bridged modems. They are different providers with different public addresses and networks.
Outbound connections work well and get balanced okay with a few nuances. i.e sip traffic is confused from asterisk box. Will probably force this over one route with routing marks but then lose failover. I need to look at sip_nat.conf and see if I can setup both public addresses with success.
Should this setup give me persistent connections? And if so is there a time out? I have adjusted the Generic Timeout in the Firewall Connection Tracking with no success. I need to sniff the packets abit but iTunes and online gaming sessions get dropped after about 10 mins and have to be restarted.
RB433 ROS 3.20
/ip route
add check-gateway=arp comment="Route All ToADSL1" disabled=no distance=1 \
dst-address=0.0.0.0/0 gateway=ADSL1 routing-mark=ToADSL1
add check-gateway=ping comment="" disabled=yes distance=1 dst-address=\
0.0.0.0/0 gateway=ADSL1,ADSL2
add check-gateway=arp comment="Route All ToADSL2" disabled=no distance=1 \
dst-address=0.0.0.0/0 gateway=ADSL2 routing-mark=ToADSL2
add check-gateway=arp comment="ECMP Test - BAD" disabled=no distance=1 \
dst-address=0.0.0.0/0 gateway=ADSL1,ADSL2
add check-gateway=arp comment="Route All Else to ADSL1" disabled=no distance=\
2 dst-address=0.0.0.0/0 gateway=ADSL1
/ip firewall nat
add action=masquerade chain=srcnat comment="" disabled=no out-interface=ADSL1
add action=masquerade chain=srcnat comment="" disabled=no out-interface=ADSL2
add action=dst-nat chain=dstnat comment="" disabled=no dst-port=22 \
in-interface=ADSL1 protocol=tcp to-addresses=xx.xx.xx.21 to-ports=22
add action=dst-nat chain=dstnat comment="" disabled=no dst-port=25 \
in-interface=ADSL1 protocol=tcp to-addresses=xx.xx.xx.21 to-ports=25
add action=dst-nat chain=dstnat comment="" disabled=no dst-port=80 \
in-interface=ADSL1 protocol=tcp to-addresses=xx.xx.xx.21 to-ports=80
add action=dst-nat chain=dstnat comment="" disabled=no dst-port=443 \
in-interface=ADSL1 protocol=tcp to-addresses=xx.xx.xx.21 to-ports=443
add action=dst-nat chain=dstnat comment="" disabled=no dst-port=587 \
in-interface=ADSL1 protocol=tcp to-addresses=xx.xx.xx.21 to-ports=587
add action=dst-nat chain=dstnat comment="" disabled=no dst-port=993 \
in-interface=ADSL1 protocol=tcp to-addresses=xx.xx.xx.21 to-ports=993
add action=dst-nat chain=dstnat comment="" disabled=no dst-port=5004-5037 \
in-interface=ADSL1 protocol=udp to-addresses=xx.xx.xx.7 to-ports=\
5004-5037
add action=dst-nat chain=dstnat comment="" disabled=no dst-port=5039-5082 \
in-interface=ADSL1 protocol=udp to-addresses=xx.xx.xx.7 to-ports=\
5039-5082
add action=dst-nat chain=dstnat comment="" disabled=no dst-port=10000-20000 \
in-interface=ADSL1 protocol=udp to-addresses=xx.xx.xx.7 to-ports=\
10000-20000
/ip firewall mangle
add action=mark-connection chain=input comment=\
"Policy Routing All connections from ADSL1 to Router back to ADSL1" \
connection-state=new disabled=no in-interface=ADSL1 new-connection-mark=\
ADSL1Con2R passthrough=yes
add action=mark-routing chain=output comment="" connection-mark=ADSL1Con2R \
disabled=no new-routing-mark=ToADSL1 passthrough=yes
add action=mark-connection chain=input comment=\
"Policy Routing All connections from ADSL2 to Router back to ADSL2" \
connection-state=new disabled=no in-interface=ADSL2 new-connection-mark=\
ADSL2Con2R passthrough=yes
add action=mark-routing chain=output comment="" connection-mark=ADSL2Con2R \
disabled=no new-routing-mark=ToADSL2 passthrough=yes
I have also added the following rule in to see if it drops the connection for iTunes and such and either way the apps still disconnect. And of course If I disable ADSL2 pppoe connection everything works just fine.
/ip firewall filter
add action=drop chain=forward connection-state=invalid
So Policy Route them tooUpdate:: I have verified with torch that the forwarded packets coming in ADSL1 from internet through nat are at times getting routed back through ADSL2.
DA dl-ing from same server or different mirrors!??I have followed the same tutorial and was pretty excited that it got updated as the old one seemed to be broken.
My 2 links that I am trying to load balance are a 1.5M T1 and a 3M DSL. I understand that adding the 3M pipe in under gateway=WAN1,WAN2,WAN2 will force the router to make multiple use of that particular gateway to "weight" the higher throughput of the DSL line.
I have also implemented the same configuration with the suggested changes. and am seeing pretty much the same problems as what knects is seeing. When I used a Download Accelerator I see pretty close to the 4.5M of traffic that would be expected. As well as when I do an update in Debian.
Problem is probably due to the broken applications using multiple connections, some TCP some UDP some to different servers. Please Policy Route them correctly! over one of the links and Please report back here. Thank you.However, my project based Webserver and email server seem to sporadically miss connections. As if I am using some sort of round-robin bonding without the other side being bonded. itunes and Zune Market place seem to also break and can stay sometimes connected for as little as 10 minutes, but as much as 1 hour. Everquest and WoW suffer from this as well and are playable for a short time, but then drop. It appears as if at some point the router just stiops following the routing marks.
I also still see the original of HTTPS, SSH and SMTP failing as indicated by the very first post and the very last post.
Does anybody have any idea or is this supposed to just be a port 80 only load balancer? No point posting the config as they probably all look the same. Someone Please help?
Otherwise I am thinking of using my overly priced Edimax BR724 Load Balancer.
Please Help I am desperate.
Preston
Can you view the connection log of the download program? Maybe there is a reconnect and resume, that is not obvious, unless you peek in the transfer log? So you tried this with what programs/browser/downloaders and what files did you download? Usually I test with Linux distribs ISO files. If you feel it will help, you could post a screenshot or two.Ok, so policy routing has taken care of most issues but am still having problems with connections. Long file transfers via http, sftp, scp or ftp time out. If I use clients such as transmission or such they seem to work just fine. Downloading large files will time out after a period of time. This has happened from various hosts and servers. Seems to be random as to time or amount transfered. Files are > 500MB. Any ideas?
Please try to play around with Gateway Distance. When RouterOS detects a gateway is not active due to interface beind down, it will route right away to the next active gateway with the next distance.Dear All,
Currently I use mikrotik RB450 with OS 3.22. I have been struggling to figure it out how to have load balancing and fail over. is anyone in this forum has a script that run on this router?
I create fail over with load balancing just like in the wiki.
The problem is, when i unplug my ISP cable, the traffic can not find another gateway.
for example with ping applicatuion from client PC with option -t
ex: ping http://www.linux.org -t
if i unplug one of the ISP gateway cable, I got time out.. but It could NOT get reply again.
I had to close the cmd window and do type ping , than i get reply using another gateway.
I really need a script that run smoothly, that can rediret trafic to another gateway.
Thanks in advance.
Best Regards
1: The ICMP connection is already established and is managed by ConnectionTracking mechanisms of RouterOS. Because of this, it must be disconnected and re-established for it to go the working gateway. This is why refreshing the browser works - it makes new tcp connections.There is a little problem, when I use 'ping' application, using -t parameters, and i unpluged the isp gateway cable, I got 'request time out' and after i wait for several minutes i didn't get reply.. ( I still got time out ) It couldn't find another gateway. 1
But, if I using the connection to browse internet, after i unpluged one ISP gateway cable, after doing refresh on the browser, i still able to reach the web address.
is this the correct result of this 'ECMP and failover' script?
is this script realy doing/working to perform load balancing?
Thanks in advance for you all.
Best Regards
Just FYI, I've tried 4.0b2 (which supposedly has 3.22 bug fixes in it) and I've still got my ECMP download problem.I've not tried 3.22 yet, but large file downloads stop after 10-20 minutes of downloading. Like knects, pausing and unpausing the download causes it to start going again. I also have problems with long ssh sessions being open.
Anyone out there with a 433 that has ECMP working?
/ip firewall mangle
add action=mark-connection chain=prerouting comment= Inet_1 connection-state=new disabled=no in-interface=ether3 new-connection-mark= Inet_1 nth=3,1 passthrough= yes
add action=mark-routing chain=prerouting comment="" connection-mark=Inet_1 disabled=no in-interface=ether3 new-routing-mark= Inet_1 passthrough=no
….
/ip address
add address=192.168.28.2/24 broadcast=192.168.28.255 comment=Inet_Modem_1 disabled=no interface=ether1 network=192.168.28.0
add address=192.168.1.3/24 broadcast=192.168.1.255 comment=Inet_Modem_2 disabled=no interface=ether2 network=192.168.1.0
add address=172.168.0.1/24 broadcast=172.168.0.255 comment=Output disabled=no interface=ether3 network=172.168.0.0
/ip firewall mangle
add action=mark-connection chain=prerouting comment="ICMP Redirect" disabled=no new-connection-mark=ICMP passthrough=yes protocol=icmp src-address= 172.168.0.0/24
add action=mark-packet chain=prerouting comment="" connection-mark=ICMP disabled=no new-packet-mark=ICMP passthrough=yes protocol=icmp src-address=172.168.0.0/24
add action=mark-routing chain=prerouting comment="" connection-mark=ICMP disabled=no new-routing-mark=ICMP packet-mark=ICMP passthrough=no protocol=icmp src-address=172.168.0.0/24
add action=mark-connection chain=input comment= Inet_1 connection-state=new disabled=no in-interface= ether1 new-connection-mark= Inet_1 passthrough=yes
add action=mark-routing chain=output comment="" connection-mark= Inet_1 disabled=no new-routing-mark= Inet_1 passthrough=yes
add action=mark-connection chain=input comment= Inet_2 connection-state=new disabled=no in-interface=ether2 new-connection-mark= Inet_2 passthrough=yes
add action=mark-routing chain=output comment="" connection-mark= Inet_2 disabled=no new-routing-mark= Inet_2 passthrough=yes
/ip firewall nat
add action=masquerade chain=srcnat comment="ICMP Redirect" connection-mark= ICMP disabled=no src-address=172.168.0.0/24
add action=masquerade chain=srcnat comment="L B 2" disabled=no out-interface= ether3
add action=masquerade chain=srcnat comment="" disabled=no out-interface=ether2
add action=masquerade chain=srcnat comment="L B 2" disabled=no src-address=172.168.0.0/24
/ip route
add check-gateway=arp comment="ICMP Redirect" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.1.1 routing-mark=ICMP scope=30 target-scope=10
add check-gateway=arp comment="LB 2" disabled=yes distance=2 dst-address=0.0.0.0/0 gateway=192.168.28.1,192.168.28.1,192.168.1.1 scope=30 target-scope=10
add check-gateway=arp comment="" disabled=yes distance=1 dst-address=0.0.0.0/0 gateway=192.168.28.1 routing-mark= Inet_2 scope=30 target-scope=10
add check-gateway=arp comment="" disabled=yes distance=1 dst-address= 0.0.0.0/0 gateway=192.168.1.1 routing-mark= Inet_1 scope=30 target-scope=10
/ip firewall mangle
add action=mark-connection chain=prerouting comment="ICMP Redirect" new-connection-mark=ICMP passthrough=yes protocol=icmp src-address=172.168.0.0/24 connection-state=new
add action=mark-routing chain=prerouting connection-mark=ICMP new-routing-mark=ICMP [b]passthrough=yes[/b] protocol=icmp
Reply from 81.19.70.3: bytes=32 time=31ms TTL=47
Reply from 81.19.70.3: bytes=32 time=99ms TTL=52
Reply from 81.19.70.3: bytes=32 time=35ms TTL=47
Reply from 81.19.70.3: bytes=32 time=193ms TTL=52
Reply from 81.19.70.3: bytes=32 time=21ms TTL=47
Reply from 81.19.70.3: bytes=32 time=109ms TTL=52
Reply from 81.19.70.3: bytes=32 time=108ms TTL=52
Reply from 81.19.70.3: bytes=32 time=36ms TTL=47
Dear Network Pro,Dear ValeriyZ, I think I Fixed it, I also cleaned it from what was not needed:
/ip firewall mangle
add action=mark-connection chain=prerouting comment="ICMP Redirect" new-connection-mark=ICMP passthrough=yes protocol=icmp src-address=172.168.0.0/24 connection-state=new
add action=mark-routing chain=prerouting connection-mark=ICMP new-routing-mark=ICMP passthrough=yes protocol=icmp
/ip firewall mangle
add action=mark-connection chain=input comment="" connection-state=new disabled=no in-interface=ADSL2 new-connection-mark=ADSL2Con2R passthrough=yes
add action=mark-connection chain=input comment="" connection-state=new disabled=no in-interface=ADSL1 new-connection-mark=ADSL1Con2R passthrough=yes
add action=mark-routing chain=output comment="" connection-mark=ADSL2Con2R disabled=no new-routing-mark=ToADSL2 passthrough=yes
add action=mark-routing chain=output comment="" connection-mark=ADSL1Con2R disabled=no new-routing-mark=ToADSL1 passthrough=yes
/ip route
add check-gateway=arp comment="Route All ToADSL1" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=ADSL1 routing-mark=ToADSL1
add check-gateway=arp comment="Route All ToADSL2" disabled=no distance=1 dst-address=0.0.0.0/0 gateway=ADSL2 routing-mark=ToADSL2
add check-gateway=arp comment="ECMP Route" disabled=no distance=2 dst-address=0.0.0.0/0 gateway=ADSL1,ADSL2
/ip firewall mangle
add action=mark-connection chain=prerouting comment="" connection-state=new disabled=no dst-port=1723 new-connection-mark=PPTP passthrough=yes protocol=tcp
add action=mark-connection chain=prerouting comment="" connection-state=new disabled=no new-connection-mark=GRE passthrough=yes protocol=gre
add action=mark-routing chain=prerouting comment="" connection-mark=PPTP disabled=no new-routing-mark=ToADSL1 passthrough=yes
add action=mark-routing chain=prerouting comment="" connection-mark=GRE disabled=no new-routing-mark=ToADSL1 passthrough=yes