Sie sind auf Seite 1von 5

13/3/2016

LoadBalancingPersistentSpanishMikroTikWiki

LoadBalancingPersistentSpanish
FromMikroTikWiki
Versineninglsdeesteartculo:Load_Balancing_Persistent

Contents
1Introduccin
2Guarpidaparaimpacientes
3Explicacin
3.1DireccinIP
4Mangle
4.1NAT
4.2Routing

Introduccin
Esteejemploesunaversinmejorada(diferente)delejemplodebalanceodecargaroundrobin.Le
agregasesionespersistentealusuario,porejemplounusuarioparticularlegustarausarlamisma
direccinIPorigenparatodassusconeccionessalientes.Considerarelsiguientediagramadered:

http://wiki.mikrotik.com/wiki/Load_Balancing_Persistent_Spanish

1/5

13/3/2016

LoadBalancingPersistentSpanishMikroTikWiki

Guarpidaparaimpacientes
Configuracinexportadadelroutergateway:
/ipaddress
addaddress=192.168.0.1/24network=192.168.0.0broadcast=192.168.0.255interface=Local
addaddress=10.111.0.2/24network=10.111.0.0broadcast=10.111.0.255interface=wlan2
addaddress=10.112.0.2/24network=10.112.0.0broadcast=10.112.0.255interface=wlan1
/ipfirewallmangle
addchain=preroutingsrcaddresslist=oddininterface=Localaction=markconnection\
newconnectionmark=oddpassthrough=yes
addchain=preroutingsrcaddresslist=oddininterface=Localaction=markrouting\
newroutingmark=oddpassthrough=no
addchain=preroutingsrcaddresslist=evenininterface=Localaction=markconnection\
newconnectionmark=evenpassthrough=yes
addchain=preroutingsrcaddresslist=evenininterface=Localaction=markrouting\
newroutingmark=evenpassthrough=no
addchain=preroutingininterface=Localconnectionstate=newnth=1,1,0\
action=markconnectionnewconnectionmark=oddpassthrough=yes
addchain=preroutingininterface=Localaction=addsrctoaddresslist\
addresslist=oddaddresslisttimeout=1dconnectionmark=oddpassthrough=yes

http://wiki.mikrotik.com/wiki/Load_Balancing_Persistent_Spanish

2/5

13/3/2016

LoadBalancingPersistentSpanishMikroTikWiki
addchain=preroutingininterface=Localconnectionmark=oddaction=markrouting\
newroutingmark=oddpassthrough=no
addchain=preroutingininterface=Localconnectionstate=newnth=1,1,1\
action=markconnectionnewconnectionmark=evenpassthrough=yes
addchain=preroutingininterface=Localaction=addsrctoaddresslist\
addresslist=evenaddresslisttimeout=1dconnectionmark=evenpassthrough=yes
addchain=preroutingininterface=Localconnectionmark=evenaction=markrouting\
newroutingmark=evenpassthrough=no
/ipfirewallnat
addchain=srcnatconnectionmark=oddaction=srcnattoaddresses=10.111.0.2\
toports=065535
addchain=srcnatconnectionmark=evenaction=srcnattoaddresses=10.112.0.2\
toports=065535
/iproute
adddstaddress=0.0.0.0/0gateway=10.111.0.1scope=255targetscope=10routingmark=odd
adddstaddress=0.0.0.0/0gateway=10.112.0.1scope=255targetscope=10routingmark=even
adddstaddress=0.0.0.0/0gateway=10.112.0.1scope=255targetscope=10

Explicacin
Primeromostramoselcdigoyluegoexplicamosqueesloquehace.

DireccinIP
/ipaddress
addaddress=192.168.0.1/24network=192.168.0.0broadcast=192.168.0.255interface=Local
addaddress=10.111.0.2/24network=10.111.0.0broadcast=10.111.0.255interface=wlan2
addaddress=10.112.0.2/24network=10.112.0.0broadcast=10.112.0.255interface=wlan1

Elroutertienelosinterfacesdesubidas(wan)conladireccinIP10.111.0.2/24y10.112.0.2/24.
LainterfaceLANtieneelnombre"Local"yladireccinip192.168.0.1/24.

Mangle
/ipfirewallmangle
addchain=preroutingsrcaddresslist=oddininterface=Localaction=markconnection\
newconnectionmark=oddpassthrough=yes
addchain=preroutingsrcaddresslist=oddininterface=Localaction=markrouting\
newroutingmark=oddpassthrough=no

TodoeltrficodelosusuariosquetienensusdireccionesIPpuestapreviamenteenla"addresslist"
"impar"soninstantaneamentemarcadosconlamarcadeconeccinyrouting"impar".Luegoel
trficoesexcluidodelprocesosusesivodelmangleenelchainprerouting.
/ipfirewallmangle
addchain=preroutingsrcaddresslist=evenininterface=Localaction=markconnection\
newconnectionmark=evenpassthrough=yes
addchain=preroutingsrcaddresslist=evenininterface=Localaction=markrouting\
newroutingmark=evenpassthrough=no

Igualquearriba,soloquelosusuariostienesusdireccionesIPpuestapreviamenteenlaaddresslist
"par".
/ipfirewallmangle
addchain=preroutingininterface=Localconnectionstate=newnth=1,1,0\
action=markconnectionnewconnectionmark=oddpassthrough=yes
addchain=preroutingininterface=Localaction=addsrctoaddresslist\
addresslist=oddaddresslisttimeout=1dconnectionmark=oddpassthrough=yes
addchain=preroutingininterface=Localconnectionmark=oddaction=markrouting\
newroutingmark=oddpassthrough=no

http://wiki.mikrotik.com/wiki/Load_Balancing_Persistent_Spanish

3/5

13/3/2016

LoadBalancingPersistentSpanishMikroTikWiki

Primerotomamoscadasegundopaquetequeestableceunanuevasesin(notaconnection
state=new)ymarcamosconmarcaconeccion"impar".Consecuentementetodoslossucesivos
paquetessiguientesdelamismasesinllevarnlamarcaconeccin"impar".Notarqueestamos
pasandoesospaquetesalasegundaregla(passtrough=yes)parponerlamarcaderouteoenesos
paquetesadicionandoalamarcaconeccin.LasegundareglaagregalaIPdelclientealaaddress
listparahabilitartodaslassusesivassesionesquesalganatravsdelmismogateway.Latercerregla
ponelamarcaderouting"impar"entodoslospaquetespertenecientesalaconeccin"impar"ypara
deprocesartodoslosotrosmanglesenlacadenapreroutingparaesospaquetes.
/ipfirewallmangle
addchain=preroutingininterface=Localconnectionstate=newnth=1,1,1\
action=markconnectionnewconnectionmark=evenpassthrough=yes
addchain=preroutingininterface=Localaction=addsrctoaddresslist\
addresslist=evenaddresslisttimeout=1dconnectionmark=evenpassthrough=yes
addchain=preroutingininterface=Localconnectionmark=evenaction=markrouting\
newroutingmark=evenpassthrough=no

Esasreglassonlasmismasparalamitadrestantedeltrficocomolasprimerasdosreglasparala
primermitaddeltrfico.
Elcdigoanteriorhacequecadanuevaconeccinqueseiniciaatravzdelrouterdesdelaredlocal
sermarcadocomo"impar"o"par"conambasmarcasderoutingyconeccin.

NAT
/ipfirewallnat
addchain=srcnatconnectionmark=oddaction=srcnattoaddresses=10.111.0.2\
toports=065535
addchain=srcnatconnectionmark=evenaction=srcnattoaddresses=10.112.0.2\
toports=065535

Todoeltrficomarcado"impar"esNATeadoconlaiporigen10.111.0.2,mientrsqueeltrfico
marcado"par"obtiene"10.112.0.2"comoiporigen.

Routing
/iproute
adddstaddress=0.0.0.0/0gateway=10.111.0.1scope=255targetscope=10routingmark=odd
adddstaddress=0.0.0.0/0gateway=10.112.0.1scope=255targetscope=10routingmark=even

Paratodoeltrficomarcado"impar"(consecuentementeteniendo10.111.1.0.2comodireccin
origentraducida)usamos10.111.0.1comogateway.Delamismamaneratodoeltrficomarcado
"par"esruteadaporelgateway10.112.0.1.
/iproute
adddstaddress=0.0.0.0/0gateway=10.112.0.1scope=255targetscope=10

Finalmente,tenemosunaentradaadicionalespecificandoeltraficodelroutermismo(trficosin
marcasderouting)deberanirporelgateway10.112.0.1.

Translation:[MaximilianoDobladezMikrotikExpert.com(http://maxid.com.ar)]23:49,11June
2006(EEST)
Retrievedfrom"http://wiki.mikrotik.com/index.php?
title=Load_Balancing_Persistent_Spanish&oldid=8012"

http://wiki.mikrotik.com/wiki/Load_Balancing_Persistent_Spanish

4/5

13/3/2016

LoadBalancingPersistentSpanishMikroTikWiki

Thispagewaslastmodifiedon30July2008,at22:12.
Thispagehasbeenaccessed37,528times.

http://wiki.mikrotik.com/wiki/Load_Balancing_Persistent_Spanish

5/5

Das könnte Ihnen auch gefallen