Kill switch set-up - Wireguard (Surfshark) - ROS 7.8

This is what I don’t get it, I set first rule to 192.168.0.0/16 which covers from 192.168.0.1 to 192.168.255.254 (yes you sure I don’t want to include GUEST VLAN, but now I’m just testing, I’ll set CIDR to narrower later), so why this roule is not enough?

add action=lookup-only-in-table disabled=no dst-address=192.168.0.0**/16** table=main

Why only works with these rules when the first rule contains these subnets?

add action=lookup-only-in-table disabled=no dst-address=192.168.10.0/24 table=main
add action=lookup-only-in-table disabled=no dst-address=192.168.9.0/24 table=main

Good question makes no sense to me either, in any case stick with what works…its only one extra rule.

This is two extra rules and what if I have 10+ VLANS and I need cross traffic between several VLAN, it means 10+ rules (ok this example not so real, but in theoretically could be a problem) or this is the case where mangle marking is better?

I avoid mangling if I can.

Did you try
add lookup-in-table only dst-address=192.168.1.0**/20** table=main ??

Should also work.

+++++++++++++++++++++++++++++++++++++++++++++++

Okay I figured out something…
The problem we are fixing is fixed.

YOur two rule have nothing to do with going out wireguard.
add action=lookup-only-in-table disabled=no dst-address=192.168.10.0/24 src-address=192.168.9.0/24 table=main
add action=lookup-only-in-table disabled=no dst-address=192.168.9.0/24 src-address=192.168.10.0/24 table=main

You are saying any traffic from subnet .9.0/24 to subnet 10.0/24 should go through table main OKAY great.
You are saying any traffic from subnet .10.0/24 to subnet .9.0/24 should go through table main OKAY great.
BUT BOTH THOSE SUBNETS are not going out wireguard so you dont need any routing rules for them.
In fact the router already has nice routes for them created automatically.

This leads me to believe there is something else blocking this traffic.
your config has many holes for example forgetting to define vlans 30 and 20 ??
your bridge settings are wrong too.

Because CPU using or fasttrack disabling?

Yes I tried, nothing changed :frowning:

Now I’m deleted any orphan settings but the same, also I did the last resort of noobs, I restarted too :slight_smile:

Post full config
/export file=anynameyouwish ( minus router serial #, any public WANIP information, keys etc.)

Here are my latest settings:

/interface bridge
add name=BRIDGE-LAN vlan-filtering=yes

/interface pppoe-client
add add-default-route=yes disabled=no interface=ether1 name=ISP user=username532

/interface wireguard
add listen-port=51820 mtu=1420 name=WG-NORDVPN

/interface vlan
add interface=BRIDGE-LAN name=VLAN-LAN_VPN vlan-id=9
add interface=BRIDGE-LAN name=VLAN-DEVICES vlan-id=10
add interface=BRIDGE-LAN name=VLAN-NO_INTERNET vlan-id=20
add interface=BRIDGE-LAN name=VLAN-TEST vlan-id=30
add interface=BRIDGE-LAN name=VLAN-GUEST vlan-id=100

/interface list
add name=WAN
add name=VLAN

/ip pool
add name=POOL-LAN ranges=192.168.3.2-192.168.3.254
add name=POOL-LAN_VPN ranges=192.168.9.2-192.168.9.254
add name=POOL-DEVICES ranges=192.168.10.2-192.168.10.254
add name=POOL-NO_INTERNET ranges=192.168.20.2-192.168.20.254
add name=POOL-TEST ranges=192.168.30.2-192.168.30.254
add name=POOL-GUEST ranges=192.168.100.2-192.168.100.254

/ip dhcp-server
add address-pool=POOL-LAN interface=BRIDGE-LAN name=DHCP-LAN
add address-pool=POOL-LAN_VPN interface=VLAN-LAN_VPN name=DHCP-LAN_VPN
add address-pool=POOL-DEVICES interface=VLAN-DEVICES name=DHCP-DEVICES
add address-pool=POOL-NO_INTERNET interface=VLAN-NO_INTERNET name=DHCP-NO_INTERNET
add address-pool=POOL-TEST interface=VLAN-TEST name=DHCP-TEST
add address-pool=POOL-GUEST interface=VLAN-GUEST name=DHCP-GUEST

/routing table
add disabled=no fib name=NORDVPN

/interface bridge port
add bridge=BRIDGE-LAN interface=sfp-sfpplus1
add bridge=BRIDGE-LAN interface=ether2
add bridge=BRIDGE-LAN interface=ether3 pvid=9
add bridge=BRIDGE-LAN interface=ether4 pvid=10
add bridge=BRIDGE-LAN interface=ether5
add bridge=BRIDGE-LAN interface=ether6
add bridge=BRIDGE-LAN interface=ether7 pvid=30
add bridge=BRIDGE-LAN interface=ether8

/interface bridge vlan
add bridge=BRIDGE-LAN tagged=BRIDGE-LAN,ether2,ether6 vlan-ids=9
add bridge=BRIDGE-LAN tagged=BRIDGE-LAN,ether2 vlan-ids=10
add bridge=BRIDGE-LAN tagged=BRIDGE-LAN vlan-ids=20
add bridge=BRIDGE-LAN tagged=BRIDGE-LAN,ether6 vlan-ids=30
add bridge=BRIDGE-LAN tagged=BRIDGE-LAN,ether2,ether6 vlan-ids=100

/interface list member
add interface=ISP list=WAN
add interface=VLAN-LAN_VPN list=VLAN
add interface=VLAN-DEVICES list=VLAN
add interface=VLAN-NO_INTERNET list=VLAN
add interface=VLAN-TEST list=VLAN
add interface=VLAN-GUEST list=VLAN

/interface wireguard peers
add allowed-address=0.0.0.0/0 endpoint-address=123.45.67.89 endpoint-port=51820 interface=WG-NORDVPN public-key="1a2b3c4d5e6f6g7h8i9j"

/ip address
add address=192.168.3.1/24 interface=sfp-sfpplus1 network=192.168.3.0
add address=192.168.30.1/24 interface=VLAN-TEST network=192.168.30.0
add address=192.168.10.1/24 interface=VLAN-DEVICES network=192.168.10.0
add address=192.168.20.1/24 interface=VLAN-NO_INTERNET network=192.168.20.0
add address=192.168.9.1/24 interface=VLAN-LAN_VPN network=192.168.9.0
add address=192.168.100.1/24 interface=VLAN-GUEST network=192.168.100.0
add address=10.5.0.2/24 interface=WG-NORDVPN network=10.5.0.0

/ip cloud
set ddns-enabled=yes

/ip dns
set allow-remote-requests=yes servers=103.86.96.100

/ip firewall filter
add action=drop chain=input comment="BLOCK WAN SIDE DNS REQUEST" dst-port=53 in-interface=ISP protocol=tcp
add action=accept chain=input comment="ALLOW LAN ACCESS ROUTER SERVICES" src-address=192.168.3.0/24
add action=accept chain=input comment="ALLOW ESTABLISHED AND RELATED CONNECTIONS" connection-state=established,related
add action=accept chain=input comment="ALLOW VLANS ACCESS ROUTER SERVICES" in-interface-list=VLAN
add action=drop chain=input comment="DROP ANYTHING ELSE"
add action=accept chain=forward dst-address=192.168.10.2 in-interface-list=VLAN
add action=accept chain=forward comment="ALLOW LAN TRAFFIC TO EVERYWHERE" src-address=192.168.3.0/24
add action=accept chain=forward comment="ALLOW TRAFFIC FROM LAN_VPN TO LAN" dst-address=192.168.3.0/24 src-address=192.168.9.0/24
add action=accept chain=forward comment="ALLOW TRAFFIC FROM LAN_VPN TO DEVICES" dst-address=192.168.10.0/24 src-address=192.168.9.0/24
add action=accept chain=forward comment="ALLOW TRAFFIC FROM LAN_VPN TO TEST" dst-address=192.168.30.0/24 src-address=192.168.9.0/24
add action=accept chain=forward comment="ALLOW TRAFFIC FROM DEVICES TO LAN_VPN" dst-address=192.168.9.0/24 src-address=192.168.10.0/24
add action=accept chain=forward comment="ALLOW ESTABLISHED AND RELATED CONNECTIONS" connection-state=established,related
add action=accept chain=forward comment="ALLOW VLANS NORDVPN ACCESS" connection-state=new in-interface-list=VLAN out-interface=WG-NORDVPN
add action=drop chain=forward comment="DROP ANYTHING ELSE"

/ip firewall mangle
add action=change-mss chain=forward new-mss=clamp-to-pmtu passthrough=yes protocol=tcp tcp-flags=syn

/ip firewall nat
add action=masquerade chain=srcnat comment=NAT-ISP out-interface=ISP
add action=masquerade chain=srcnat comment=NAT-VPN out-interface=WG-NORDVPN

/ip route
add disabled=no distance=5 dst-address=0.0.0.0/0 gateway=WG-NORDVPN pref-src="" routing-table=NORDVPN scope=30 suppress-hw-offload=no target-scope=10

/ip service
set telnet disabled=yes
set ftp disabled=yes
set www disabled=yes
set ssh disabled=yes
set api disabled=yes
set api-ssl disabled=yes

/routing rule
add action=lookup-only-in-table comment="KEEPS LOCAL TRAFFIC POSSIBLE" disabled=no dst-address=192.168.0.0/16 table=main
add action=lookup-only-in-table disabled=no dst-address=192.168.3.0/24 table=main
add action=lookup-only-in-table disabled=no dst-address=192.168.9.0/24 table=main
add action=lookup-only-in-table disabled=no dst-address=192.168.10.0/24 table=main
add action=lookup-only-in-table disabled=no dst-address=192.168.30.0/24 table=main
add action=lookup-only-in-table comment="REDIRECT VLAN-LAN_VPN TRAFFIC VIA NORDVPN" disabled=no src-address=192.168.9.0/24 table=NORDVPN
add action=lookup-only-in-table comment="REDIRECT VLAN-DEVICES TRAFFIC VIA NORDVPN" disabled=no src-address=192.168.10.0/24 table=NORDVPN
add action=lookup-only-in-table comment="REDIRECT VLAN-TEST TRAFFIC TO NORDVPN" disabled=no src-address=192.168.30.0/24 table=NORDVPN
add action=lookup-only-in-table comment="REDIRECT VLAN-GUEST TRAFFIC TO NORDVPN" disabled=no src-address=192.168.100.0/24 table=NORDVPN

(1) Your sffplus setup is hosed and is the core of your issues. Why do you NOT make it a vlan?
You can elect to not do so, but then why do you have it on the bridge… MAkes no sense…

So either make 192.168.3.0/24 another vlan on the bridge or
remove this line.
/interface bridge port
add bridge=BRIDGE-LAN interface=sfp-sfpplus1

(2) Personal preference to make /interface bridge vlan settings clearer so they match bridge ports and are shown on the config export!
Also when doing this it became clear that you forgot to tag a port for vlan id 20??

/interface bridge vlan
add bridge=BRIDGE-LAN tagged=BRIDGE-LAN,ether2,ether6 untagged=ether3 vlan-ids=9
add bridge=BRIDGE-LAN tagged=BRIDGE-LAN,ether2 untagged=ether4 vlan-ids=10
add bridge=BRIDGE-LAN tagged=BRIDGE-LAN,??? vlan-ids=20
add bridge=BRIDGE-LAN tagged=BRIDGE-LAN,ether6 untagged=ether7 vlan-ids=30
add bridge=BRIDGE-LAN tagged=BRIDGE-LAN,ether2,ether6 vlan-ids=100

(3) MISSING persistent keep alive on MT peer settings for nordvpn

(4) The route for NORDVPN does not require distance setting of 5, default of 1 is fine.

(5) DID NORDVPN give you any other information like DNS address ???
(6) Why did you choose DNS server 103.86.96.100 ?

(7) Looking at firewall rules I am puzzled as the logic is missing.
I understand allowing all to a specific server OKAY
I understand allowing all from 192.168.3.0 vlan to all other vlans - I assume you are on that vlan and thus as admin want access to all vlans.
(See option 2 in firewall rules below for better way to do this)
WHAT I DONT UNDERSTAND is allow all of vlan9 to 192.168.3 IF FULL access goes both ways, then ONLY HAVE ONE SUBNET ???
WHAT I DONT UNDERSTAND is allow all of vlan9 to vlan 10 and all of vlan10 to vlan9 , WHY NOT JUST HAVE ONE SUBNET ???


(8) Firewall rules NEED WORK should look like.
/ip firewall address-list
add address=admin-IP1 list=Admin comment=“admin desktop”
add address=admin-IP2 list=Admin comment=“admin laptop”
add address=admin-IP2 list=Admin comment=“admin smartphone”
/ip firewall filter
{Input Chain}
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 src-address-list=Admin
add action=accept chain=input comment=“Allow LAN DNS queries-UDP”
dst-port=53 in-interface-list=VLAN protocol=udp
add action=accept chain=input comment=“Allow LAN DNS queries - TCP”
dst-port=53 in-interface-list=VLAN protocol=tcp
add action=drop chain=input comment=“drop all else”
{forward chain
add action=fasttrack-connection chain=forward comment=“defconf: fasttrack” connection-state=established,related
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=accept chain=forward comment=“server traffic” in-interface-list=VLAN dst-address=192.168.10.2
add action=accept chain=forward comment=“admin-access” src-address-list=Admin out-interface-list=VLAN
add action=accept chain=forward comment=“internet traffic” in-interface-list=VLAN out-interface-list=WAN
add action=accept chain=forward comment=“wireguard traffic” in-interface-list=VLAN out-interface=WG-NORDVPN
add action=accept chain=forward comment=“port forwarding” connection-nat-state=dstnat
add action=drop chain=forward comment=“drop all else”

I wanted to create a network outside from VLANS if I mess something and I lock out myself accidentally, but I doubt that specific interface causes the problem. Why would it? It just an iterface or am I missing something?
I tried to delete it and nothing changed, still not works without extra route rules.


VLAN20 is not in use yet so this is why I didn’t set, at this point I stucked with routing issue.

Should I set and why? I read the spec but I thought I need to leave unset.


You right, I set back to 1, that was only a previous setting when I tried several routing “type”.


These setting is from NordVPN, I didn’t wanted my ISP’s nor google.
If everything is ok with routing and testing, I think I’ll set quad9 DoH.


I’ll do as you adviced.


Because I’m just testing why it doesn’t working, and I didn’t leased my IPs thats why I gave full access, at the end of my learning curve I’ll set static IPs and I allow access between specific devices only not whole subnets.


Ok I see what is wrong my rules thank you for simplifying.

(1) Yes, you need persistent keep alive at the client which is MT

(2) Okay understood about getting locked out…but the concept is wrong, the problem is not vlans but the BRIDGE… Nothing wrong with dedicating a port to this effect but it then SHOULD NOT BE A PORT ON THE BRIDGE!!!
what I do is take an unused port and simply give it an IP address nothing else, and then I can always log into the port by setting the ipv4 settings on my laptop and am in.

Let me know which way you want to go.
a. separate port for emergency access but not a LAN, and add another subnet/vlan to the bridge as your normal LAN subnet.
b. separate port for LAN usage BUT not on bridge.

Then we can massage config appropriately.

(3) WHERE ARE YOUR /ip dchp-server network config settings???
Assuming that you failed to provided them vice missing, boooo

Try this: For all subnets going out Wireguard.
/ip dhcp-server network
add address=192.168.X.X/24 dns-server=103.86.96.100 gateway=192.168.X.1

For rest of config use:
add address=192.168.xx.y/24 dns-server=192.168.xx.1 gateway=192.168.xx.1

//ip dns
set allow-remote-requests=yes servers=9.9.9.9



Are there any vlans or subnets going out local WAN ever?? fall back position if wireguard not available etc…

Why this is needed and what number is adviced? I can’t find proper explanation on internet.

Why should I remove an interface from a BRIDGE if the bridge has VLAN filtering? (I’m so hard hard-headed because it’s just a testing enviroment so this is not a real network so I want to learn from these mistakes)
By the way, I completely reconfigured the firewall with your adviced filter rules and the existing ones and I think is working now, I,m testing so if I’m right, I’ll paste here the whole config.

(1) Thats how wireguard works, the client keeps the connection live… also if the client changes location, think moving from wifi coffee shop to the street and to cellular coverage, it keeps your connection going…
If you want to really understand it…then read this → https://www.wireguard.com/protocol/

(2) Normally there is no reason to remove and interface from the bridge, unless you want for some reason to have that port do something different from the rest of the subnets/vlans using the bridge.
For example what I call off bridge access. The ability to config the device or reach the device in an emergency due to something went funky on the bridge settings. Its a safer configuration location so to speak.

Ok but here is the router is the client (Mikrotik is connected to NordVPN) so moves nowhere, so this keep alive is needed when the clients connected to the router’s wireguard server?

Yes, that is the wireguard protocol, the router is the client and has a part to play in communicating over the tunnel. The protocol doesnt know what devices are being used LOL.

LOL? So in your experience that, your enterprise routers going to coffee shop? If my question was LOL, what is this ROLF? :smiley:

The point being the protocol is agnostic with respect to which device its being used on. It doesnt care if its an android phone or MT router.

Can you help me to setup my MikroTik Router with WireGuard?
I search a lot, but I cannot find any instructions.
I don’t have knowlege about RouterOS.

Start your own thread, provide network diagram, list the user requirements ( what user and devices you ahve and what traffic they need) and provide your current config
/export file=anynameyouwish ( minus router serial number, public WANIP information, keys etc.)