Community discussions

MikroTik App
 
User avatar
mhenriques
newbie
Topic Author
Posts: 47
Joined: Sat Mar 23, 2019 8:45 pm
Location: BRAZIL
Contact:

WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Sun Jul 04, 2021 2:12 am

Hello guys

In my current scenario, I have 2 ISP providers connected to my Mikrotik Router. One ISP (Cable Operator) allows the cable-modem to operate in bridge mode, hence the Mikrotik receives a real IPV4 address on this port. The other ISP (Fiber GPON operator) does not allow the ONU to operate in bridge mode, hece the Mikrotik receives a reserved IPV4 address on this port (192.168.0.100), configured as the DMZ for the ONU internal LAN (192.168.0.0/24). Summary:
  • Internal LAN: 192.168.1.0/24;
  • Cable Operator WAN network: 177.142.96.0/20;
  • Fiber Operator WAN network: 192.168.0.0/24
The problem with this scenario is that the route "check gateway" test does not ensure reachability on the Fiber case, as the ONU will be online most of the time but the fiber service itself can be offline. I'm fighting the Fiber Operator to allow bridge mode, but in the meantime I'd like to define a gateway route to it's ONU internal address (192.168.0.254) but to test "check gateway" reachabillity by pinging it's external gateway real IPV4 address. Is there any way to accomplish this?

Thanks and Regards

Mauricio
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12186
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)  [SOLVED]

Sun Jul 04, 2021 2:33 am

search tag # rextended dual wan failover


It's like you ask for dual WAN failover than a load balancing

Use this as example, you must disable default roure creation on dhcp clients and remove predefined routes on /ip route
:global isp1gateway 177.142.96.44
:global isp2gateway 192.168.0.254

/ip dns
set servers=1.1.1.1,8.8.8.8

/ip route
add comment="A - 1.1.1.1 must be reachable only from ISP1" distance=1 dst-address=1.1.1.1/32 gateway=$isp1gateway scope=10
add comment="B - Recursive Routing, check ping 1.1.1.1 instead of ISP1 IP" distance=10 gateway=1.1.1.1 check-gateway=ping
add comment="C - ISP2 is alternative Gateway" distance=20 gateway=$isp2gateway

EDIT: see next posts for v7 version
Last edited by rextended on Tue Oct 25, 2022 12:36 pm, edited 10 times in total.
 
User avatar
mhenriques
newbie
Topic Author
Posts: 47
Joined: Sat Mar 23, 2019 8:45 pm
Location: BRAZIL
Contact:

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Sun Jul 04, 2021 6:10 pm

Thanks!

I'm actually doing load balancing between both ISPs, but the problem is that the current configuration does not identify "Internet Down" for the GCNAT FIber ISP connection, as it's only testing the 192.168.0.254 reserved IP address, which is always on as long as the ONU is powered up, regardless of the actual fiber connection state.

I'll take a look at the proposed code and see if I can manage to modify my configuration to incorporate the appropriate connection tests.

Thanks again.
Mauricio
 
Sylla
just joined
Posts: 1
Joined: Sun Jul 18, 2021 1:06 pm

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Mon Jul 19, 2021 11:18 am

Hi rextended, thank you for the recursive approach, very smart.
I have the same config as mhenriques (2 WANs: 1 NATted + 1 bridged).
I use PCC for dual Wan load balancing and it works fine. However, when I have on ISP line cut on the operator side, the Internet connectivity stops (ping works only to check gateway on the working ISP link), no DNS, nothing else.
example: ISP1 is a Bridged router on DSL line => line is cut on the ISP side => I need the system to failover to ISP2

For the moment I only have a dirty fix: I setup temporarily a fixed route to ISP2 to recover Internet access:

/IP route
add distance=1 gateway=172.16.2.1

But failover should be dynamic! So what is your recommandation to use PCC for LB as I use + have working failover when 1 WAN link is dow?
I'd assume it does not need a script, but I don't understand how to implement it.
I have attached an extract of my config, including the dirty fix to ISP2 : /IP route distance=1 gateway=172.16.2.1
(
210718ConfigScriptC-Gateway4Gonly_rsc.txt
)
Thank you!
You do not have the required permissions to view the files attached to this post.
Last edited by Sylla on Mon Jul 19, 2021 11:37 am, edited 1 time in total.
 
howdey57
Member Candidate
Member Candidate
Posts: 127
Joined: Wed Dec 31, 2014 2:36 pm

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Tue Oct 25, 2022 12:18 am

rextended
I'm trying to use your recursive method here but your "B" add creates an invalid entry. I'm using the isp1gateway directly (192.168.1.1 - I'm behind another router) and am using the dynamically created ppp route (a 4g dongle) wiht distance 20. I turn off the dynamically created default route on isp1 after I've added your "A" and "B".

Could you confirm your commands are still ok, or have they been amended since you published them?

I'm on 7.6

Thanks, Charles
Last edited by howdey57 on Tue Oct 25, 2022 12:54 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12186
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Tue Oct 25, 2022 12:37 am

Check the date on the post, are for v6, there is another topic, if you search from @chupaka than explain at the end the v7 version
 
howdey57
Member Candidate
Member Candidate
Posts: 127
Joined: Wed Dec 31, 2014 2:36 pm

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Tue Oct 25, 2022 9:34 am

Check the date on the post, are for v6, there is another topic, if you search from @chupaka than explain at the end the v7 version
I see this topic viewtopic.php?p=814682 Is it the one you mean?

But it starts in 2020, so spans the v6 to v7 period and is long and inconclusive. This is the problem of not having a properly managed wiki.

It would be good to have a clean version we can all use. I'd like an example with 2 WAN (one primary - ie not load balanced), with no scripting and (hopefully) no connection marks.

Charles
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12186
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Tue Oct 25, 2022 12:35 pm

I see this topic viewtopic.php?p=814682 Is it the one you mean?
[…] It would be good to have a clean version we can all use. […]
Yes, is that topic.

Please @howdey57 edit your previous post #5 and remove my quoted part, for not duplicate search results.
viewtopic.php?p=963933#p963848

This work both on v6 and on v7:
:global isp1gateway 177.142.96.44
:global isp2gateway 192.168.0.254

/ip dns
set servers=1.1.1.1,8.8.8.8

/ip route
add comment="A - 1.1.1.1 must be reachable only by ISP1" distance=1 dst-address=1.1.1.1/32 gateway=177.142.96.44 scope=10 target-scope=11
add comment="B - Recursive ping 1.1.1.1" distance=10 dst-address=0.0.0.0/0 gateway=1.1.1.1 scope=30 target-scope=12 check-gateway=ping
add comment="C - ISP2 is the alternative gateway" distance=20 dst-address=0.0.0.0/0 gateway=192.168.0.254 scope=30 target-scope=11
On winbox, for refresh routing I must close and reopen the window for refresh the content.
You can use on terminal /ip/route pri detail interval=1 for see the real status of routes
 
berzerker
newbie
Posts: 44
Joined: Thu Oct 26, 2017 6:55 am

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Wed Nov 02, 2022 7:09 pm

Hi, is there a method for using this with 2 Dynamic WAN addresses? I tried setting the gateways to interfaces, but that doesn't seem to be working. I'm unable to ping 1.1.1.1 when the static route for 1.1.1.1/32 is set up
Last edited by berzerker on Thu Nov 03, 2022 2:44 am, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12186
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Thu Nov 03, 2022 12:03 am

please remove the quoted part for not duplicate search results,
dynamic from what, dhcp client, pppoe or other?
 
berzerker
newbie
Posts: 44
Joined: Thu Oct 26, 2017 6:55 am

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Thu Nov 03, 2022 2:45 am

DHCP client, but I believe I did get this figured out. I'm using NetWatch instead, and using two static routes for each gateway as a ping monitor, then modifying the static routes distances. I believe this is the "older" method, but it works for executing scripts in the event a failover occurs.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12186
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Thu Nov 03, 2022 1:12 pm

modify DHCP client settings:

REMEMBER TO REMOVE "ADD DEFAULT ROUTE" ON DHCP CLIENTs
and add those scripts on "script" section of DHCP client

script for DHCP Client 1 = MAIN
/ip route
set [find where comment~"ISP1"] gateway=$"gateway-address"

script for DHCP Client 2 = FAILOVER
/ip route
set [find where comment~"ISP2"] gateway=$"gateway-address"
 
banshee3891
just joined
Posts: 1
Joined: Sun Apr 09, 2023 1:32 pm

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Wed Jul 05, 2023 6:54 am

Thank you rextended! This worked as intended with CGNATed LTE WAN (after setting up passthrough) as a backup.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12186
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Wed Jul 05, 2023 9:56 am

Thank you rextended! This worked as intended with CGNATed LTE WAN (after setting up passthrough) as a backup.
Thanks
 
banshee3891
just joined
Posts: 1
Joined: Sun Apr 09, 2023 1:32 pm

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Fri Aug 18, 2023 5:51 pm

How should I go about when I receive dynamic IP and gateway addresses from the PPPoE Client? Unlike the DHCP client (under advanced) there's no option to use a script for the PPPoE client.
Last edited by banshee3891 on Fri Aug 18, 2023 5:53 pm, edited 2 times in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12186
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Fri Aug 18, 2023 7:49 pm

Is in ppp profile used, instead
 
berzerker
newbie
Posts: 44
Joined: Thu Oct 26, 2017 6:55 am

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Fri Aug 18, 2023 7:51 pm

How should I go about when I receive dynamic IP and gateway addresses from the PPPoE Client? Unlike the DHCP client (under advanced) there's no option to use a script for the PPPoE client.
In the PPP Profile, there's an area to set a script "On Up" or "On Down"
 
banshee3891
just joined
Posts: 1
Joined: Sun Apr 09, 2023 1:32 pm

Re: WAN Load Balancing between 2 ISPs - one with CGNAT and another in bridge mode (real IPV4 address)

Sat Aug 26, 2023 4:28 am

Thank you, I was able to successfully use this for the PPPoE client (that gave dynamic IP) by modifying the 'default' PPP profile using the following script under the 'On Up' section:
/ip route
set [find where comment~"ISP 2"] gateway=$"remote-address"
Last edited by banshee3891 on Sat Aug 26, 2023 4:30 am, edited 1 time in total.

Who is online

Users browsing this forum: Bing [Bot], elico and 13 guests