|
|
发表于 2006-5-16 04:20:55
|
显示全部楼层
原帖由 younger 于 2006-5-15 22:43 发表
只有很特殊的情况才可以做负载平衡,特殊到几乎不可能的情况。只可能做分流
我现在正在做4ADSL分流。分流做好了,现在要做断线时的切换
看看我写的脚本,动态更新SNAT的to-add地址
:global adsl-1 "pppoe-out1"
:global adsl-2 "pppoe-out2"
:global adsl-1-ip [ /ip address get [/ip address find interface=$adsl-1] address ]
:global adsl-2-ip [ /ip address get [/ip address find interface=$adsl-2] address ]
:if ([ :typeof $adsl-1-lastip ] = nil ) do={ :global adsl-1-lastip 0.0.0.0/0 }
:if ([ :typeof $adsl-1-ip ] = nil ) do={
:log info ("adsl-1: No ip address present on " . $adsl-1-ip . ", please check.")
} else={
:if ($adsl-1-ip != $adsl-1-lastip) do={
:log info "adsl-1: Sending UPDATE!"
:log info [/ip fire nat set [ /ip fire nat find comm=adsl1 ] to-add [:pick $adsl-1-ip 0 [:find $adsl-1-ip "/"] ]
:global adsl-1-lastip $adsl-1-ip
} else={
:log info "adsl-1: No change"
}
}
:if ([ :typeof $adsl-2-lastip ] = nil ) do={ :global adsl-2-lastip 0.0.0.0/0 }
:if ([ :typeof $adsl-2-ip ] = nil ) do={
:log info ("adsl-2: No ip address present on " . $adsl-2-ip . ", please check.")
} else={
:if ($adsl-2-ip != $adsl-2-lastip) do={
:log info "adsl-2: Sending UPDATE!"
:log info [/ip fire nat set [ /ip fire nat find comm=adsl2] to-add [:pick $adsl-2-ip 0 [:find $adsl-2-ip "/"] ]
:global adsl-2-lastip $adsl-2-ip
} else={
:log info "adsl-2: No change"
}
}
:log info "End" |
|