Community discussions

MikroTik App
 
dragonauta
newbie
Topic Author
Posts: 28
Joined: Thu Feb 02, 2017 12:50 am

Two dynamic ISP failover

Fri Feb 03, 2017 4:04 am

Hello.
I have a TP-Link ER5210 router that lets me have two ISP as failover. It just does the job but it's a horrible piece of hardware.
So I purchased a RB2011UiAS-2HnD-IN. As I'm a newbie with RouterOS and it's my first Mikrotik device, I'm a little (too much) lost.
Connecting a single ISP was a piece of cake.
But I can't make two ISP work in failover.

Both ISP gives me dynamic IP, also gateways change from time to time (if I restart modem, sometimes gateway change).

This week I was reading/searching all info I could:
http://wiki.mikrotik.com/wiki/Two_gateways_failover but this is for static IP, won't work.
I learned I could use
/ip address get [find interface="wan1"] address];
to find which IP I have on wan1, but I can't figure out how to use it.

I'm pretty sure I'm messing things here, but this is what I know
I have to set two ports as dhcp-client
/ip dhcp-client add interface=ether1 disabled=no add-default-route=yes default-route-distance=1 comment=WAN1
/ip dhcp-client add interface=ether2 disabled=no add-default-route=yes default-route-distance=2 comment=WAN2
Enable masquerade
/ip firewall nat add chain=srcnat action=masquerade
And make the routes
/ip route add check-gateway=ping comment="Primary WAN1" distance=1 gateway=[ /ip address get [/ip address find interface=ether1 ] network]
/ip route add comment="Backup WAN2" distance=2 gateway=[ /ip address get [/ip address find interface=ether2 ] network]
I'm not even tried this, because I have to plan disconnection (replacing TP-LINK with RB2011 just to test means doing it after work-hours)
Something wrong? or maybe something right?
Any advice?

Thanks!!
 
dragonauta
newbie
Topic Author
Posts: 28
Joined: Thu Feb 02, 2017 12:50 am

Re: Two dynamic ISP failover

Sat Feb 04, 2017 10:27 pm

Ok, I think I'm in the right path.
I used two domestic routers to simulate two ISP.

I started with the default configuration.
Reassigned ether2-master to ether4-master in bridge,
and released ether2 & ether3 to run dhcp-client on both (I should have three ports for ISP)
Also defined routes and masquerade
I tested ping disconnecting cables (one at a time) and keeps pinging

I got this so far.
[admin@MikroTik] > /export
# feb/04/2017 17:10:52 by RouterOS 6.38.1
# software id = YYYY-ZZZZ
#
/interface bridge
add admin-mac=XX:XX:XX:XX:XX:XX auto-mac=no comment=defconf name=bridge
/interface ethernet
set [ find default-name=ether1 ] name=ether1-wan1
set [ find default-name=ether2 ] name=ether2-wan2
set [ find default-name=ether3 ] name=ether3-wan3
set [ find default-name=ether4 ] name=ether4-master
set [ find default-name=ether5 ] master-port=ether4-master
set [ find default-name=ether6 ] name=ether6-master
set [ find default-name=ether7 ] master-port=ether6-master
set [ find default-name=ether8 ] master-port=ether6-master
set [ find default-name=ether9 ] master-port=ether6-master
set [ find default-name=ether10 ] master-port=ether6-master
/interface wireless
set [ find default-name=wlan1 ] band=2ghz-b/g/n channel-width=20/40mhz-Ce disabled=no distance=indoors frequency=auto mode=ap-bridge ssid=TestWLAN \
    wireless-protocol=802.11
/ip neighbor discovery
set ether1-wan1 discover=no
/ip pool
add name=default-dhcp ranges=192.168.88.10-192.168.88.254
/ip dhcp-server
add address-pool=default-dhcp disabled=no interface=bridge name=defconf
/interface bridge port
add bridge=bridge comment=defconf interface=ether4-master
add bridge=bridge comment=defconf interface=ether6-master
add bridge=bridge comment=defconf interface=sfp1
add bridge=bridge comment=defconf interface=wlan1
/ip address
add address=192.168.88.1/24 comment=defconf interface=bridge network=192.168.88.0
/ip dhcp-client
add comment=defconf dhcp-options=hostname,clientid disabled=no interface=ether1-wan1
add default-route-distance=2 dhcp-options=hostname,clientid disabled=no interface=ether2-wan2
add default-route-distance=3 dhcp-options=hostname,clientid disabled=no interface=ether3-wan3
/ip dhcp-server network
add address=192.168.88.0/24 comment=defconf gateway=192.168.88.1
/ip dns
set allow-remote-requests=yes
/ip dns static
add address=192.168.88.1 name=router
/ip firewall filter
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment="defconf: accept established,related" connection-state=established,related
add action=drop chain=input comment="defconf: drop all from WAN" in-interface=ether1-wan1
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" connection-state=established,related
add action=accept chain=forward comment="defconf: accept established,related" connection-state=established,related
add action=drop chain=forward comment="defconf: drop invalid" connection-state=invalid
add action=drop chain=forward comment="defconf:  drop all from WAN not DSTNATed" connection-nat-state=!dstnat connection-state=new in-interface=ether1-wan1
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" out-interface=ether1-wan1
add action=masquerade chain=srcnat out-interface=ether2-wan2
add action=masquerade chain=srcnat out-interface=ether3-wan3
/ip route
add check-gateway=ping disabled=yes distance=1 gateway=ether1-wan1 routing-mark=G24
add check-gateway=ping disabled=yes distance=2 gateway=ether2-wan2 routing-mark=A3
add check-gateway=ping disabled=yes distance=3 gateway=ether3-wan3 routing-mark=G8
/system clock
set time-zone-name=America/Argentina/Buenos_Aires
/tool mac-server
set [ find default=yes ] disabled=yes
add interface=bridge
/tool mac-server mac-winbox
set [ find default=yes ] disabled=yes
add interface=bridge
Next week I will test on real environment.
 
JanTore
just joined
Posts: 7
Joined: Wed Jan 06, 2016 11:54 am

Re: Two dynamic ISP failover

Tue Apr 18, 2017 8:57 pm

I`m working on the same thing. I have a lots of devices that I use temporarily on festivals, conserts etc.. Don`t know what kind of connection I will be able to get everywhere. Sometimes I have too use 3G usb dongle.

Who is online

Users browsing this forum: HBG570 and 29 guests