2 masquerade, srcnat rules, Out Interfaces ISP_1, ISP_2,
10 rules for internal servers forwarded from ISP_2,
default RouterOS rules
my configuration was worked fine for 5 years, but one ISP_1 (2 dynamic IP, 500 Mbps) do some nightly service works, “broke my internet connection”, router switched to ISP_2 (1 static IP, 100 Mbps), I call service and get technician visit, tell him history, he calls some master technician, he reconfigure something at their site, and ISP_1 internet works, if I directly connect computer to it
but!
if I connect this ISP_1 Ethernet cable to router, router switches to WAN1 - ISP_1, but ISP_2 link stops working - PING stops, internal services from outside are not accessible, if I disable ether1_ISP1, all starts working again after second
it looks like, that when ether1_ISP1 is enabled, all data goes somewhere wrong, but I can’t find where and why
it looks like, that when ether1_ISP1 is enabled, all data goes somewhere wrong, but I can’t find where and why
Thats what i think as well…
Is your ISP 1 IP still Dynamic or Static ?
If it is static, did you make sure your config and your addresses, subnets etc are correct ?
ISP_1 it’s dynamic - as my experiments I disable and enable this ether1 and get addresses - 46., 85., 95. and so on. for now I even leave Add Default Route - on, and if I enable ether1 (ISP1), I get working internet through this link with full speed (~500/500), but after second of enable ether1, static link ether5 came unreachable from outside (but if I try ping 1.1.1.1 through ether5 I get ~7ms response)
# apr/06/2020 22:42:27 by RouterOS 6.46.4
# software id = 5DWL-EDZZ
#
# model = 751G-2HnD
/interface bridge
add admin-mac=00:0C:42:FB:C7:47 auto-mac=no comment=defconf name=bridge
/interface ethernet
set [ find default-name=ether1 ] disabled=yes
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/ip pool
add name=dhcp ranges=192.168.88.10-192.168.88.254
/ip dhcp-server
add address-pool=dhcp disabled=no interface=bridge name=defconf
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=wlan1
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
add interface=ether5 list=WAN
/ip address
add address=192.168.88.1/24 comment=defconf interface=ether2 network=192.168.88.0
add address=87.87.87.87/24 interface=ether5 network=87.87.87.0
/ip dhcp-client
add comment=defconf disabled=no interface=ether1
/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 servers=1.1.1.1
/ip dns static
add address=192.168.88.1 comment=defconf name=router.lan
/ip firewall filter
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" connection-state=established,related
add action=accept chain=input comment="defconf: accept established,related,untracked" connection-state=established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=forward comment="accept forwarded ports" dst-port=80 protocol=tcp
add action=accept chain=input comment="defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" ipsec-policy=out,ipsec
add action=accept chain=forward comment="defconf: accept established,related, untracked" connection-state=established,related,untracked
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-list=WAN
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" ipsec-policy=out,none out-interface=ether1
add action=masquerade chain=srcnat comment="defconf: masquerade" ipsec-policy=out,none out-interface=ether5
add action=dst-nat chain=dstnat comment="services on MPE" dst-address=87.87.87.87 dst-port=80 protocol=tcp to-addresses=192.168.88.80
/ip route
add distance=20 gateway=87.87.87.1
set winbox address=192.168.0.0/16
set api-ssl disabled=yes
/system clock
set time-zone-name=Europe/Riga
/system ntp client
set enabled=yes primary-ntp=192.168.88.80
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN
on spare RB-751G and get the same results, if I enable ether1, ether5 came unreachable from outside, PING stops, forwarded web server on 80 port stops respond, but internet connection to outgoing connections switches from ether5 to ether1 and gets ~500/500 Mbps
and for clear experiment, I remove all LAN devices, just connect to RB-751G ether1, ether5 as WANs and one Windows 10 notebook to ether3 as LAN device. results - all as previous - if I turn on ether1, ether5 stops respond from outside
There do not appear to be any mangle rules or additional routing tables to properly support dual WAN operation. Replies to traffic arriving from either ISP1 or ISP2 will return via the best default route to ISP1 - this may have accidentally worked until the nightly engineering works correctly blocked this traffic.
I’m sure load balancing with dynamic gateways will have cropped up before in the forums - a script triggered by the DHCP client, or possibly using routing filters.
It depends on what you need - if all traffic will be to/from ISP1, other than replies to that coming from ISP2, instead of full load balancing you could get away with something like
/ip firewall mangle
add chain=prerouting dst-address=87.87.87.87/24 action=accept in-interface=LAN
add chain=prerouting in-interface=ether5 connection-mark=no-mark action=mark-connection new-connection-mark=ISP2_conn
add chain=prerouting connection-mark=ISP2_conn in-interface=LAN action=mark-routing new-routing-mark=to_ISP2
add chain=output connection-mark=ISP2_conn action=mark-routing new-routing-mark=to_ISP2
1st mangle rule I in dst-address put 87.87.87.0/24 as ‘ip address expected’ or I must use 87.87.87.87?
2nd and 3rd I use In. Interface List=LAN or in-interface=bridge
this corrects “half” of problems one time - if I enable ether1, ether5 no stop answering on PINGs, but inside servers came unreachable from outside
and after next disable/enable eth1, eth5 stopped answer on outside PINGs completely if eth1 is enabled
p.s.
as You say - “load balancing with dynamic gateways will have cropped up before in the forums” - but it was answers and fragments from some configurations, not complete tutorial
after upgrade to v7.* and ISP blocking any ICMP beyond gateway, old problem comes again, if if optics with DHCP is enabled, routing messes and port forwarding don’t work. corrected via adopting DHCP script to v7.*
routing rule
instead
ip route rule
as in v6.*
another correction in “recursion” route, now ISP gateway, not 4.2.2.1, which isn’t pingable from this ISP
Dual wan works very well.
What is not clear is the requirements, so I have to guess.
WAN1 is primary should run most traffic all the time. If WAN1 fails you want users to go to WAN2?
WAN2 is secondary, handles servers all the time. If WAN2 fails you want servers accessible on WAN1? add distance=1 check-gateway=ping dst-address=0.0.0.0/0 gateway=ISP1-gatewayIP routing-table=main comment=MyStatic
add distance=2 check-gateway=ping dst-address=0.0.0.0/0 gateway=ISP2-gatewayIP routing table=main comment=MyDynamic
Thats the starting point for two fixed static WANIPs.
If you have a dynamic WANIP you need to ensure the gateway IP is updated via script.
So in the IP DHCP client area under ADVANCED TAB enter the following script:
Since you have servers that need to work on WAN2 all the time, we will need to ensure that external traffic hitting the WANs heading to the servers, goes out the same WAN. We do both WANs in case WAN2 is down and we use WAN1 for servers…
NOTE: firewall address list Servers, contains the IP addresses of all servers…
Basically this marks any traffic coming on the WAN with the appropriate connection marks.
Then any traffic with these marks coming from the servers (reply traffic), gets sent out the same WAN they came in on.
To complete the config we need tables and routes.
And then the routes add dst-address=0.0.0.0/0 gateway=ISP1-gatewayIP routing-table=to-WAN1
add dst-address=0.0.0.0/0 gateway=ISP2-gatewayIP routing-table=to-WAN2 comment=MyDynamic