Hi everyone,
I know this has been asked before, but somehow I am missing something:
I have several VLANs which each have their own WiFi SSID. All of this works fine as does the rest of the setup, so no questions there.
I would now like that all traffic via WiFi TestNet-YT (VLAN ID 40) runs through wireguard from a VPN provider. VLAN ID 40 shall not communicate with other VLANS and if wireguard is down, VLAN ID 40 shall not route via ISP.
My entire setup before adding the wireguard config in question was as follows:
# 2025-06-22 13:16:45 by RouterOS 7.19.2
# software id = KSYB-YVIV
#
# model = C53UiG+5HPaxD2HPaxD
/interface bridge
add name=Bridge-LAN vlan-filtering=yes
/interface ethernet
set [ find default-name=ether1 ] name=ether1-WAN
set [ find default-name=ether2 ] disabled=yes name=ether2-LAN
set [ find default-name=ether3 ] disabled=yes name=ether3-LAN
set [ find default-name=ether4 ] disabled=yes name=ether4-LAN
set [ find default-name=ether5 ] disabled=yes name=ether5-LAN
/interface vlan
add interface=Bridge-LAN name=VLAN-Home vlan-id=10
add interface=Bridge-LAN name=VLAN-Work vlan-id=20
add interface=Bridge-LAN name=VLAN-Printer-IOT vlan-id=30
add interface=Bridge-LAN name=VLAN-YT vlan-id=40
/interface list
add name=WAN
add name=VLAN
add name=VLAN-Admin
/interface wifi configuration
add channel.band=2ghz-ax .width=20mhz country=Germany disabled=no mode=ap \
name="2.4ghz Config" security.authentication-types=wpa3-psk \
.disable-pmkid=yes .encryption=ccmp .wps=disable ssid=TestNet tx-power=16
add channel.band=5ghz-ax .width=20/40mhz country=Germany disabled=no mode=\
ap name="5ghz Config" security.authentication-types=wpa3-psk \
.disable-pmkid=yes .encryption=ccmp,gcmp,ccmp-256,gcmp-256 .wps=disable \
ssid=TestNet5G tx-power=18
add channel.band=2ghz-ax .width=20mhz country=Germany disabled=no mode=ap \
name="2.4ghz Config-Work" security.authentication-types=wpa3-psk \
.disable-pmkid=yes .encryption=ccmp .wps=disable ssid=TestNet-W
add channel.band=2ghz-n .width=20mhz country=Germany disabled=no mode=ap \
name="2.4ghz Config-Printer-IOT" security.authentication-types=wpa2-psk \
.disable-pmkid=yes .encryption=ccmp .wps=disable ssid=TestNet-P
add channel.band=2ghz-n .width=20mhz country=Germany disabled=no mode=ap \
name="2.4ghz Config-YT" security.authentication-types=wpa2-psk \
.disable-pmkid=yes .encryption=ccmp .wps=disable ssid=TestNet-YT
/interface wifi
set [ find default-name=wifi1 ] configuration="5ghz Config" \
configuration.mode=ap name=Wifi1-5ghz
set [ find default-name=wifi2 ] configuration="2.4ghz Config" \
configuration.mode=ap disabled=no name=Wifi2-2.4ghz
add configuration="2.4ghz Config-Printer-IOT" configuration.mode=ap disabled=\
no mac-address=XX:XX:XX:XX:XX:XX master-interface=Wifi2-2.4ghz name=\
Wifi2-2.4ghz-Printer-IOT
add configuration="2.4ghz Config-Work" configuration.mode=ap mac-address=\
XX:XX:XX:XX:XX:XX master-interface=Wifi2-2.4ghz name=Wifi2-2.4ghz-Work
add configuration="2.4ghz Config-YT" configuration.mode=ap disabled=no \
mac-address=XX:XX:XX:XX:XX:XX master-interface=Wifi2-2.4ghz name=\
Wifi2-2.4ghz-YT
/ip pool
add name=VLAN-Home-Pool ranges=192.168.10.20-192.168.10.254
add name=VLAN-Work-Pool ranges=192.168.20.20-192.168.20.254
add name=VLAN-Printer-IOT-Pool ranges=192.168.30.20-192.168.30.254
add name=VLAN-YT-Pool ranges=192.168.40.20-192.168.40.254
/ip dhcp-server
add address-pool=VLAN-Home-Pool interface=VLAN-Home name=VLAN-Home-DHCP
add address-pool=VLAN-Work-Pool interface=VLAN-Work name=VLAN-Work-DHCP
add address-pool=VLAN-Printer-IOT-Pool interface=VLAN-Printer-IOT name=\
VLAN-Printer-IOT-DHCP
add address-pool=VLAN-YT-Pool interface=VLAN-YT name=VLAN-YT-DHCP
/interface bridge port
add bridge=Bridge-LAN frame-types=admit-only-untagged-and-priority-tagged \
interface=ether2-LAN pvid=10
add bridge=Bridge-LAN frame-types=admit-only-untagged-and-priority-tagged \
interface=ether3-LAN pvid=10
add bridge=Bridge-LAN frame-types=admit-only-untagged-and-priority-tagged \
interface=ether4-LAN pvid=10
add bridge=Bridge-LAN frame-types=admit-only-untagged-and-priority-tagged \
interface=ether5-LAN pvid=10
add bridge=Bridge-LAN frame-types=admit-only-untagged-and-priority-tagged \
interface=Wifi2-2.4ghz pvid=10
add bridge=Bridge-LAN frame-types=admit-only-untagged-and-priority-tagged \
interface=Wifi1-5ghz pvid=10
add bridge=Bridge-LAN frame-types=admit-only-untagged-and-priority-tagged \
interface=Wifi2-2.4ghz-Work pvid=20
add bridge=Bridge-LAN frame-types=admit-only-untagged-and-priority-tagged \
interface=Wifi2-2.4ghz-Printer-IOT pvid=30
add bridge=Bridge-LAN frame-types=admit-only-untagged-and-priority-tagged \
interface=Wifi2-2.4ghz-YT pvid=40
/ip neighbor discovery-settings
set discover-interface-list=VLAN-Admin
/ip settings
set rp-filter=loose
/ipv6 settings
set accept-redirects=no accept-router-advertisements=no disable-ipv6=yes \
forward=no
/interface bridge vlan
add bridge=Bridge-LAN tagged=Bridge-LAN untagged=Wifi2-2.4ghz-Work vlan-ids=\
20
add bridge=Bridge-LAN tagged=Bridge-LAN untagged=\
ether2-LAN,ether3-LAN,ether4-LAN,ether5-LAN,Wifi1-5ghz,Wifi2-2.4ghz \
vlan-ids=10
add bridge=Bridge-LAN tagged=Bridge-LAN untagged=Wifi2-2.4ghz-Printer-IOT \
vlan-ids=30
add bridge=Bridge-LAN tagged=Bridge-LAN untagged=Wifi2-2.4ghz-YT vlan-ids=40
/interface list member
add interface=ether1-WAN list=WAN
add interface=VLAN-Home list=VLAN
add interface=VLAN-Work list=VLAN
add interface=VLAN-Home list=VLAN-Admin
add interface=VLAN-Printer-IOT list=VLAN
add interface=VLAN-YT list=VLAN
/ip address
add address=192.168.10.1/24 interface=VLAN-Home network=192.168.10.0
add address=192.168.20.1/24 interface=VLAN-Work network=192.168.20.0
add address=192.168.30.1/24 interface=VLAN-Printer-IOT network=192.168.30.0
add address=192.168.40.1/24 interface=VLAN-YT network=192.168.40.0
/ip cloud
set update-time=no
/ip dhcp-client
add interface=ether1-WAN
/ip dhcp-server lease
add address=192.168.10.15 client-id=1:XX:XX:XX:XX:XX:XX mac-address=\
XX:XX:XX:XX:XX:XX server=VLAN-Home-DHCP
add address=192.168.10.16 client-id=1:XX:XX:XX:XX:XX:XX mac-address=\
XX:XX:XX:XX:XX:XX server=VLAN-Home-DHCP
add address=192.168.30.6 comment=Switch mac-address=XX:XX:XX:XX:XX:XX server=\
VLAN-Printer-IOT-DHCP
/ip dhcp-server network
add address=192.168.10.0/24 dns-server=192.168.10.1 gateway=192.168.10.1
add address=192.168.20.0/24 dns-server=192.168.20.1 gateway=192.168.20.1
add address=192.168.30.0/24 dns-server=192.168.30.1 gateway=192.168.30.1
add address=192.168.40.0/24 dns-server=192.168.40.1 gateway=192.168.40.1
/ip dns
set allow-remote-requests=yes
/ip firewall address-list
add address=192.168.10.15 list=Authorized
add address=192.168.10.16 list=Authorized
/ip firewall filter
add action=accept chain=input comment="accept established,related,untracked" \
connection-state=established,related,untracked
add action=drop chain=input comment="drop invalid" connection-state=invalid
add action=accept chain=input comment="accept ICMP" protocol=icmp
add action=accept chain=input comment="admin access" in-interface-list=\
VLAN-Admin src-address-list=Authorized
add action=accept chain=input comment="users to services" dst-port=53 \
in-interface-list=VLAN protocol=udp
add action=accept chain=input comment="users to services" dst-port=53 \
in-interface-list=VLAN protocol=tcp
add action=drop chain=input comment="drop all else"
add action=fasttrack chain=forward comment="fasttrack" \
connection-state=established,related
add action=accept chain=forward comment=\
"accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=forward comment="drop invalid" connection-state=invalid
add action=accept chain=forward comment="internet traffic" in-interface-list=\
VLAN out-interface-list=WAN
add action=accept chain=forward comment=\
"Access Printer on Printing Network from Home Network" disabled=yes \
dst-address=192.168.30.8 in-interface=VLAN-Home out-interface=\
VLAN-Printer-IOT
add action=drop chain=forward comment="drop all else"
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1-WAN
/ip ipsec profile
set [ find default=yes ] dpd-interval=2m dpd-maximum-failures=5
/ip service
set ftp disabled=yes
set telnet disabled=yes
set www disabled=yes
set ssh disabled=yes port=2421
set api disabled=yes
set api-ssl disabled=yes
/ip ssh
set strong-crypto=yes
/ipv6 firewall filter
add action=drop chain=input comment="Drop all other IPv6 traffic"
add action=drop chain=forward comment="Drop all IPv6 forward traffic"
/ipv6 nd
set [ find default=yes ] disabled=yes
/system clock
set time-zone-name=Berlin/Germany
/system note
set show-at-login=no
/system ntp client
set enabled=yes
/system ntp client servers
add address=0.pool.ntp.org
add address=1.pool.ntp.org
add address=2.pool.ntp.org
add address=3.pool.ntp.org
/system scheduler
add interval=1w name="1.1 MO Wifi-Work enable" on-event=\
"/interface wifi enable Wifi2-2.4ghz-Work" policy=write start-date=\
2024-12-30 start-time=07:00:00
add interval=1w name="1.2 MO Wifi-Work disable" on-event=\
"/interface wifi disable Wifi2-2.4ghz-Work" policy=write start-date=\
2024-12-30 start-time=20:00:00
add interval=1w name="2.1 TU Wifi-Work enable" on-event=\
"/interface wifi enable Wifi2-2.4ghz-Work" policy=write start-date=\
2024-12-31 start-time=07:00:00
add interval=1w name="2.2 TU Wifi-Work disable" on-event=\
"/interface wifi disable Wifi2-2.4ghz-Work" policy=write start-date=\
2024-12-31 start-time=20:00:00
add interval=1w name="3.1 WE Wifi-Work enable" on-event=\
"/interface wifi enable Wifi2-2.4ghz-Work" policy=write start-date=\
2025-01-01 start-time=07:00:00
add interval=1w name="3.2 WE Wifi-Work disable" on-event=\
"/interface wifi disable Wifi2-2.4ghz-Work" policy=write start-date=\
2025-01-01 start-time=20:00:00
add interval=1w name="4.1 TH Wifi-Work enable" on-event=\
"/interface wifi enable Wifi2-2.4ghz-Work" policy=write start-date=\
2025-01-02 start-time=07:00:00
add interval=1w name="4.2 TH Wifi-Work disable" on-event=\
"/interface wifi disable Wifi2-2.4ghz-Work" policy=write start-date=\
2025-01-02 start-time=20:00:00
add interval=1w name="5.1 FR Wifi-Work enable" on-event=\
"/interface wifi enable Wifi2-2.4ghz-Work" policy=write start-date=\
2025-01-03 start-time=07:00:00
add interval=1w name="5.2 FR Wifi-Work disable" on-event=\
"/interface wifi disable Wifi2-2.4ghz-Work" policy=write start-date=\
2025-01-03 start-time=20:00:00
/tool bandwidth-server
set enabled=no
/tool mac-server
set allowed-interface-list=none
/tool mac-server mac-winbox
set allowed-interface-list=VLAN-Admin
/tool mac-server ping
set enabled=no
I then added the following for wireguard (all marked as disabled currently until I know what I am missing):
/interface wireguard
add disabled=yes listen-port=13231 mtu=1420 name=WG-ALB1
/interface wireguard peers
add allowed-address=0.0.0.0/0 disabled=yes endpoint-address=31.171.153.66 \
endpoint-port=49121 interface=WG-ALB1 name=Peer-WG-ALB1 public-key=\
"XXXXXXXXXXXXXXXXXXXXXXXX"
/ip address
add address=10.10.123.105 disabled=yes interface=WG-ALB1 network=10.10.123.0
So far I presume this is correct, however I am having troubles connecting the wireguard to VLAN ID 40 so all devices on WiFi SSID TestNet-YT (and only these) get routed via wireguard. What I did additionally is the following:
/ip route
add disabled=yes distance=1 dst-address=0.0.0.0/0 gateway=WG-ALB1 \
routing-table=VPN-YT scope=30 suppress-hw-offload=no target-scope=10
/routing rule
add action=lookup-only-in-table disabled=yes src-address=192.168.40.0/24 \
table=VPN-YT
/routing table
add disabled=no fib name=VPN-YT
/ip firewall nat
add action=masquerade chain=srcnat disabled=yes out-interface=WG-ALB1
/ip firewall filter
add action=accept chain=forward disabled=yes in-interface=VLAN-YT \
out-interface=WG-ALB1
I have two questions:
- DNS: According to what I read is that the VPN provider´s DNS should be added under /ip dns in the server field. But would this not make all other VLANS use the VPN providers DNS as well if I add it there? The goal is obviously that VLAN ID 40 uses the VPN provider´s DNS and all other VLANs use my ISPs DNS. So where do I add the VPN´s provider DNS in this case that it will only be used for VLAN ID 40?
- With last settings (IP router, routing rules, routing table, firewall nat and firewall filter; see above) the WiFi net VPN-YT has no internet access. Without this it does, however I am also not seeing any Tx or Rx with my current wireguard configuration. What am I missing, how can I tie VLAN ID 40 to route via wiregaurd?
Any help is greatly appreciated.