mikrotik policy routing implementation example

Hello,
i have used mikrotik policy routing implementation example found in Butch Evans blog http://blog.butchevans.com/2008/09/mikrotik-policy-routing-implementation-example/,
i modified it for 4 gateway, it works but navigation become very very slow.

why???

There are many possible reasons for this. Post the output of:

/ip firewall mangle print
/ip route print detail
/ip route rule print

1 X ;;; adsl3 load balance
chain=prerouting action=mark-routing new-routing-mark=adsl3
passthrough=no src-address=192.168.2.128/26

2 X ;;; adsl1 load balance
chain=prerouting action=mark-routing new-routing-mark=adsl1
passthrough=no src-address=192.168.2.0/26

3 X ;;; adsl4 load balance
chain=prerouting action=mark-routing new-routing-mark=adsl4
passthrough=no src-address=192.168.2.192/26

4 X ;;; adsl2 load balance
chain=prerouting action=mark-routing new-routing-mark=adsl2
passthrough=no src-address=192.168.2.64/26







X S dst-address=0.0.0.0/0 gateway=10.4.1.252
gateway-status=10.4.1.252 inactive distance=1 scope=30
target-scope=10 routing-mark=adsl1

X S dst-address=0.0.0.0/0 gateway=192.168.3.1
gateway-status=192.168.3.1 inactive distance=1 scope=30
target-scope=10 routing-mark=adsl3

X S dst-address=0.0.0.0/0 gateway=192.168.1.1
gateway-status=192.168.1.1 inactive distance=1 scope=30
target-scope=10 routing-mark=adsl2

X S dst-address=0.0.0.0/0 gateway=192.168.4.1
gateway-status=192.168.4.1 inactive distance=1 scope=30
target-scope=10 routing-mark=adsl4






X dst-address=192.168.2.0/26 action=lookup table=main

X dst-address=192.168.2.64/26 action=lookup table=main

X dst-address=192.168.2.128/26 action=lookup table=main

X dst-address=192.168.2.192/26 action=lookup table=main

X dst-address=10.4.1.0/24 action=lookup table=main

X dst-address=192.168.1.0/24 action=lookup table=main

X dst-address=192.168.3.0/24 action=lookup table=main

X dst-address=192.168.4.0/24 action=lookup table=main

X src-address=10.4.1.0/24 action=lookup table=adsl1

X src-address=192.168.1.0/24 action=lookup table=adsl2

X src-address=192.168.3.0/24 action=lookup table=adsl3

X src-address=192.168.4.0/24 action=lookup table=adsl4

X routing-mark=adsl1 action=lookup table=adsl1

X routing-mark=adsl2 action=lookup table=adsl2

X routing-mark=adsl3 action=lookup table=adsl3

X routing-mark=adsl4 action=lookup table=adsl4


they are actually deactivated

These rules should work.

/ip route 
add gateway=10.4.1.252 routing-mark=adsl1
add gateway=192.168.1.1 routing-mark=adsl2
add gateway=192.168.3.1 routing-mark=adsl3
add gateway=192.168.4.1 routing-mark=adsl4
add gateway=10.4.1.0/24 comment="router Default via adsl1"
/ip route rule
add dst-address=192.168.0.0/16 action=lookup table=main
add dst-address=10.0.0.0/8 action=lookup table=main
add src-address=10.4.1.0/24 action=lookup table=adsl1
add src-address=192.168.1.0/24 action=lookup table=adsl2
add src-address=192.168.3.0/24 action=lookup table=adsl3
add src-address=192.168.4.0/24 action=lookup table=adsl4
add  routing-mark=adsl1 action=lookup table=adsl1
add routing-mark=adsl2 action=lookup table=adsl2
add routing-mark=adsl3 action=lookup table=adsl3
add routing-mark=adsl4 action=lookup table=adsl4
add routing-mark=main action=lookup table=main
/ip firewall mangle
add comment="Route local via main" \
    chain=prerouting action=mark-routing \
    dst-address=192.168.0.0/16 \
    new-routing-mark=main passthrough=no
add comment="Route local via main" \
    chain=prerouting action=mark-routing \
    dst-address=10.0.0.0/8 \
    new-routing-mark=main passthrough=no
add comment="adsl1 load balance" \
    chain=prerouting action=mark-routing \
    new-routing-mark=adsl1 passthrough=no \
    src-address=192.168.2.0/26
add comment="adsl2 load balance" \
    chain=prerouting action=mark-routing \
    new-routing-mark=adsl2 passthrough=no \
    src-address=192.168.2.64/26
add comment="adsl3 load balance" \
    chain=prerouting action=mark-routing \
    new-routing-mark=adsl3 passthrough=no \
    src-address=192.168.2.128/26
add comment="adsl4 load balance" \
    chain=prerouting action=mark-routing \
    new-routing-mark=adsl4 passthrough=no \
    src-address=192.168.2.192/26

The only thing I saw missing were your local routing rules, which MAY have been part of the problem. The other possibility is that you simply don’t have enough processor to handle all 4 lines. I don’t think I’ve overlooked anything here, but these are not lab tested. It should be noted that some of the routing rules are not needed, but I have included them here because some older versions of MT will require them and it does not hurt to have them in newer versions.

thank you, i have used it, it works but there is a big problem, the lines are not separated.
If i am in one of the four groups and watch my public ip it should be fixed and corresponding to the adsl of the group, on the contrary it changes and corresponds to different adsl.

and if i deactivate the hot spot it works fine!!!
please help me!