Thanks for taking a look. My configs are below.
Using the diagram above this is how wired:
switch sfp-sfpplus1 → router1 sfp-sfpplus1
switch ether6 → router2 ether2
router1 ether1 → ISP1
router2 ether1 → ISP2
workstation → ether17 (when testing vlan20)
workstation → ether19 (when testing default vlan)
Desired Behavior:
-
If router1 fails, then use router2: uses VRRP. PASS with both default vlan and vlan20. VRRP .254 def gateway must be used.
-
Any machine to directly use router1 or router2 (.1 or .2) gateways directly. PASS. I need this for my monitoring code to verify health of network as well as using vtrunkd.
-
if ISP1 fails, then route out router2 AND support for PBR using mangle and address lists: uses routing rules and filters, PASS with default vlan IFF default gateway is NOT VRRP. FAIL with vlan20.
If I dump router2, put ISP2 on router1 ether2, and change that to be marked as isp2, then everything in #3 works as expected (this is my current running solution on a different router; the configs below are in a lab getting ready for deployment). OTOH, I do not have a 2nd router or VRRP. Not a huge issue, but I figured why not? since I’ll have a 2nd rack mount router. The HeX playing the role of router2 is just a place holder.
Other things I have tried:
- disable fasttrack. I’ve had issues with fasttrack and vlans in the past.
- Connect ether3 to ether3 of the routers and use a different subnet to route from 1 to 2.
Switch:
# sep/10/2017 08:19:40 by RouterOS 6.41rc26
# software id = 4HJ8-GWWB
#
# model = CRS326-24G-2S+
/interface bridge
add admin-mac=XX:XX:XX:XX:XX:XX auto-mac=no igmp-snooping=no name=bridge1 vlan-filtering=yes
/interface vlan
add interface=bridge1 name=vlan20 vlan-id=20
/interface bridge port
add bridge=bridge1 interface=ether1
add bridge=bridge1 interface=ether2
add bridge=bridge1 interface=ether3
add bridge=bridge1 interface=ether4
add bridge=bridge1 interface=ether5
add bridge=bridge1 interface=ether6
add bridge=bridge1 interface=ether7
add bridge=bridge1 interface=ether8
add bridge=bridge1 interface=ether9
add bridge=bridge1 interface=ether10
add bridge=bridge1 interface=ether11
add bridge=bridge1 interface=ether12
add bridge=bridge1 interface=ether13
add bridge=bridge1 interface=ether14
add bridge=bridge1 interface=ether15
add bridge=bridge1 interface=ether16
add bridge=bridge1 interface=ether17 pvid=20
add bridge=bridge1 interface=ether18
add bridge=bridge1 interface=ether19
add bridge=bridge1 interface=ether20
add bridge=bridge1 interface=ether21
add bridge=bridge1 interface=ether22
add bridge=bridge1 interface=ether23
add bridge=bridge1 interface=ether24
add bridge=bridge1 interface=sfp-sfpplus1
add bridge=bridge1 interface=sfp-sfpplus2
/interface bridge vlan
add bridge=bridge1 tagged=sfp-sfpplus1,ether6 untagged=ether17 vlan-ids=20-30
/ip address
add address=172.16.1.1/16 interface=bridge1 network=172.16.0.0
add address=172.20.1.1/16 interface=vlan20 network=172.20.0.0
/ip route
add distance=1 gateway=172.16.0.1
/system identity
set name=switch
/system package update
set channel=release-candidate
/system routerboard settings
set boot-os=router-os
router1:
/interface bridge
add fast-forward=no name=bridge1
/interface vrrp
add interface=sfp-sfpplus1 name=vrrp1 priority=254
/interface vlan
add interface=sfp-sfpplus1 name=vlan20 vlan-id=20
/interface vrrp
add interface=vlan20 name=vrrp20 priority=254 vrid=20
/interface list
add name=external
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/routing bgp instance
set default as=100 disabled=yes
/interface bridge port
add bridge=bridge1 interface=ether4
add bridge=bridge1 interface=ether5
add bridge=bridge1 interface=ether6
add bridge=bridge1 interface=ether7
add bridge=bridge1 interface=combo1
/interface list member
add interface=ether1 list=external
add disabled=yes interface=ether2 list=external
/ip address
add address=172.16.0.254 interface=vrrp1 network=172.16.0.254
add address=172.16.0.1/16 interface=sfp-sfpplus1 network=172.16.0.0
add address=172.20.0.1/16 interface=vlan20 network=172.20.0.0
add address=172.20.0.254 interface=vrrp20 network=172.20.0.254
/ip dhcp-client
add disabled=no interface=ether1
/ip firewall address-list
add address=172.20.1.10 comment="preferisp2, failover to isp1" disabled=yes list=preferisp2
add address=172.20.1.10 comment="only out isp1" disabled=yes list=onlyisp1
add address=172.20.1.10 comment="preferisp1, failover to isp2" disabled=yes list=preferisp1
add address=172.20.1.10 comment="only out isp2" disabled=yes list=onlyisp2
add address=172.16.1.10 comment="preferisp2, failover to isp1" disabled=yes list=preferisp2
add address=172.16.1.10 comment="only out isp1" disabled=yes list=onlyisp1
add address=172.16.1.10 comment="preferisp1, failover to isp2" disabled=yes list=preferisp1
add address=172.16.1.10 comment="only out isp2" disabled=yes list=onlyisp2
/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="drop all from WAN, external interface list" in-interface-list=external
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="drop all from WAN not DSTNATed, external interface list" connection-nat-state=\
!dstnat connection-state=new in-interface-list=external
/ip firewall mangle
add action=mark-routing chain=prerouting comment="prefer isp1, failover to isp2 (default)" new-routing-mark=preferisp1 \
passthrough=yes
add action=mark-routing chain=prerouting comment="only out isp1 (onlyisp1 address list)" new-routing-mark=onlyisp1 \
passthrough=yes src-address-list=onlyisp1
add action=mark-routing chain=prerouting comment="prefer isp2, failover to isp1 (preferisp2 address list)" disabled=\
yes new-routing-mark=preferisp2 passthrough=no src-address-list=preferisp2
add action=mark-routing chain=prerouting comment="only out isp2 (onlyisp2 address list)" new-routing-mark=onlyisp2 \
passthrough=yes src-address-list=onlyisp2
/ip firewall nat
add action=masquerade chain=srcnat comment="external interface list" out-interface-list=external
/ip route
add check-gateway=ping distance=2 gateway=172.16.0.2 routing-mark=isp2
/ip route rule
add comment="isp1 only / disallow failover" routing-mark=onlyisp1 table=main
add routing-mark=onlyisp1 table=isp1
add action=unreachable routing-mark=onlyisp1
add comment="prefer isp1 but allow failover to isp2" routing-mark=preferisp1 table=main
add routing-mark=preferisp1 table=isp1
add routing-mark=preferisp1 table=isp2
add comment="isp2 only / disallow failover" routing-mark=onlyisp2 table=main
add routing-mark=onlyisp2 table=isp2
add action=unreachable routing-mark=onlyisp2
add comment="prefer isp2 but allow failover" disabled=yes routing-mark=preferisp2 table=main
add disabled=yes routing-mark=preferisp2 table=isp2
add disabled=yes routing-mark=preferisp2 table=isp1
add comment="unmarked traffic" table=main
add table=isp1
add table=isp2
/lcd
set backlight-timeout=never color-scheme=dark default-screen=interfaces
/lcd interface
set sfp-sfpplus1 disabled=yes
set combo1 disabled=yes
set ether2 disabled=yes
set ether3 disabled=yes
set ether4 disabled=yes
set ether5 disabled=yes
set ether6 disabled=yes
set ether7 disabled=yes
/routing bgp peer
add disabled=yes in-filter=from-router2 name=router2 remote-address=172.16.0.2 remote-as=100
/routing filter
add chain=dynamic-in distance=1 prefix=0.0.0.0 prefix-length=0 set-check-gateway=ping set-routing-mark=isp1
add bgp-local-pref=100 chain=from-router2 disabled=yes set-check-gateway=ping set-distance=3 set-routing-mark=isp3
/system identity
set name=router1
router2:
# sep/10/2017 08:47:41 by RouterOS 6.41rc26
# software id = 8CFI-AN74
#
# model = 960PGS
/interface bridge
add admin-mac=XX:XX:XX:XX:XX:XX auto-mac=no comment=defconf fast-forward=no igmp-snooping=no name=bridge1
/interface ethernet
set [ find default-name=ether2 ] poe-out=off
set [ find default-name=ether3 ] poe-out=off
/interface vrrp
add interface=ether2 name=vrrp1
/ip neighbor discovery
set ether1 discover=no
/interface vlan
add interface=ether2 name=vlan20 vlan-id=20
/interface vrrp
add interface=vlan20 name=vrrp20 vrid=20
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip hotspot profile
set [ find default=yes ] html-directory=flash/hotspot
/port
set 0 baud-rate=115200 name=usb1
/routing bgp instance
set default as=100 client-to-client-reflection=no disabled=yes redistribute-connected=yes
/interface bridge port
add bridge=bridge1 comment=defconf disabled=yes interface=ether2
add bridge=bridge1 comment=defconf hw=no interface=sfp1
add bridge=bridge1 disabled=yes interface=ether3
add bridge=bridge1 interface=ether4
add bridge=bridge1 interface=ether5
/interface bridge vlan
add bridge=bridge1 disabled=yes tagged=ether2 vlan-ids=20
/ip address
add address=172.16.0.2/16 comment=defconf interface=ether2 network=172.16.0.0
add address=172.16.0.254 interface=vrrp1 network=172.16.0.254
add address=172.20.0.2/16 interface=vlan20 network=172.20.0.0
add address=172.20.0.254 interface=vrrp20 network=172.20.0.254
/ip dhcp-client
add comment=defconf dhcp-options=hostname,clientid disabled=no interface=ether1
/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
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
/ip firewall mangle
add action=mark-routing chain=prerouting comment="only out isp2 (onlyisp2 address list)" disabled=yes \
new-routing-mark=onlyisp2 passthrough=yes src-address-list=onlyisp2
add action=mark-routing chain=prerouting comment="prefer isp2, failover to isp1 (default)" disabled=yes \
new-routing-mark=preferisp2 passthrough=yes
add action=mark-routing chain=prerouting comment="prefer isp1, failover to isp2 (preferisp1 address list)" disabled=\
yes new-routing-mark=preferisp1 passthrough=yes src-address-list=preferisp1
add action=mark-routing chain=prerouting comment="only out isp1 (onlyisp1 address list)" disabled=yes \
new-routing-mark=onlyisp1 src-address-list=onlyisp1
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" out-interface=ether1
/ip route rule
add comment="isp2 only / disallow failover" routing-mark=onlyisp2 table=main
add routing-mark=onlyisp2 table=isp2
add action=unreachable routing-mark=onlyisp2
add comment="prefer isp2 but allow failover to isp1" disabled=yes routing-mark=preferisp2 table=main
add disabled=yes routing-mark=preferisp2 table=isp2
add disabled=yes routing-mark=preferisp2 table=isp1
add comment="isp1 only / disallow failover" disabled=yes routing-mark=onlyisp1 table=main
add disabled=yes routing-mark=onlyisp1 table=isp1
add action=unreachable disabled=yes routing-mark=onlyisp1
add comment="prefer isp1 but allow failover" disabled=yes routing-mark=preferisp1 table=main
add disabled=yes routing-mark=preferisp1 table=isp1
add disabled=yes routing-mark=preferisp1 table=isp2
add comment="unmarked traffic" table=main
add table=isp2
add disabled=yes table=isp1
/ip smb shares
set [ find default=yes ] directory=/pub
/routing bgp peer
add disabled=yes name=router1 out-filter=to_router1 remote-address=172.16.0.1 remote-as=100
/routing filter
add chain=dynamic-in distance=1 prefix=0.0.0.0 prefix-length=0 set-check-gateway=ping set-routing-mark=isp2
add action=discard chain=to_router1 disabled=yes prefix=10.0.0.0/24
add action=discard chain=to_router1 disabled=yes prefix=172.16.0.0/16
add action=discard chain=to_router1 disabled=yes prefix=172.20.0.0/16
/system identity
set name=router2
/system package update
set channel=release-candidate
/tool graphing interface
add
/tool mac-server
set [ find default=yes ] disabled=yes
add interface=bridge1
/tool mac-server mac-winbox
set [ find default=yes ] disabled=yes
add interface=bridge1