First of all, I'd like to say thanks for all of the great resources in this forum. I have been reading loads and learning a lot, but I am now stuck on my little VLAN <-> Wireguard setup.
Setup and goals:
- MikroTIk hAP ac2 that connects a switch to the internet and provides IP services and routing (RoaS) (I followed viewtopic.php?f=23&t=143620 for the base setup: VLAN, DHCP, PPPoE)
- One trunk port carries untagged and tagged traffic between the switch and MikroTik router (native LAN and one VLAN) ✅
- Router assigns IP addresses for the LAN and VLAN ✅
- Untagged traffic (native network) should flow over the PPPoE connection ✅
- VLAN traffic should be tunneled through the Wireguard connection (I am using the v7 beta) ❌
After having established the base, I followed viewtopic.php?f=1&t=173952 for the Wireguard setup. The Wireguard connection stands and I can ping the peer, but I am struggling to get VLAN traffic routed through the Wireguard interface. I think I am missing something in the routing and firewall section.
Here is my config (/export compact):
Code: Select all
# Interfaces
/interface bridge
add admin-mac=XX:XX:XX:XX:XX:XX auto-mac=no comment=defconf name=bridge vlan-filtering=yes
/interface pppoe-client
add add-default-route=yes disabled=no interface=ether1 keepalive-timeout=disabled name=pppoe-out1 \
password=***** user=*****
/interface wireguard
add listen-port=13231 mtu=1420 name=wireguard-1 private-key=\
"XXXXXXXXXXXXXXXXXXX"
# Edit: Error 1 was located here. WebFig v7.1 beta6 doesn't allow to specify allowed-address in the UI (bug)
/interface wireguard peers
add comment=peer1 endpoint-address=HOST_IP endpoint-port=51820 interface=wireguard-1 \
persistent-keepalive=30s public-key="XXXXXXXXX" allowed-address=0.0.0.0/0
/interface vlan
add interface=bridge name=vlan20 vlan-id=20
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
add name=VLAN
/interface bridge port
add bridge=bridge comment=defconf ingress-filtering=yes interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
/interface bridge vlan
add bridge=bridge tagged=bridge,ether2,ether3,ether4 vlan-ids=20
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
add interface=ether5 list=LAN
add interface=pppoe-out1 list=WAN
add interface=vlan20 list=VLAN
add interface=vlan20 list=LAN
add interface=wireguard-1 list=VLAN
# Adresses
/ip address
add address=192.168.1.1/24 interface=bridge network=192.168.1.0
add address=192.168.20.1/24 interface=vlan20 network=192.168.20.0
add address=192.168.88.1/24 interface=ether5 network=192.168.88.0
add address=10.0.0.5/8 interface=wireguard-1 network=10.0.0.0
# DHCP
/ip dhcp-client
add comment=defconf disabled=no interface=ether1
/ip pool
add name=dhcp-pool-native ranges=192.168.1.100-192.168.1.254
add name=dhcp-pool-vlan20 ranges=192.168.20.100-192.168.20.254
add name=dhcp-pool-mgmt ranges=192.168.88.100-192.168.88.254
/ip dhcp-server
add address-pool=dhcp-pool-native disabled=no interface=bridge name=dhcp-native
add address-pool=dhcp-pool-vlan20 disabled=no interface=vlan20 name=dhcp-vlan20
add address-pool=dhcp-pool-mgmt disabled=no interface=ether5 name=dhcp-mgmt
/ip dhcp-server network
add address=192.168.1.0/24 dns-server=1.1.1.1 gateway=192.168.1.1
add address=192.168.20.0/24 dns-server=1.1.1.1 gateway=192.168.20.1
add address=192.168.88.0/24 dns-server=1.1.1.1 gateway=192.168.88.1
# DNS
/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
# Firewall
/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=accept chain=input comment="" in-interface-list=VLAN
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
# NAT
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" ipsec-policy=out,none out-interface-list=\
WAN
add action=masquerade chain=srcnat out-interface=wireguard-1
# Routing
/ip vrf
add list=VLAN name=vrf_vlan20
/ip route
add dst-address=0.0.0.0/0 gateway=wireguard-1@vrf_vlan20 routing-table=vrf_vlan20
Besides the overall setup, I was wondering what the advantage of a VRF table is compared to a simple firewall mangle rule (routing mark) and the creation of a standard routing table and route referring to that routing table. Both seem to use the same underlying concept, but I am not sure how they differ apart from some automatic routes being set up.
Also, I believe the hAP ac2 has a switch chip, but I configured all VLAN settings in the Bridge section of the device. Would it be wise to optimise this setup to take some load off the router's main CPU? Or is the setup above considered good practice?
Thanks a lot!