MikroTik Dual WAN over 2 DHCP Internet Connections

Поделиться
HTML-код
  • Опубликовано: 19 авг 2024
  • /interface ethernet
    set [ find default-name=ether1 ] name=ether1-WAN1
    set [ find default-name=ether2 ] name=ether2-WAN2
    set [ find default-name=ether4 ] name=ether4-LAN
    /ip pool
    add name=dhcp_pool0 ranges=10.10.10.2-10.10.10.254
    /ip dhcp-server
    add address-pool=dhcp_pool0 disabled=no interface=ether4-LAN name=dhcp1
    /ip address
    add address=10.10.10.1/24 interface=ether4-LAN network=10.10.10.0
    /ip dhcp-client
    add add-default-route=no disabled=no interface=ether1-WAN1 script="{
    \

    :local rmark \"to_wan1\"
    \

    :local count [/ip route print count-only where comment=\"to_wan1\"]\

    \

    :if (\$bound=1) do={
    \

    :if (\$count = 0) do={
    \

    /ip route add distance=1 gateway=\$\"gateway-address\" check\
    -gateway=ping routing-mark=to_wan1 comment=\"to_wan1\"
    \

    /ip route add distance=1 gateway=\$\"gateway-address\" check\
    -gateway=ping comment=\"to_wan1\"
    \

    } else={
    \

    :if (\$count = 1) do={
    \

    :local test [/ip route find where comment=\"to_wan1\"]
    \

    :if ([/ip route get \$test gateway] != \$\"gateway-addre\
    ss\") do={
    \

    /ip route set \$test gateway=\$\"gateway-address\"
    \

    }
    \

    } else={
    \

    :error \"Multiple routes found\"
    \

    }
    \

    }
    \

    } else={
    \

    /ip route remove [find comment=\"to_wan1\"]
    \

    }
    \

    }"
    add add-default-route=no disabled=no interface=ether2-WAN2 script="{
    \

    :local rmark \"to_wan2\"
    \

    :local count [/ip route print count-only where comment=\"to_wan2\"]\

    \

    :if (\$bound=1) do={
    \

    :if (\$count = 0) do={
    \

    /ip route add distance=1 gateway=\$\"gateway-address\" check\
    -gateway=ping routing-mark=to_wan2 comment=\"to_wan2\"
    \

    /ip route add distance=2 gateway=\$\"gateway-address\" check\
    -gateway=ping comment=\"to_wan2\"
    \

    \t} else={
    \

    :if (\$count = 1) do={
    \

    :local test [/ip route find where comment=\"to_wan2\"]
    \

    :if ([/ip route get \$test gateway] != \$\"gateway-addre\
    ss\") do={
    \

    /ip route set \$test gateway=\$\"gateway-address\"
    \

    }
    \

    } else={
    \

    :error \"Multiple routes found\"
    \

    }
    \

    }
    \

    } else={
    \

    /ip route remove [find comment=\"to_wan2\"]
    \

    }
    \

    }"
    /ip dhcp-server network
    add address=10.10.10.0/24 dns-server=8.8.8.8 gateway=10.10.10.1
    /ip firewall mangle
    add action=accept chain=prerouting in-interface=ether1-WAN1
    add action=accept chain=prerouting in-interface=ether2-WAN2
    add action=mark-connection chain=prerouting dst-address-type=!local \
    new-connection-mark=wan1_conn passthrough=yes per-connection-classifier=\
    both-addresses-and-ports:2/0 src-address=10.10.10.0/24
    add action=mark-connection chain=prerouting dst-address-type=!local \
    new-connection-mark=wan2_conn passthrough=yes per-connection-classifier=\
    both-addresses-and-ports:2/1 src-address=10.10.10.0/24
    add action=mark-routing chain=prerouting connection-mark=wan1_conn \
    new-routing-mark=to_wan1 passthrough=yes src-address=10.10.10.0/24
    add action=mark-routing chain=prerouting connection-mark=wan2_conn \
    new-routing-mark=to_wan2 passthrough=yes src-address=10.10.10.0/24
    /ip firewall nat
    add action=masquerade chain=srcnat out-interface=ether1-WAN1 src-address=\
    10.10.10.0/24
    add action=masquerade chain=srcnat out-interface=ether2-WAN2 src-address=\
    10.10.10.0/24
    /ip route
    add check-gateway=ping comment=to_wan1 distance=1 gateway=192.168.1.1 \
    routing-mark=to_wan1
    add check-gateway=ping comment=to_wan2 distance=1 gateway=192.168.2.1 \
    routing-mark=to_wan2
    add check-gateway=ping comment=to_wan1 distance=1 gateway=192.168.1.1
    add check-gateway=ping comment=to_wan2 distance=2 gateway=192.168.2.1

Комментарии • 334

  • @zbgslavi
    @zbgslavi 3 года назад +5

    The scripts will not work correctly, if the DHCP server just change the gateway. It will go to the :error "Multiple routes found'. I suggest better script. When you apply it to the WAN2 DHCP client, just change the first line.
    {
    :local rmark "to_wan1"
    :if ($bound=1) do={
    :if ([/ip route print count-only where comment=$rmark] = 0) do={
    /ip route add distance=1 gateway=$"gateway-address" check-gateway=ping routing-mark=$rmark comment=$rmark
    /ip route add distance=1 gateway=$"gateway-address" check-gateway=ping comment=$rmark
    } else={
    :foreach r in=[/ip route find where comment=$rmark] do={
    :if ([/ip route get $r gateway] != $"gateway-address") do={
    /ip route set $r gateway=$"gateway-address"
    }
    }
    }
    } else={
    /ip route remove [find comment=$rmark]
    }
    }

  • @metalstream
    @metalstream 3 года назад +3

    Great tutorial bro, still i dont get why we must send you an email for the scripts when you can just copy&paste on the description...

    • @wifilabxyz
      @wifilabxyz  3 года назад +2

      It's in the description...

  • @matthewfranck5458
    @matthewfranck5458 3 года назад +1

    This is amazing!! Thank you so much for this!!

  • @joelram3182
    @joelram3182 3 года назад

    i tried the dual wan static and it was perfect.. thank you for that also

  • @MitzaelSerna
    @MitzaelSerna 3 года назад +1

    I used Bridge to share the DHCP Server to ether3 and ether4 (3 for WLAN and 4 for LAN)

  • @mikey_2387
    @mikey_2387 3 года назад +1

    Is it possibleto have 3 isp. 2 isp is for bonding/browsing and the other one is for gaming purposes only?

  • @Elrevisor2k
    @Elrevisor2k 3 года назад +1

    thanks for sharing if I want also do this for wireless what I need to do as I see only one port Lan is enabled but for the 2g and 5g wireless to happen what I need to do?

    • @wifilabxyz
      @wifilabxyz  3 года назад +1

      create a bridge, make this bridge as your LAN. add wifi and port interfaces to it.

  • @jean-francoishetu6147
    @jean-francoishetu6147 6 месяцев назад

    Could you confirm my understanding... if we don't complete the configuration with the mangle rules and simply keep the DHCP client configuration. Then this becomes a simple Dual WAN DHCP client failover solution?
    ie: the mangle portion allows for load balancing, correct?

  • @wilsonjuance3760
    @wilsonjuance3760 4 года назад +2

    Sna next po 2 mikrotik nmn
    Mt 1 multi isp.
    Mt 2 . Bandwidth mgmt , hs and ppoe

  • @jez1357
    @jez1357 4 года назад +1

    ito ung pinaka clear tuts.... sir baka full scrip ka sir baka pwde maki share

    • @wifilabxyz
      @wifilabxyz  3 года назад

      It's in the description...

  • @arodb86
    @arodb86 3 года назад

    Hello, what should I do in order to activate WLAN ( WIFI) using the same Balanced LAN..??? Thanks

  • @MitzaelSerna
    @MitzaelSerna 3 года назад +1

    the scripts has some extra characters from the parser, should be like this
    {
    :local rmark "to_wan2"
    :local count [/ip route print count-only where comment="to_wan2"]
    :if ($bound=1) do={
    :if ($count = 0) do={
    /ip route add distance=1 gateway=$"gateway-address" check-gateway=ping routing-mark=to_wan2 comment="to_wan2"
    /ip route add distance=1 gateway=$"gateway-address" check-gateway=ping comment="to_wan2"
    } else={
    :if ($count = 1) do={
    :local test [/ip route find where comment="to_wan2"]
    :if ([/ip route get $test gateway] != $"gateway-address") do={
    /ip route set $test gateway=$"gateway-address"
    }
    } else={
    :error "Multiple routes found"
    }
    }
    } else={
    /ip route remove [find comment="to_wan2"]
    }
    }
    only changes wan2 for wan1, the logic of the script are the same

    • @lucianodisarno4328
      @lucianodisarno4328 2 года назад

      There is an error here i believe... The second ip route should add a distance = 2...

  • @dexturevlogs5677
    @dexturevlogs5677 2 года назад

    Hello, I hope i can receive a response for this. I used this configuration and its work totally fine for my dual wan set-up, however, i can't ping to the networks i created on LAN3 and LAN4 vice versa. Given the fact that, that LAN1 AND LAN2 is for ISP. Any suggestion how my networks could ping each other.

  • @TechnicalMamunBengali
    @TechnicalMamunBengali 3 года назад

    or a list of websites will be passing through over vpn while user hit these websites

  • @ilyasft9640
    @ilyasft9640 2 года назад

    Thank you for this video!
    i'm successfully join both my WAN connection.
    if i can ask 1 question, how do i force certain IP Address/client to use only WAN1 ?
    i tried using source address != "Block to WAN2" but the client still using both WAN connection

  • @jez1357
    @jez1357 4 года назад +1

    maraming salamat sir ung config nito ung gusto talga salamat sir

  • @lightbeam6783
    @lightbeam6783 3 года назад +1

    Hello there. I have followed the instructions on this video to the T and i'm not getting internet breakout on the mikrotik when the wan is connected to either wan1 or wan 2 - getting no route to host error? Please can you give more information on the ip/route setup?

    • @wifilabxyz
      @wifilabxyz  3 года назад

      maybe u have missed something. please try the script posted in the description.

    • @lightbeam6783
      @lightbeam6783 3 года назад +1

      @@wifilabxyz Thank you so much for the reply. I started everything form scratch and it is now working just as it should. You are probably right , my bad :)

  • @TechnicalMamunBengali
    @TechnicalMamunBengali 3 года назад

    (ether1=pppoe-client)+(ovpn -client/l2tp-client/sstp-client/pptp-client) = (ether 2=dhcp)
    where vpn connection will only be used for block site to open.
    bro how can i do that??
    i need your help .

  • @wncgcg
    @wncgcg 2 года назад +1

    @wifiLAB, excuse my ignorance, but where should i paste the script provided? I'm a newbie!!!

    • @wifilabxyz
      @wifilabxyz  2 года назад +1

      from the terminal...

    • @wncgcg
      @wncgcg 2 года назад +1

      @@wifilabxyz thanks so much for replying back at me!!

  • @waldenlaab4285
    @waldenlaab4285 3 года назад

    Sir what will happened when two isp dhcp meet in load banlancer ?
    And meet static and dhcp in load banlancer?

  • @rk12450
    @rk12450 3 года назад

    Dear Team,
    Pls help me for This rules is i ussing
    But the banking site reirect not not login issue

  • @EraseAllDrives
    @EraseAllDrives 2 года назад

    @wifiLAB, hello, how to make your script work with l2tp providers?

  • @ArcTour292
    @ArcTour292 4 года назад +2

    Thank you for this video. I've been seeking for solution setting up mikrotik with 2 WAN both DHCP-client. Your script is good, but I think there is some mistake in it - in section :if (count=1) we need to write count=2, 'cause we recently created 2 routes in upper section. But I may be wrong. Best regards!

    • @tradethatask7518
      @tradethatask7518 3 года назад

      Did you get a reply back on this. I can't get it to auto create the comments and default route using the script.

    • @wifilabxyz
      @wifilabxyz  3 года назад

      It's in the description...

  • @sohrkim
    @sohrkim 3 года назад +1

    impressive!

  • @psywareSSL
    @psywareSSL 9 месяцев назад

    Thanx for the tutorial but does not work on any of my MTK´s in 7.11 router OS...could u send me the scripts to my mail?
    best regards

  • @enoypinedo6274
    @enoypinedo6274 3 года назад

    muchas gracias... estoy usando dos WAN de 10M, está funcionando muy bien... estoy usando Bridge, y detalles en IP Routes..

    • @MitzaelSerna
      @MitzaelSerna 3 года назад

      fijate que yo tambien tuve que usar Bridge para repartir el DHCP Server entre ether3 y 4

    • @cristianbarboza6298
      @cristianbarboza6298 2 года назад

      consulta: Te sumo los 2 enlaces? porque yo no logro hacerlo

  • @newtonmuuo1659
    @newtonmuuo1659 2 года назад

    HI the script is not adding routes automatically kindly help

  • @BenzkyG101
    @BenzkyG101 3 года назад +1

    Is this merging dual isp boss?

    • @wifilabxyz
      @wifilabxyz  3 года назад

      nope, it just balances the traffic from 2 different ISPs.

  • @cristianbarboza6298
    @cristianbarboza6298 2 года назад

    Como puedo hacer para que sume los 2 anchos de banda??

  • @bulitobayagbag6683
    @bulitobayagbag6683 4 года назад

    sir how to create packet marks using this routing setup po?
    di ko kasi mapagana yung sakin pwede po pa turo kahit isang set of mangle lang. example is Streaming. how can I create packet marks para magamit po sa Q3
    Thanks sir.

  • @sanfrancamotes7530
    @sanfrancamotes7530 3 года назад +1

    The configuration for MT rb4011?

  • @johnrolansunido4626
    @johnrolansunido4626 4 года назад

    Sir parang sa tutorial mo pag nakatangal lng yung cable ska ngfafailover pano kung nkasaksak pa din sa router tpos internet lng ang wala.

    • @wifilabxyz
      @wifilabxyz  4 года назад

      gawa po kayo script para mamonitor ung internet connection or try netwatch.

  • @ZindelLeander
    @ZindelLeander 3 года назад +1

    Boss pwede ba ito kung pareho PLDT Home Fibr yung ISP1 and ISP2 ko?

  • @jez1357
    @jez1357 4 года назад

    advance tanks sir

  • @notsoordinary8731
    @notsoordinary8731 3 года назад

    Paano if same 192.168.1.1 binibigay sa dhcp client

  • @3l_96
    @3l_96 3 года назад

    Thank you bro 😎

  • @baradotvfunents4979
    @baradotvfunents4979 4 года назад +1

    thanks

  • @jvsbm
    @jvsbm 2 года назад

    Parabéns e muito obrigado top da mais

  • @calotcalot
    @calotcalot 3 года назад +1

    Hi sir is there any chance that we cna check ping 8.8.8.8? Since most outages WAN gateway(ISP modem) is still reacheable unless it its hardware/power related. Thank you. This is very helpful

    • @wifilabxyz
      @wifilabxyz  3 года назад

      u can try netwatch or recursive route (i think i have this in 3WAN static video)

  • @renzorioja1964
    @renzorioja1964 3 года назад +1

    sir bkt parang nka limit lang po sa 30mbps ang wan2 ? thankyu sir

  • @badburn
    @badburn 3 года назад +1

    nice tutorial. Sir, saan po galing yung 192.168.1.1 at 192.168.2.1 na gateway? thanks

    • @wifilabxyz
      @wifilabxyz  3 года назад +1

      yan po ung dalawang router na nakakonek sa mikrotik. 1 isp router = 1.1 at 2 isp router = 2.1

    • @badburn
      @badburn 3 года назад

      @@wifilabxyz Thank you Sir. Did copy and pasted the script on the Mikrotik terminal. The mikrotik router can ping google.com via terminal but the laptop can't ping google.com. will check again.

  • @nachorepara
    @nachorepara 2 года назад

    hi! great video! but, i cannot make to work the script, when i create the dhcp-client and put the script, it doesn`t create the statics routes. I put it excactly like the description on your video, copy-paste in the terminal, but wont work. I do some modifications to it, but same results, it take some IP from my ISP but nothing happend on the statics routes. Maybe it is wrong? Is ther a way to debug it? Thnks for your help!

    • @tekniqal2639
      @tekniqal2639 Год назад

      Same here. Followed the tutorial to the letter but the default routes do not show up as shown in the video. I guess the maker of the video has moved on.

    • @nachorepara
      @nachorepara Год назад

      @@tekniqal2639 hey! I resolved it downgrading My mktk to last versión 6 (i had versión 7) i supose script doesn't work in 7.

    • @tekniqal2639
      @tekniqal2639 Год назад

      @@nachorepara You know I thought of that but I was thinking of using the containers feature and it only only works with 7. No wireguard with 6 also. What is the latest version of 6 that can be used. Or at least, what version number are you using?

    • @nachorepara
      @nachorepara Год назад

      I have now 6.48.6 ando it works fine! You should try it, or i think you must search some script for 7.x.x

    • @tekniqal2639
      @tekniqal2639 Год назад +1

      @@nachorepara Thanks dude. I did look at another guide (see here: ruclips.net/video/IsJlBqpVgGo/видео.html). He is on 7 but I do not think it really works. He uses the main table and when I turn that off setup stops working which suggests the configuration is not really doing anything. Anyhow, thanks again.

  • @mehebubbinahmed1036
    @mehebubbinahmed1036 3 года назад

    Please make a tutorial 1pppoe+1dhcp
    Load balancing and failover

  • @salemoraya1398
    @salemoraya1398 4 года назад +1

    thanks..

  • @choitoi67
    @choitoi67 3 года назад

    pwede ba to lagyan ng anti lag sir ?

  • @norwhyndavesales3482
    @norwhyndavesales3482 3 года назад +1

    ano main wan ip na gagamitin ng setup na to boss?

    • @wifilabxyz
      @wifilabxyz  3 года назад

      main wan ip ng alin sir?

    • @norwhyndavesales3482
      @norwhyndavesales3482 3 года назад +1

      yung public IP na gagamitin nia boss, sa ISP 1 ba or ISP 2. para sana sa ip whitelisting just incase.

    • @wifilabxyz
      @wifilabxyz  3 года назад +1

      most of the time ung isp 1 sir.

  • @fearmtechwireless6145
    @fearmtechwireless6145 2 года назад

    Hello Good day

  • @raivillegas7242
    @raivillegas7242 4 года назад

    Sir from this set up then saksak ko to to another MT na may confi for pisowifi swak ba to?

  • @Alescaramanzia
    @Alescaramanzia 2 года назад

    Thanks a lot, this works!!!

  • @TechnicalMamunBengali
    @TechnicalMamunBengali 3 года назад

    bro i have copied that dhcp code from your video by typing in notepad.

  • @akeemarcayera
    @akeemarcayera 3 года назад

    Boss thank you!! Gumana yung code!!
    Tanong ko lang din sana if sang banda mag eedit if gusto ko iactivate yung dalawang ports plus yung wifi. Salamat ng marami! God bless!!

    • @wifilabxyz
      @wifilabxyz  3 года назад

      gawa ka ng bridge, tapos add mo ung dalawang port at wireless dun sa ginawa mong bridge.

    • @thenomadtrade
      @thenomadtrade 3 года назад

      @@wifilabxyz pwede ba kitang i add sa facebook sir?

    • @zwack2097
      @zwack2097 Год назад

      ​@@wifilabxyz bakit po wlang kang ginawang bridge sa video?

  • @tradethatask7518
    @tradethatask7518 3 года назад

    I can't get it to auto create the "to_WAN1" comments under routes and also auto create the default route using the script and followed this closely. Any suggestions?

    • @tradethatask7518
      @tradethatask7518 3 года назад

      I have an RB2011UiAS and version 6.43. I'm testing with a single ISP and when I connect, it creates the subnet route but not 0.0.0.0/0 default route and also does not insert the comment "to_wan1" etc. Any advice would be helpful to troubleshoot - jason@jakadas.com and jason.bawcom@gmail.com.

    • @tradethatask7518
      @tradethatask7518 3 года назад

      Nevermind. I found the issue with a ")" vs. a "}" in one place. Once I addressed this, it worked fine. Thank you!

  • @reparacionytecnologiaparat2582
    @reparacionytecnologiaparat2582 3 года назад +1

    hola gran video podra apoyarme con los script
    saludos y gracias

    • @wifilabxyz
      @wifilabxyz  3 года назад

      it's in the description...

  • @FAST-TECH0101
    @FAST-TECH0101 4 года назад

    please add 4wan dhcp configuration MikroTik

  • @BunalmananapTV
    @BunalmananapTV 3 года назад +1

    Pa share nmn scrip sir

    • @wifilabxyz
      @wifilabxyz  3 года назад

      nasa description ng video sir

  • @warfaachannel2013
    @warfaachannel2013 3 года назад

    Please help me bro

  • @redcat483
    @redcat483 4 года назад

    Nice. Pwede po makahingi ng Script? Thanks

  • @AlbertTafilaj
    @AlbertTafilaj 2 года назад

    Anyone managed to get this working on OS 7.1?

  • @jenrichonlineshop1712
    @jenrichonlineshop1712 4 года назад

    Ito bossing kailangan ko..salamat

  • @kaungmonsoe5020
    @kaungmonsoe5020 4 года назад

    Please Can I get your Script..

    • @wifilabxyz
      @wifilabxyz  4 года назад

      email?

    • @kaungmonsoe5020
      @kaungmonsoe5020 4 года назад +1

      @@wifilabxyz kaungmonsoe9@gmail.com

    • @wifilabxyz
      @wifilabxyz  4 года назад +1

      sent

    • @kaungmonsoe5020
      @kaungmonsoe5020 4 года назад +2

      @@wifilabxyz I well received with thanks.

    • @lawrencegithui9543
      @lawrencegithui9543 3 года назад

      @@kaungmonsoe5020 hallo brother can you help me with the scripts to my email lawrengits@gmail.com thanks in advance

  • @jez1357
    @jez1357 4 года назад +1

    sir baka pwde na ako makahingi ng script nito cardinalajc19@gmail.com maraming salamat po sana mapansin nyo po ako

  • @michaelmacandog4914
    @michaelmacandog4914 4 года назад +1

    pa try po sir penge po ng script kenmichael05@gmail.com salamat po sir

  • @paulpagcaliwangan5137
    @paulpagcaliwangan5137 4 года назад +1

    pwede po makahingi script. paulpagcaliwangan@gmail.com salamat

  • @aotsimp4
    @aotsimp4 4 года назад +1

    pa send din script for dhcp sir...
    dino.johnson05@gmail.com
    salamat at godbless!

  • @clydedrexler9431
    @clydedrexler9431 4 года назад +1

    pasend din po ng script @ drexlerguapo12@gmail.com thank you po

  • @abelyap4666
    @abelyap4666 4 года назад +1

    sir p send poh ng script kenkerby40@gmail.com

  • @dyyoung7573
    @dyyoung7573 4 года назад +1

    Pa send din po script salamat po.
    dyyoung1028@gmail.com

  • @JyCny
    @JyCny 4 года назад +1

    pa send po script newbie lang po salamat ^_^. canoyarnulfop@gmail.com

  • @MrRenz15
    @MrRenz15 4 года назад +1

    sir pa send po ng script brezr15@gmail.com thankyou po

  • @solrista664
    @solrista664 Год назад

    pleasedo tutorial on dual wan + failover on mikrotik v7

  • @pinoycoccoc4465
    @pinoycoccoc4465 4 года назад +1

    pwede pa send ng script? Salamat po. pinoy1coc@gmail.com