I have two places (home and office) which are connected via wireguard interface. At “office” I have two networks 192.168.1.0/24 and 192.168.2.0/24 (let’s call them “remote networks”). At home I need two networks:
- Home Router 192.168.99.0/24 (vlan 99)
a. Route traffic for remote subnets on Office router through wireguard connection
b. Route all other traffic through the local WAN at home.
It is just ordinary local network. Here I need access to “remote networks”. The trace to 8.8.8.8 must be smth like
- 192.168.99.1
- 87.87.87.87 ← It’s ISP gateway at home
- Home Router 192.168.42.0/24 (vlan 42)
a. Route local traffic as expected ( either originating traffic on vlan XX to other local vlans, or return traffic/answer to those local vlans )
b. Route all other traffic through Wireguard to the office router.
It’s a route_everything_to_office_network. I want to route all traffic from unknown networks (aka default route) to “office” router. The trace to 8.8.8.8 must be smth like
- 192.168.42.1
- 192.168.4.1
- 88.88.88.88 ← It’s ISP gateway at office
In other words, for local network only packages with dest network 192.168.1.0/24 and 192.168.2.0/24 must be routed to the office router.
In contrast, for route_everything_to_office_network all packages but with dest network 192.168.42.0/24 and 192.168.99.0/24 must be routed to the office router.
I don’t need any device from remote networks has access any home networks.
The router at “office” is not a Mikrotik device. But I believe it was properly configured. Moreover I used to have openwrt router at home with similar setup and it worked just as expected.
My new Mikrotik router at home somehow works in configuration below.
I use a routing rule for route_everything_to_office_network.
/routing rule add action=lookup-only-in-table interface=vlan-office routing-mark=main table=office
But I need more complicated rules so I want use mangle instead of /routing rule. However as soon as I enable
/ip firewall mangle add action=mark-routing chain=prerouting disabled=yes in-interface=vlan-office new-routing-mark=office passthrough=yes
the route_everything_to_office_network don’t have access to any local network. I even cannot use DNS at 192.168.42.1. However all traffic goes to “office” router, and if I change DNS to 1.1.1.1 I could have access to the Internet from “route_everything_to_office_network” (via “office” router, just as expected).
Could someone explain what I missed and why it works with a routing rule but not with a mangle in my case?
Here is a config of “home” router
/interface bridge
add name=bridge_vlan pvid=99 vlan-filtering=yes
/interface lte
set [ find default-name=lte1 ] allow-roaming=no band=""
/interface wireguard
add listen-port=13231 mtu=1420 name=wg-office
/interface vlan
add interface=bridge_vlan name=vlan-local vlan-id=99
add interface=bridge_vlan name=vlan-smart vlan-id=10
add interface=bridge_vlan name=vlan-office vlan-id=42
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/ip pool
add name=default-dhcp ranges=192.168.88.10-192.168.88.254
add comment=smart name=dhcp-pool-smart ranges=192.168.10.150-192.168.10.250
add comment=office name=dhcp-pool-office ranges=192.168.42.150-192.168.42.250
add comment=local name=dhcp-pool-local ranges=192.168.99.150-192.168.99.250
/ip dhcp-server
add address-pool=default-dhcp interface=bridge lease-time=10m name=defconf
add add-arp=yes address-pool=dhcp-pool-smart comment=smart interface=vlan-smart name=dhcp-smart
add add-arp=yes address-pool=dhcp-pool-office comment=office interface=vlan-office name=dhcp-office
add add-arp=yes address-pool=dhcp-pool-local comment=local interface=vlan-local name=dhcp-local
/routing table
add disabled=no fib name=office
/interface bridge port
add bridge=bridge comment=defconf interface=ether1
add bridge=bridge_vlan comment=defconf frame-types=admit-only-untagged-and-priority-tagged interface=ether2 pvid=10
add bridge=bridge_vlan comment=defconf frame-types=admit-only-untagged-and-priority-tagged interface=ether3 pvid=42
add bridge=bridge_vlan comment=defconf frame-types=admit-only-untagged-and-priority-tagged interface=ether4 pvid=99
add bridge=bridge_vlan comment=defconf frame-types=admit-only-vlan-tagged interface=ether5
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface bridge vlan
add bridge=bridge_vlan tagged=bridge_vlan,ether5 untagged=ether2 vlan-ids=10
add bridge=bridge_vlan tagged=bridge_vlan,ether5 untagged=ether3 vlan-ids=42
add bridge=bridge_vlan tagged=bridge_vlan,ether5 untagged=ether4 vlan-ids=99
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=lte1 list=WAN
add interface=vlan-local list=LAN
add interface=vlan-smart list=LAN
add interface=vlan-office list=LAN
add interface=wg-office list=WAN
/interface wireguard peers
add allowed-address=0.0.0.0/0 interface=wg-office
/ip address
add address=192.168.88.1/24 comment=defconf interface=bridge network=192.168.88.0
add address=192.168.4.3/24 interface=wg-office network=192.168.4.0
add address=192.168.10.1/24 comment=smart interface=vlan-smart network=192.168.10.0
add address=192.168.42.1/24 comment=office interface=vlan-office network=192.168.42.0
add address=192.168.99.1/24 comment=local interface=vlan-local network=192.168.99.0
/ip dhcp-server network
add address=192.168.10.0/24 comment=smart dns-server=192.168.10.1 gateway=192.168.10.1
add address=192.168.42.0/24 comment=office dns-server=192.168.42.1 gateway=192.168.42.1
add address=192.168.88.0/24 comment=defconf dns-server=192.168.88.1 gateway=192.168.88.1
add address=192.168.99.0/24 comment=local dns-server=192.168.99.1 gateway=192.168.99.1
/ip firewall filter
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=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=fasttrack-connection chain=forward comment="defconf: fasttrack" connection-state=established,related hw-offload=yes
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 mangle
add action=mark-routing chain=prerouting disabled=yes in-interface=vlan-office new-routing-mark=office passthrough=yes
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" ipsec-policy=out,none out-interface-list=WAN
add action=src-nat chain=srcnat out-interface=wg-office to-addresses=192.168.4.3
/ip route
add disabled=no distance=1 dst-address=192.168.1.0/24 gateway=wg-office pref-src=0.0.0.0 routing-table=office scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=1 dst-address=192.168.2.0/24 gateway=wg-office pref-src=0.0.0.0 routing-table=office scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=10 dst-address=0.0.0.0/0 gateway=wg-office pref-src=0.0.0.0 routing-table=office scope=30 suppress-hw-offload=no target-scope=10
/ipv6 firewall address-list
add address=::/128 comment="defconf: unspecified address" list=bad_ipv6
add address=::1/128 comment="defconf: lo" list=bad_ipv6
add address=fec0::/10 comment="defconf: site-local" list=bad_ipv6
add address=::ffff:0.0.0.0/96 comment="defconf: ipv4-mapped" list=bad_ipv6
add address=::/96 comment="defconf: ipv4 compat" list=bad_ipv6
add address=100::/64 comment="defconf: discard only " list=bad_ipv6
add address=2001:db8::/32 comment="defconf: documentation" list=bad_ipv6
add address=2001:10::/28 comment="defconf: ORCHID" list=bad_ipv6
add address=3ffe::/16 comment="defconf: 6bone" list=bad_ipv6
/ipv6 firewall filter
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 ICMPv6" protocol=icmpv6
add action=accept chain=input comment="defconf: accept UDP traceroute" port=33434-33534 protocol=udp
add action=accept chain=input comment="defconf: accept DHCPv6-Client prefix delegation." dst-port=546 protocol=udp src-address=fe80::/10
add action=accept chain=input comment="defconf: accept IKE" dst-port=500,4500 protocol=udp
add action=accept chain=input comment="defconf: accept ipsec AH" protocol=ipsec-ah
add action=accept chain=input comment="defconf: accept ipsec ESP" protocol=ipsec-esp
add action=accept chain=input comment="defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=input comment="defconf: drop everything else not coming from LAN" in-interface-list=!LAN
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 packets with bad src ipv6" src-address-list=bad_ipv6
add action=drop chain=forward comment="defconf: drop packets with bad dst ipv6" dst-address-list=bad_ipv6
add action=drop chain=forward comment="defconf: rfc4890 drop hop-limit=1" hop-limit=equal:1 protocol=icmpv6
add action=accept chain=forward comment="defconf: accept ICMPv6" protocol=icmpv6
add action=accept chain=forward comment="defconf: accept HIP" protocol=139
add action=accept chain=forward comment="defconf: accept IKE" dst-port=500,4500 protocol=udp
add action=accept chain=forward comment="defconf: accept ipsec AH" protocol=ipsec-ah
add action=accept chain=forward comment="defconf: accept ipsec ESP" protocol=ipsec-esp
add action=accept chain=forward comment="defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=forward comment="defconf: drop everything else not coming from LAN" in-interface-list=!LAN
/routing rule
add action=lookup-only-in-table disabled=no dst-address=192.168.1.0/24 routing-mark=main table=office
add action=lookup-only-in-table disabled=no dst-address=192.168.2.0/24 routing-mark=main table=office
add action=lookup-only-in-table disabled=no interface=vlan-office routing-mark=main table=office
cfg.rsc (8.25 KB)
