Do not try to explain that to me, instead read...Pinging the Gateway won't guarantee Internet access!
/ip route
set [find where comment~"ISP1"] gateway=$"gateway-address"
/ip route
set [find where comment~"ISP2"] gateway=$"gateway-address"
/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=2.3.4.5 scope=10
add comment="B - Recursive Routing, check ping 1.1.1.1 instead of ISP IP" distance=10 gateway=1.1.1.1 check-gateway=ping
add comment="C - ISP2 is alternative Gateway" distance=20 gateway=6.7.8.9
[admin@MikroTik] > /ip/route print
Flags: D - DYNAMIC; I - INACTIVE, A - ACTIVE; c - CONNECT, s - STATIC, y - COPY; H - HW-OFFLOADED
Columns: DST-ADDRESS, GATEWAY, DISTANCE
# DST-ADDRESS GATEWAY DI
;;; C - ISP2 is alternative Gateway
0 As 0.0.0.0/0 172.16.50.1 20
;;; B - Recursive Routing, check ping 1.1.1.1 instead of ISP IP
1 IsH 0.0.0.0/0 1.1.1.1 10
;;; A - 1.1.1.1 must be reachabble only from ISP1
2 As 1.1.1.1/32 77.109.171.1 1
DAc 77.109.171.0/24 init7 0
DAc 172.16.50.0/24 50 0
DAc 172.16.90.0/24 90 0
DAc 192.168.88.0/24 lan 0
3 As 192.168.99.0/24 172.16.50.1 1
[admin@MikroTik] > /tool/traceroute 1.1.1.1
Columns: ADDRESS, LOSS, SENT, LAST, AVG, BEST, WORST, STD-DEV
# ADDRESS LO S LAST AVG BES WOR STD
1 77.109.183.62 0% 2 7.3ms 7.4 7.3 7.4 0.1
2 77.109.183.61 0% 2 8ms 7.7 7.4 8 0.3
3 82.197.168.35 0% 2 9ms 8.4 7.7 9 0.7
4 194.42.48.14 0% 2 7.7ms 7.6 7.5 7.7 0.1
5 1.1.1.1 0% 2 7ms 7 6.9 7 0.1
[admin@MikroTik] > /tool/traceroute 8.8.8.8
Columns: ADDRESS, LOSS, SENT, LAST, AVG, BEST, WORST, STD-DEV
# ADDRESS LO S LAST AVG BES WOR S
1 172.16.50.3 0% 1 0.6ms 0.6 0.6 0.6 0
2 77.109.183.62 0% 1 7.7ms 7.7 7.7 7.7 0
3 77.109.183.61 0% 1 7.9ms 7.9 7.9 7.9 0
4 5.180.135.161 0% 1 7.9ms 7.9 7.9 7.9 0
5 77.109.135.214 0% 1 7.3ms 7.3 7.3 7.3 0
6 74.125.243.161 0% 1 8.8ms 8.8 8.8 8.8 0
7 172.253.50.19 0% 1 8.5ms 8.5 8.5 8.5 0
8 8.8.8.8 0% 1 7.7ms 7.7 7.7 7.7 0
Yes... you run beta 7, the script and route are for 6.46+ version,Did I miss something?
Hi rextended, my ccr1009 is on version 6 LOL. The RB450Gx4 behind my hex (acting as a switch) and connected to the CCR1009 is running v7 beta6 as a wireguard router,/server mainly for the purposes of connecting to an RB4011 acting as wireguard client router, behind a Bell ISP device (combo modem/router) at a different location.Yes... you run beta 7, the script and route are for 6.46+ version,Did I miss something?
on beta7 the routing is totally different....
You wrote in beginner basics section ,the question for 7 beta must be go on adequate section...
Um, sometimes I take too many things for granted......read the link and then be relieved that the example provided is so simple in comparison to the Russian complex methods LOL...
/ip fire conn
:foreach idc in=[find where timeout>60] do={
remove [find where .id=$idc]
}
:global newIP [:tostr $"local-address"]
/ip fire conn
:foreach idc in=[find where timeout>60 and (!(reply-dst-address~$newIP))] do={
remove [find where .id=$idc]
}
Clear connection-tracking is needed because remote address unreachable do not cause the clear of connection-tracking.
What access method you use?
#
# software = RouterOS 6.47.10
# model = RouterBOARD 952Ui-5ac2nD (hAP AC Lite)
###########################################################
# A router with WAN failover to two uplinks on
# ether2 and ether3.
###########################################################
/system identity set name=R1
# The two ISP WAN connections
/ip dhcp-client
add add-default-route=no disabled=no interface=ether2 use-peer-dns=no comment="ISP1"
add add-default-route=no disabled=no interface=ether3 use-peer-dns=no comment="ISP2"
# Route failover by checking two hosts
/ip route
add check-gateway=ping distance=1 gateway=8.8.8.8 comment=Host1
add check-gateway=ping distance=2 gateway=9.9.9.9 comment=Host2
add distance=1 dst-address=8.8.8.8/32 gateway=10.3.30.1 scope=10 comment=ISP1_check
add distance=2 dst-address=9.9.9.9/32 gateway=10.3.30.1 scope=10 comment=ISP1_check
add distance=3 gateway=10.4.40.1 comment=ISP2
###########################################################
# Example LAN environment
###########################################################
/interface bridge add name=BR1 protocol-mode=none vlan-filtering=yes
/interface vlan add interface=BR1 name=VLAN1 vlan-id=44
/interface bridge port add bridge=BR1 interface=ether5 pvid=44
/interface bridge vlan add bridge=BR1 tagged=BR1 vlan-ids=44
/ip address add address=10.44.40.1/24 interface=VLAN1 network=10.44.40.0
/ip pool add name=POOL1 ranges=10.44.40.2-10.44.40.254
/ip dhcp-server add address-pool=POOL1 disabled=no interface=VLAN1 name=DHCP1
/ip dhcp-server network add address=10.44.40.0/24 dns-server=10.44.40.1 gateway=10.44.40.1
/interface list
add name=WAN
add name=VLAN
add name=BASE
/interface list member
add interface=ether2 list=WAN
add interface=ether3 list=WAN
add interface=VLAN1 list=VLAN
/ip dns set allow-remote-requests=yes servers=9.9.9.9,8.8.8.8
/ip firewall filter
add action=accept chain=input connection-state=established,related comment="Allow Estab & Related"
add action=accept chain=input in-interface-list=VLAN comment="Allow VLANs"
add action=drop chain=input comment=Drop
add action=accept chain=forward connection-state=established,related comment="Allow Estab & Related"
add action=accept chain=forward connection-state=new in-interface-list=VLAN out-interface-list=WAN comment="Allow VLANs"
add action=drop chain=forward comment=Drop
/ip firewall nat add action=masquerade chain=srcnat out-interface-list=WAN comment="Default masquerade"
#
# software = RouterOS 6.47.10
# model = RouterBOARD 750UP r2 (hEX PoE Lite)
###########################################################
# Test router representing two ISP providers.
# ISP1 on ether3 and ISP2 on ether4
# See the two firewall rules that simulate network down.
###########################################################
/system identity set name=ISP_Provider
/interface ethernet
set [ find default-name=ether3 ] comment=ISP1
set [ find default-name=ether4 ] comment=ISP2
###########################################################
# Example environment provided by this Test ISP
###########################################################
/interface bridge
add fast-forward=no name=BR1 protocol-mode=none vlan-filtering=yes
/interface vlan
add interface=BR1 name=VLAN_ISP1 vlan-id=30
add interface=BR1 name=VLAN_ISP2 vlan-id=40
/interface list
add name=WAN
add name=VLAN
add name=BASE
/ip pool
add name=POOL1 ranges=10.3.30.2-10.3.30.254
add name=POOL2 ranges=10.4.40.2-10.4.40.254
/ip dhcp-server
add address-pool=POOL1 disabled=no interface=VLAN_ISP1 name=DHCP1
add address-pool=POOL2 disabled=no interface=VLAN_ISP2 name=DHCP2
/interface bridge port
add bridge=BR1 interface=ether3 pvid=30
add bridge=BR1 interface=ether4 pvid=40
/interface bridge vlan
add bridge=BR1 tagged=BR1 vlan-ids=30
add bridge=BR1 tagged=BR1 vlan-ids=40
/interface list member
add interface=ether1 list=WAN
add interface=VLAN_ISP1 list=VLAN
add interface=VLAN_ISP2 list=VLAN
/ip address
add address=10.3.30.1/24 interface=VLAN_ISP1 network=10.3.30.0
add address=10.4.40.1/24 interface=VLAN_ISP2 network=10.4.40.0
/ip dns set allow-remote-requests=yes
/ip dhcp-client add dhcp-options=hostname disabled=no interface=ether1
/ip dhcp-server network
add address=10.3.30.0/24 dns-server=10.3.30.1 gateway=10.3.30.1
add address=10.4.40.0/24 dns-server=10.4.40.1 gateway=10.4.40.1
/ip firewall filter
add action=accept chain=input connection-state=established,related comment="Allow Estab & Related"
add action=accept chain=input in-interface-list=VLAN comment="Allow VLANs"
add action=drop chain=input comment=Drop
###########################################################
# These two rules test causing failover to occur
###########################################################
add action=drop chain=forward disabled=yes dst-address=8.8.8.8 src-address=10.3.30.0/24 comment="Enable to test Host1 Failure"
add action=drop chain=forward disabled=yes dst-address=9.9.9.9 src-address=10.3.30.0/24 comment="Enable to test Host2 Failure"
add action=accept chain=forward connection-state=established,related comment="Allow Estab & Related"
add action=accept chain=forward connection-state=new in-interface-list=VLAN out-interface-list=WAN comment="Allow VLANs"
add action=drop chain=forward comment=Drop
/ip firewall nat add action=masquerade chain=srcnat comment="Default masquerade" out-interface-list=WAN
When the failover is active... and when go back online the main line, and the failover is not activehow do I know when to fire a script to do this?
:global something
:if ([:len [/ip route find where comment="ISP2" and active=yes]] > 0) do={
:if ($something != true) do={
/ip fire conn
:foreach idc in=[find where timeout>60] do={ remove [find where .id=$idc] }
:set something true
}
} else={
:if ($something != false) do={
/ip fire conn
:foreach idc in=[find where timeout>60] do={ remove [find where .id=$idc] }
:set something false
}
}
If just one connection on connection tracking is already closed for timeout (or other reasons) during the execution of the clean,
the script will stop with error because the connection is already closed, and do not finish his works.
???I need > 9 seconds of closing capability.
I do not insist further, I have already written you the script that does the right job,
based on the real traffic of equipment in production and not only theoretically simulated.
pcunite, I do not understand what you are discussing regarding clearing connections. Is this something I should be worried about on my setup?