example:
1-st ISP gateway: 192.168.0.1
2-nd ISP gateway: 192.168.2.1
/ip route add dst-address=0.0.0.0/0 gateway=192.168.0.1,192.168.2.1
2:1 balancing:
/ip route add dst-address=0.0.0.0/0 gateway=192.168.0.1,192.168.0.1,192.168.2.1
2 connections will be routed via 192.168.0.1, and the next one - via 192.168.2.1
It works fine for me (with one ADSL /2Mbit/ connection, and one CABLE modem connection /1.5Mbit/.)
Bulgarian telecom BTK sux.....
The other simple way is to use routing-mark
p.s.
http://www.mikrotik.com/docs/ros/2.9/ip/route
/ ip firewall mangle
add chain=prerouting in-interface=ether2 connection-state=new nth=1,1,0 \
action=mark-connection new-connection-mark=odd passthrough=yes comment="" \
disabled=no
add chain=prerouting in-interface=ether2 connection-mark=odd \
action=mark-routing new-routing-mark=odd passthrough=no comment="" \
disabled=no
add chain=prerouting in-interface=ether2 connection-state=new nth=1,1,1 \
action=mark-connection new-connection-mark=even passthrough=yes comment="" \
disabled=no
add chain=prerouting in-interface=ether2 connection-mark=even \
action=mark-routing new-routing-mark=even passthrough=no comment="" \
disabled=no
/ ip firewall nat
add chain=srcnat connection-mark=odd action=src-nat \
to-addresses=192.168.10.201 to-ports=0-65535 comment="" disabled=no
add chain=srcnat connection-mark=even action=src-nat to-addresses=10.1.1.202 \
to-ports=0-65535 comment="" disabled=no
/ ip route
add dst-address=0.0.0.0/0 gateway=192.168.10.1 scope=255 target-scope=10 \
routing-mark=odd comment="" disabled=no
add dst-address=0.0.0.0/0 gateway=10.1.1.254 scope=255 target-scope=10 \
routing-mark=even comment="" disabled=no
/ ip route rule
add routing-mark=odd action=lookup table=odd comment="" disabled=no
add routing-mark=even action=lookup table=even comment="" disabled=no
/ ip firewall mangle
add chain=prerouting src-address-list=odd in-interface=Local action=mark-connection new-connection-mark=odd passthrough=yes
add chain=prerouting src-address-list=odd in-interface=Local action=mark-routing new-routing-mark=odd
add chain=prerouting src-address-list=even in-interface=Local action=mark-connection new-connection-mark=even passthrough=yes
add chain=prerouting src-address-list=even in-interface=Local action=mark-routing new-routing-mark=even
add chain=prerouting in-interface=Local connection-state=new nth=1,1,0 \
action=mark-connection new-connection-mark=odd passthrough=yes comment="" \
disabled=no
add chain=prerouting in-interface=Local action=add-src-to-address-list address-list=odd address-list-timeout=1d connection-mark=odd passthrough=yes
add chain=prerouting in-interface=Local connection-mark=odd action=mark-routing \
new-routing-mark=odd passthrough=no comment="" disabled=no
add chain=prerouting in-interface=Local connection-state=new nth=1,1,1 \
action=mark-connection new-connection-mark=even passthrough=yes comment="" \
disabled=no
add chain=prerouting in-interface=Local action=add-src-to-address-list address-list=even address-list-timeout=1d connection-mark=even passthrough=yes
add chain=prerouting in-interface=Local connection-mark=even action=mark-routing \
new-routing-mark=even passthrough=no comment="" disabled=no
thanks, but please make the links shorter I will do this for you ..I translate the wiki article to spanish:
http://wiki.mikrotik.com/wiki/Balanceo_ ... _%28wan%29
Maximiliano
Mikrotik Certified Consultant
To Sharing the knowledge
I surely hope to find the time to dig out and polish up my example.If one of the link goes down does it mean that some traffic won`t be routed at all.
I surely hope to find the time to dig out and polish up my example.If one of the link goes down does it mean that some traffic won`t be routed at all.
But in the mean time: It was working practically the same way (by adding new src-addresses to address-lists, but with a lower address-list-timeout).
Then I added a script to check the uplinks every few seconds and have it redistribute the users/connections on the "dead" link to the (or one of the) alive uplinks.
Best regards,
Christian Meis
/ ip firewall mangle
add chain=prerouting src-address-list=use_uplink_a action=mark-routing new-routing-mark=uplink_a passthrough=no comment="set routing mark for uplink A" disabled=no
add chain=prerouting src-address-list=use_uplink_b action=mark-routing new-routing-mark=uplink_b passthrough=no comment="set routing mark for uplink B" disabled=no
add chain=prerouting action=mark-packet new-packet-mark=new_srcadr passthrough=yes comment="" disabled=no
/ ip firewall filter
add chain=forward in-interface=ether1 packet-mark=new_srcadr action=add-src-to-address-list address-list=new_user address-list-timeout=0s comment="" disabled=no
:local uplinkacount
:local uplinkbcount
:local newipadr
:log debug "script checking for new source addresses"
:foreach i in=[/ip firewall address-list find list=new_user] do={
:set newipaddr [/ip firewall address-list get $i address]
:set uplinkacount [:len [/ip firewall address-list find list=use_uplink_a]]
:set uplinkbcount [:len [/ip firewall address-list find list=use_uplink_b]]
:log debug (" found new source address " . $newipaddr)
:log debug (" " . $uplinkacount . " User auf Uplink A")
:log debug (" " . $uplinkbcount . " User auf Uplink B")
:if ($uplinkacount < $uplinkbcount) do={
:log debug ("about to add " . $newipaddr . " to list a")
/ip firewall address-list remove $i
/ip firewall address-list add address=$newipaddr list=use_uplink_a disabled=no
:log info ("added new source address " . $newipaddr . " to address-list use_uplink_a")
} else={
:log debug ("about to add " . $newipaddr . " to list b")
/ip firewall address-list remove $i
/ip firewall address-list add address=$newipaddr list=use_uplink_b disabled=no
:log info ("added new source address " . $newipaddr . " to address-list use_uplink_b")
}
}
Well, MY banking and MY instant messaging works, and that is my only point of concern Indeed, as Christian has pointed out, it does round-robin on all connections, but as I have said, this does not cause any problems ... for me.
To "fix" it to NAT all connections from a particular user to the same IP address, you have to do the following:EugeneCode: Select all/ ip firewall mangle add chain=prerouting src-address-list=odd in-interface=Local action=mark-connection new-connection-mark=odd passthrough=yes add chain=prerouting src-address-list=odd in-interface=Local action=mark-routing new-routing-mark=odd add chain=prerouting src-address-list=even in-interface=Local action=mark-connection new-connection-mark=even passthrough=yes add chain=prerouting src-address-list=even in-interface=Local action=mark-routing new-routing-mark=even add chain=prerouting in-interface=Local connection-state=new nth=1,1,0 \ action=mark-connection new-connection-mark=odd passthrough=yes comment="" \ disabled=no add chain=prerouting in-interface=Local action=add-src-to-address-list address-list=odd address-list-timeout=1d connection-mark=odd passthrough=yes add chain=prerouting in-interface=Local connection-mark=odd action=mark-routing \ new-routing-mark=odd passthrough=no comment="" disabled=no add chain=prerouting in-interface=Local connection-state=new nth=1,1,1 \ action=mark-connection new-connection-mark=even passthrough=yes comment="" \ disabled=no add chain=prerouting in-interface=Local action=add-src-to-address-list address-list=even address-list-timeout=1d connection-mark=even passthrough=yes add chain=prerouting in-interface=Local connection-mark=even action=mark-routing \ new-routing-mark=even passthrough=no comment="" disabled=no
i don't want to bind a port to a public ip... but to a private ip... just to redirect all traffic incoming port xxx to ip xxx.xxx.xxx.xxx... no matter what is the public ip....chain=prerouting in-interface=Local protocol=tcp dst-port=443
action=mark-connection new-connection-mark=even passthrough=yes
for example
/ ip firewall mangle
add chain=prerouting in-interface=Local connection-state=new nth=1,1,0 \
action=mark-connection new-connection-mark=odd passthrough=yes
add chain=prerouting in-interface=Local action=add-src-to-address-list \
address-list=odd address-list-timeout=1d connection-mark=odd passthrough=yes
add chain=prerouting in-interface=Local action=add-src-to-address-list address-list=odd address-list-timeout=1d connection-mark=odd passthrough=yes
add chain=prerouting in-interface=Local connection-mark=odd action=add-src-to-address-list address-list=odd address-list-timeout=1d passthrough=yes
you all must know that loadbalancing via two or more ADSL that have different outgoing IP will not work .. why...
.. thing like MSN, ICQ, ... must have same IP for all the outgoing connection to central ...
exmpl:
if i start MSN it have few connection one is for MSN directory and it's main connection, for transfer of emotion there is another one, file goes by third and cam on 4th ... 5th is for voice .. all connection will go to different port on MSN central server (s) and if one connection came from different IP .. you msn is out for 60 sec ... MSN think it is a freaud
try play some online game as knight online, silkroad, or even CS .. lolo
a) put ADSL1 as dflt rout and then reroute (in preroute) http, ft, smtp, pop3 etc .. that can be reroute'd
b) have some smart per user IP or block of IP routing ..
your missing code thats why. there is some mangle code your missing copare it to the link provided on the wiki.
mangle rules are missing some code
Yea sorry your tight i had the 3 wan in my head for a while and didnt think u was using 2 wansyour missing code thats why. there is some mangle code your missing copare it to the link provided on the wiki.
mangle rules are missing some code
Isn't missing anything! that is the configuration of load balance without Persistent Sessions ....
http://wiki.mikrotik.com/wiki/Load_Balancing
/ ip route rule
add dst-address=10.33.33.0/29 action=lookup table=main comment="" disabled=no
add dst-address=10.254.0.0/16 action=lookup table=main comment="" disabled=no
add dst-address=10.44.44.0/30 action=lookup table=main comment="" disabled=no
add src-address=10.44.44.0/24 routing-mark=T1 action=lookup table=T1 comment="" disabled=no
add src-address=10.44.44.0/24 routing-mark=DSL action=lookup table=DSL comment="" disabled=no
add src-address=10.33.33.0/24 routing-mark=T1 action=lookup table=T1 comment="" disabled=no
add src-address=10.33.33.0/24 routing-mark=DSL action=lookup table=DSL comment="" disabled=no
1) you have to disable "passthrough" in your voip rules....
Congratulations! Could you make this into the wiki?Hello Again,
Got it working!!!! I now have all VOIP going through one specific WAN.. Thanks to Eugene and Sergejs...The trick was to make the mangle rule unset... To unset goto ip firewall mangle and print, than type unset, it will ask for the number and value-name, put connection-state on the value.
Here is the snippet incase someone whats to try it out:
Well, MY banking and MY instant messaging works, and that is my only point of concern Indeed, as Christian has pointed out, it does round-robin on all connections, but as I have said, this does not cause any problems ... for me.
To "fix" it to NAT all connections from a particular user to the same IP address, you have to do the following:EugeneCode: Select all/ ip firewall mangle add chain=prerouting src-address-list=odd in-interface=Local action=mark-connection new-connection-mark=odd passthrough=yes add chain=prerouting src-address-list=odd in-interface=Local action=mark-routing new-routing-mark=odd add chain=prerouting src-address-list=even in-interface=Local action=mark-connection new-connection-mark=even passthrough=yes add chain=prerouting src-address-list=even in-interface=Local action=mark-routing new-routing-mark=even add chain=prerouting in-interface=Local connection-state=new nth=1,1,0 \ action=mark-connection new-connection-mark=odd passthrough=yes comment="" \ disabled=no add chain=prerouting in-interface=Local action=add-src-to-address-list address-list=odd address-list-timeout=1d connection-mark=odd passthrough=yes add chain=prerouting in-interface=Local connection-mark=odd action=mark-routing \ new-routing-mark=odd passthrough=no comment="" disabled=no add chain=prerouting in-interface=Local connection-state=new nth=1,1,1 \ action=mark-connection new-connection-mark=even passthrough=yes comment="" \ disabled=no add chain=prerouting in-interface=Local action=add-src-to-address-list address-list=even address-list-timeout=1d connection-mark=even passthrough=yes add chain=prerouting in-interface=Local connection-mark=even action=mark-routing \ new-routing-mark=even passthrough=no comment="" disabled=no