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
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]
}
}
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...
It's in the description...
This is amazing!! Thank you so much for this!!
i tried the dual wan static and it was perfect.. thank you for that also
I used Bridge to share the DHCP Server to ether3 and ether4 (3 for WLAN and 4 for LAN)
Please make a tutorial and add more VLAN on Bridge too,
Is it possibleto have 3 isp. 2 isp is for bonding/browsing and the other one is for gaming purposes only?
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?
create a bridge, make this bridge as your LAN. add wifi and port interfaces to it.
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?
Sna next po 2 mikrotik nmn
Mt 1 multi isp.
Mt 2 . Bandwidth mgmt , hs and ppoe
ito ung pinaka clear tuts.... sir baka full scrip ka sir baka pwde maki share
It's in the description...
Hello, what should I do in order to activate WLAN ( WIFI) using the same Balanced LAN..??? Thanks
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
There is an error here i believe... The second ip route should add a distance = 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.
or a list of websites will be passing through over vpn while user hit these websites
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
maraming salamat sir ung config nito ung gusto talga salamat sir
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?
maybe u have missed something. please try the script posted in the description.
@@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 :)
(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 .
@wifiLAB, excuse my ignorance, but where should i paste the script provided? I'm a newbie!!!
from the terminal...
@@wifilabxyz thanks so much for replying back at me!!
Sir what will happened when two isp dhcp meet in load banlancer ?
And meet static and dhcp in load banlancer?
Dear Team,
Pls help me for This rules is i ussing
But the banking site reirect not not login issue
@wifiLAB, hello, how to make your script work with l2tp providers?
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!
Did you get a reply back on this. I can't get it to auto create the comments and default route using the script.
It's in the description...
impressive!
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
muchas gracias... estoy usando dos WAN de 10M, está funcionando muy bien... estoy usando Bridge, y detalles en IP Routes..
fijate que yo tambien tuve que usar Bridge para repartir el DHCP Server entre ether3 y 4
consulta: Te sumo los 2 enlaces? porque yo no logro hacerlo
HI the script is not adding routes automatically kindly help
Is this merging dual isp boss?
nope, it just balances the traffic from 2 different ISPs.
Como puedo hacer para que sume los 2 anchos de banda??
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.
The configuration for MT rb4011?
it will be the same.
Sir parang sa tutorial mo pag nakatangal lng yung cable ska ngfafailover pano kung nkasaksak pa din sa router tpos internet lng ang wala.
gawa po kayo script para mamonitor ung internet connection or try netwatch.
Boss pwede ba ito kung pareho PLDT Home Fibr yung ISP1 and ISP2 ko?
pwde lang sir.
@@wifilabxyz Salamat sir!
advance tanks sir
Paano if same 192.168.1.1 binibigay sa dhcp client
Thank you bro 😎
thanks
Parabéns e muito obrigado top da mais
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
u can try netwatch or recursive route (i think i have this in 3WAN static video)
sir bkt parang nka limit lang po sa 30mbps ang wan2 ? thankyu sir
ilan mbps wan1 mo?
@@wifilabxyz nsa 90 80 sir
anong router model gamit mo?
nice tutorial. Sir, saan po galing yung 192.168.1.1 at 192.168.2.1 na gateway? thanks
yan po ung dalawang router na nakakonek sa mikrotik. 1 isp router = 1.1 at 2 isp router = 2.1
@@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.
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!
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.
@@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.
@@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?
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
@@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.
Please make a tutorial 1pppoe+1dhcp
Load balancing and failover
thanks..
pwede ba to lagyan ng anti lag sir ?
ano main wan ip na gagamitin ng setup na to boss?
main wan ip ng alin sir?
yung public IP na gagamitin nia boss, sa ISP 1 ba or ISP 2. para sana sa ip whitelisting just incase.
most of the time ung isp 1 sir.
Hello Good day
Sir from this set up then saksak ko to to another MT na may confi for pisowifi swak ba to?
yes sirrr
wifiLAB ok lng ba khit ano lan address gmitin ko?
Also lets say add ako pang 3rd n wan same process lng ata ryt?
kahit ano po
yes sir pareho lang
Thanks a lot, this works!!!
bro i have copied that dhcp code from your video by typing in notepad.
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!!
gawa ka ng bridge, tapos add mo ung dalawang port at wireless dun sa ginawa mong bridge.
@@wifilabxyz pwede ba kitang i add sa facebook sir?
@@wifilabxyz bakit po wlang kang ginawang bridge sa video?
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?
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.
Nevermind. I found the issue with a ")" vs. a "}" in one place. Once I addressed this, it worked fine. Thank you!
hola gran video podra apoyarme con los script
saludos y gracias
it's in the description...
please add 4wan dhcp configuration MikroTik
soon
Pa share nmn scrip sir
nasa description ng video sir
Please help me bro
Nice. Pwede po makahingi ng Script? Thanks
mr.dheyo@gmail.com
sent
Salamat po.
Anyone managed to get this working on OS 7.1?
Ito bossing kailangan ko..salamat
email?
jj.lord007xxsony@gmail.com
Script bossing ty advance
May bandwidth management narin sana para kompleto..hehe..mag aantay ako boss
Pasend script boss
Please Can I get your Script..
email?
@@wifilabxyz kaungmonsoe9@gmail.com
sent
@@wifilabxyz I well received with thanks.
@@kaungmonsoe5020 hallo brother can you help me with the scripts to my email lawrengits@gmail.com thanks in advance
sir baka pwde na ako makahingi ng script nito cardinalajc19@gmail.com maraming salamat po sana mapansin nyo po ako
sent na sir.
pa try po sir penge po ng script kenmichael05@gmail.com salamat po sir
sent
pwede po makahingi script. paulpagcaliwangan@gmail.com salamat
sent
pa send din script for dhcp sir...
dino.johnson05@gmail.com
salamat at godbless!
sent
pasend din po ng script @ drexlerguapo12@gmail.com thank you po
sent
sir p send poh ng script kenkerby40@gmail.com
sent
Pa send din po script salamat po.
dyyoung1028@gmail.com
sent
pa send po script newbie lang po salamat ^_^. canoyarnulfop@gmail.com
sent
sir pa send po ng script brezr15@gmail.com thankyou po
sent
Thankyou po.
pleasedo tutorial on dual wan + failover on mikrotik v7
pwede pa send ng script? Salamat po. pinoy1coc@gmail.com
sent