Cant get Wireguard client to work

Hello everyone.
My router has dhcp wan connection, 1 ether port with client. All i want to do is to route all traffic to VPN.

I tried multiple guides from like a dozen similar questions but cant make all my traffic route throught the wireguard tunnel: it is either shows real ip or dont have internet access at all.

Please advice what am i doing wrong.

# 2024-11-09 16:27:51 by RouterOS 7.16.1
# software id = 4NIX-BDJQ
#
# model = RBD52G-5HacD2HnD
# serial number = 92F109F00470
/interface bridge
add name=bridge1
/interface wireless
set [ find default-name=wlan1 ] mode=ap-bridge ssid=MikroTik \
    wireless-protocol=802.11
set [ find default-name=wlan2 ] mode=ap-bridge ssid=MikroTik \
    wireless-protocol=802.11
/interface ethernet
set [ find default-name=ether1 ] comment=WAN
/interface wireguard
add listen-port=13231 mtu=1420 name=wireguard1
/interface list
add name=LAN
add name=WAN
/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk mode=\
    dynamic-keys supplicant-identity=MikroTik
/ip pool
add name=dhcp_pool0 ranges=192.168.188.2-192.168.188.254
/ip dhcp-server
add add-arp=yes address-pool=dhcp_pool0 interface=bridge1 name=dhcp1 \
    server-address=192.168.188.1
/routing table
add disabled=no fib name=rtab-wg
/interface bridge port
add bridge=bridge1 interface=ether5
add bridge=bridge1 interface=ether2
add bridge=bridge1 interface=ether3
add bridge=bridge1 interface=ether4
add bridge=bridge1 interface=wlan2
add bridge=bridge1 interface=wlan1
/ip neighbor discovery-settings
set discover-interface-list=all
/ipv6 settings
set disable-ipv6=yes forward=no
/interface list member
add interface=bridge1 list=LAN
add interface=ether1 list=WAN
add interface=wireguard1 list=LAN
/interface wireguard peers
add allowed-address=0.0.0.0/0 endpoint-address=_SERVER-IP_ endpoint-port=\
    51820 interface=wireguard1 name=peer1 persistent-keepalive=25s \
    preshared-key="key" private-key=\
    "key=" public-key=\
    "key"
/ip address
add address=192.168.188.1/24 interface=bridge1 network=192.168.188.0
add address=10.7.0.2/24 comment=wg interface=wireguard1 network=10.7.0.0
/ip dhcp-client
add interface=ether1
/ip dhcp-relay
add dhcp-server=192.168.188.1 disabled=no interface=wlan1 name=relay1
/ip dhcp-server network
add address=192.168.188.0/24 dns-server=192.168.188.1 gateway=192.168.188.1
/ip dns
set allow-remote-requests=yes servers=8.8.8.8,8.8.4.4
/ip firewall filter
add action=fasttrack-connection chain=forward connection-state=\
    established,related hw-offload=yes
add action=accept chain=forward connection-state=established,related
add action=accept chain=input connection-state=established,related
add action=drop chain=forward connection-state=invalid
add action=drop chain=input connection-state=invalid
add action=drop chain=input in-interface=!bridge1
add action=accept chain=forward in-interface=bridge1 src-address=\
    192.168.188.0/24
add action=accept chain=input in-interface=bridge1 src-address=\
    192.168.188.0/24
add action=drop chain=forward in-interface=!bridge1
add action=accept chain=input comment="WG HANDSHAKE" dst-port=13231 protocol=\
    udp
/ip firewall mangle
add action=mark-routing chain=prerouting new-routing-mark=rtab-wg \
    passthrough=no src-address=192.168.188.2-192.168.188.255
/ip firewall nat
add action=masquerade chain=srcnat out-interface=wireguard1
add action=masquerade chain=srcnat out-interface=ether1
/ip nat-pmp
set enabled=yes
/ip route
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    wireguard1 routing-table=rtab-wg scope=30 suppress-hw-offload=no \
    target-scope=10
/ip upnp
set enabled=yes
/routing rule
add action=lookup-only-in-table disabled=no routing-mark=rtab-wg table=\
    rtab-wg
/system clock
set time-zone-name=Europe/London
/system note
set show-at-login=no

What are you connecting to
a. a third party server?
b. another MT router?

You dont need to BOTH mangle and use Routing Rules… one or the other.
Assuming that you have selected default route in IP DHCP client?

I’m connecting to private server. Got another router (Unifi) which uses same config without troubles - im mentioning this as a proof that server itself is working.
I tried mangle without routing rule first - no luck. Now i tried only routing rule - it shows my real ip.

Not quite sure. How do i check this? I dont see such an option in dhcp client menu

The reason I state this is because your router FIRST has to establish the tunnel with the other end… then wireguard traffic can flow.
If there is no route, then the tunnel will never happen…
Since you are getting internet locally it must exist..

Screenshot 2024-11-09 103534.png

  1. RRules
    a. disable all mangles
    b. change routing rules to the following

/routing rule
add action=lookup-only-in-table min-prefix=0 table=main comment=“permits local traffic”
add action=lookup-only-in-table src-address=192.168.188.0/24 table=rtab-wg

Yep, my dhcp config looks the same.

Done, internet’s gone.
Ping from PC says 192.168.188.1 (router) is unreachable or Request time out. 50/50

It now seems like a problem with WG. Last handshake shows 0:00:00.

Also Route 0.0.0.0/0 to wireguard1 have Unreachable status

Very strange indeed.
So you confirm the following
a. ip dhcp client has default route=yes?
b. with RRules disabled and mangle disabled you go out the local internet (local WAN) no problem?
c. while testing b, please attempt to ping the remote address you have entered in 1 below !!!

Assuming yes to these then we have to assume there is a problem with wireguard settings next.
LOCAL MT
/ip wireguard peer settings
1 - is the endpoint address correct to reach the other side?
2 - is the endpoint port correctly assigned ( matches listening port on other end )
3 - is the public key generated by the other side correctly copied to the MT device

OTHER END
4 - Does the listening port match the entry in the peer settings found in 2 above.
5 - Does the device have an input chain 'Like" rule to allow incoming wireguard traffic
6 - is the public key generated by the MT device (when creating the tunnel initially) correctly copied to this device

Yes, i do confirm
a. ip dhcp client has default route=yes - YES
b. with RRules disabled and mangle disabled you go out the local internet (local WAN) no problem? - YES
c. while testing b, please attempt to ping the remote address you have entered in 1 below !!! Yes, can ping WG server IP from MT and cant ping from local machine.

1 - is the endpoint address correct to reach the other side? Yes
2 - is the endpoint port correctly assigned ( matches listening port on other end ) Yes
3 - is the public key generated by the other side correctly copied to the MT device Yes. In case i mess up with a key, i get error in UI saying that key is invalid.

4 - Does the listening port match the entry in the peer settings found in 2 above. Yes, same settings work on other device.
5 - Does the device have an input chain 'Like" rule to allow incoming wireguard traffic Yes
6 - is the public key generated by the MT device (when creating the tunnel initially) correctly copied to this device Yes

I checked and double checked everything, recreated WG profiles and rules. Here is my current config:

# 2024-11-11 20:09:12 by RouterOS 7.16.1
# software id = 4NIX-BDJQ
#
# model = RBD52G-5HacD2HnD
# serial number = 92F109F00470
/interface bridge
add name=bridge1
/interface wireless
set [ find default-name=wlan1 ] disabled=no installation=indoor mode=\
    ap-bridge ssid="PieFi setup" wireless-protocol=802.11 wps-mode=disabled
set [ find default-name=wlan2 ] mode=ap-bridge ssid=MikroTik \
    wireless-protocol=802.11
/interface ethernet
set [ find default-name=ether1 ] comment=WAN
/interface wireguard
add listen-port=13231 mtu=1420 name=wireguard1
/interface list
add name=LAN
add name=WAN
/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa2-psk mode=dynamic-keys \
    supplicant-identity=MikroTik
/ip pool
add name=dhcp_pool0 ranges=192.168.188.2-192.168.188.254
/ip dhcp-server
add add-arp=yes address-pool=dhcp_pool0 interface=bridge1 name=dhcp1 \
    server-address=192.168.188.1
/routing table
add disabled=no fib name=rtab-wg
/interface bridge port
add bridge=bridge1 interface=ether5
add bridge=bridge1 interface=ether2
add bridge=bridge1 interface=ether3
add bridge=bridge1 interface=ether4
add bridge=bridge1 interface=wlan2
add bridge=bridge1 interface=wlan1
/ip neighbor discovery-settings
set discover-interface-list=all
/ipv6 settings
set disable-ipv6=yes forward=no
/interface list member
add interface=bridge1 list=LAN
add interface=ether1 list=WAN
add interface=wireguard1 list=LAN
/interface wireguard peers
add allowed-address=::/0,0.0.0.0/0 endpoint-address=_IP_ \
    endpoint-port=51820 interface=wireguard1 name=peer3 persistent-keepalive=\
    25s preshared-key="KEY" \
    public-key="KEY"
/ip address
add address=192.168.188.1/24 interface=bridge1 network=192.168.188.0
add address=10.7.0.2/24 comment=wg interface=wireguard1 network=10.7.0.0
/ip dhcp-client
add interface=ether1
/ip dhcp-relay
add dhcp-server=192.168.188.1 disabled=no interface=wlan1 name=relay1
/ip dhcp-server network
add address=192.168.188.0/24 dns-server=192.168.188.1 gateway=192.168.188.1
/ip dns
set allow-remote-requests=yes servers=8.8.8.8,8.8.4.4
/ip firewall filter
add action=fasttrack-connection chain=forward connection-state=\
    established,related hw-offload=yes
add action=accept chain=forward connection-state=established,related
add action=accept chain=input connection-state=established,related
add action=accept chain=input comment="WG HANDSHAKE" dst-port=13231 protocol=\
    udp
add action=drop chain=forward connection-state=invalid
add action=drop chain=input connection-state=invalid
add action=drop chain=input in-interface=!bridge1
add action=accept chain=forward in-interface=bridge1 src-address=\
    192.168.188.0/24
add action=accept chain=input in-interface=bridge1 src-address=\
    192.168.188.0/24
add action=drop chain=forward in-interface=!bridge1
/ip firewall mangle
add action=mark-routing chain=prerouting disabled=yes new-routing-mark=\
    rtab-wg passthrough=no src-address=192.168.188.2-192.168.188.255
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1
add action=masquerade chain=srcnat out-interface=wireguard1
/ip nat-pmp
set enabled=yes
/ip route
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    wireguard1 routing-table=rtab-wg scope=30 suppress-hw-offload=no \
    target-scope=10
/ip upnp
set enabled=yes
/routing rule
add action=lookup-only-in-table comment="permites local traffic" disabled=no \
    min-prefix=0 table=main
add action=lookup-only-in-table disabled=no src-address=192.168.188.0/24 \
    table=rtab-wg
/system clock
set time-zone-name=Europe/London
/system note
set show-at-login=no

Should not be related, but:
/interface list member
add interface=bridge1 list=LAN
add interface=ether1 list=WAN
add interface=wireguard1 list=LAN

wireguard1 should be WAN conceptually.

Thanks, changed that. No luck.

What concerns me is status of wg connection:
Rx: 0 B
Last handshake: 0:00:00

The concept is…to be clear, that the traffic from the router has to have one SOURCE IP to a third party server … that way the third party server does not have to anticipate and handle incoming traffic that is not the prescribed wireguard IP of the source. Critical in 3rdparty Wireguard VPN servers that provide a single IP. A private server under ones control does not require this move, unless it helps simplify matters. How is this accomplished.
EASY
By the OPs current rule.
add action=masquerade chain=srcnat out-interface=wireguard1

The main reason you sometimes see the wg interface added to the WAN, is to ACHIEVE the same effect since the default sourcenat rule is
add chain=srcnat action=masquerade out–interface-list=WAN

Hence if you make the wg interface part of the WAN interface list, the same effect of one wg IP arriving at destination is the result.
The reason this is done for third party servers, preferentially over the method used by the OP, is because there is no return traffic!!!

However he is connecting to a private Server and thus likely there may be traffic BACK to this router and probably the admin via the SERVER to configure this router or to access subnets or perhaps to even access the internet and thus LAN interface list is actually a more logical choice.

Dont see anything obvious yet.

  1. Change this to LAN
    /ip neighbor discovery-settings
    set discover-interface-list=all

    /ip neighbor discovery-settings
    set discover-interface-list=LAN

  2. POSSIBLE ISSUE look at this config
    /interface wireguard peers
    add allowed-address=::/0,0.0.0.0/0 endpoint-address=IP
    endpoint-port=51820 interface=wireguard1 name=peer3 persistent-keepalive=
    25s preshared-key=“KEY” public-key=“KEY”

Change to
/interface wireguard peers
add allowed-address=0.0.0.0/0 endpoint-address=IP
endpoint-port=51820 interface=wireguard1 name=peer3 persistent-keepalive=
25s preshared-key=“KEY” public-key=“KEY”

  1. You can remove this rule in the input chain, wireguard traffic for handshake is outbound TO server, not inbound!!!
    add action=accept chain=input comment=“WG HANDSHAKE” dst-port=13231 protocol=udp

  2. not a fan of your firewall rules but will just reorder them for easy reading and add one rule.

/ip firewall filter
add action=accept chain=input connection-state=established,related
add action=drop chain=input connection-state=invalid
add action=accept chain=input protocol=icmp
add action=accept chain=input in-interface-list=LAN
add action=drop chain=input comment=“Drop all else” { ensure you put this rule in last }
++++++++++++++++++++++++++++++
add action=fasttrack-connection chain=forward connection-state=
established,related hw-offload=yes
add action=accept chain=forward connection-state=established,related
add action=drop chain=forward connection-state=invalid
add action=accept chain=forward in-interface=bridge1 src-address=
192.168.188.0/24
add action=accept chain=input in-interface=bridge1 src-address=
192.168.188.0/24
add action=drop chain=forward in-interface=!bridge1
add action=accept chain=forward comment=“local internet access” in-interface-list=LAN out-interface-list=WAN { disabled =yes if you DONT want users going out local WAN)
add action=accept chain=forward comment=“wireguard acess” src-address=192.168.88.0/24 out-interface=wireguard1
add action=drop chain=forward comment=“drop all else”

DISCUSSION:
The rule in orange is removed as its a duplicate and obvious when you have rules ordered properly
add action=drop chain=input in-interface=!bridge1
add action=accept chain=input in-interface=bridge1 src-address=
192.168.188.0/24

The second rule is not needed as you are already allowing it by the first rule. The first rule states block any traffic TO the router except bridge1 traffic.
Since the subnet address is the bridge address its rather silly.

The normal way to do this, is the following (clear, concise)
add action=accept chain=input in-interface-list=LAN
and then after that is in place put
add action=drop chain=input comment=“drop all else”

Now in the forward chain I see what you have done, wide open rules…again, no need.
There are not other subnets on the router and they only need to be allowed to wireguard if pushed out that way.
The rules in place are not that clear and are very non-standard (but not wrong).
add action=accept chain=forward in-interface=bridge1 src-address=
192.168.188.0/24
add action=accept chain=input in-interface=bridge1 src-address=
192.168.188.0/24
add action=drop chain=forward in-interface=!bridge1

BETTER imho.
add action=accept chain=forward comment=“local internet access” in-interface-list=LAN out-interface-list=WAN disabled =yes { assuming no local WAN allowed }
add action=accept chain=forward comment=“wireguard access” src-address=192.168.88.0/24 out-interface=wireguard1
add action=drop chain=forward comment=“drop all else”

  1. What is the purpose of this rule???
    Perhaps disable for testing purposes? Not sure if works thru wg ??
    /ip nat-pmp
    set enabled=yes

  2. Same same with this rule, purpose, not sure will work thru wg>> disable for now
    /ip upnp
    set enabled=yes

Anav, thanks so much for your help. I followed your guideline, changed everything as you suggested. Btw my firewall rules are mostly from other similar posts so i dont mind changing any and all of them :slight_smile:

Current status: no connection to wan or wg from local machine, router still pings remote server easily.
Here’s update cfg

# 2024-11-12 10:51:39 by RouterOS 7.16.1
# software id = 4NIX-BDJQ
#
# model = RBD52G-5HacD2HnD
# serial number = 92F109F00470
/interface bridge
add name=bridge1
/interface wireless
set [ find default-name=wlan1 ] disabled=no installation=indoor mode=\
    ap-bridge ssid="PieFi setup" wireless-protocol=802.11 wps-mode=disabled
set [ find default-name=wlan2 ] mode=ap-bridge ssid=MikroTik \
    wireless-protocol=802.11
/interface ethernet
set [ find default-name=ether1 ] comment=WAN
/interface wireguard
add listen-port=13231 mtu=1420 name=wireguard1
/interface list
add name=LAN
add name=WAN
/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa2-psk mode=dynamic-keys \
    supplicant-identity=MikroTik
/ip pool
add name=dhcp_pool0 ranges=192.168.188.2-192.168.188.254
/ip dhcp-server
add add-arp=yes address-pool=dhcp_pool0 interface=bridge1 name=dhcp1 \
    server-address=192.168.188.1
/routing table
add disabled=no fib name=rtab-wg
/interface bridge port
add bridge=bridge1 interface=ether5
add bridge=bridge1 interface=ether2
add bridge=bridge1 interface=ether3
add bridge=bridge1 interface=ether4
add bridge=bridge1 interface=wlan2
add bridge=bridge1 interface=wlan1
/ip neighbor discovery-settings
set discover-interface-list=LAN
/ipv6 settings
set disable-ipv6=yes forward=no
/interface list member
add interface=bridge1 list=LAN
add interface=ether1 list=WAN
add interface=wireguard1 list=WAN
/interface wireguard peers
add allowed-address=0.0.0.0/0 endpoint-address=ip endpoint-port=\
    51820 interface=wireguard1 name=peer3 persistent-keepalive=25s \
    preshared-key="key" public-key=\
    "key"
/ip address
add address=192.168.188.1/24 interface=bridge1 network=192.168.188.0
add address=10.7.0.2/24 comment=wg interface=wireguard1 network=10.7.0.0
/ip dhcp-client
add interface=ether1
/ip dhcp-relay
add dhcp-server=192.168.188.1 disabled=no interface=wlan1 name=relay1
/ip dhcp-server network
add address=192.168.188.0/24 dns-server=192.168.188.1 gateway=192.168.188.1
/ip dns
set allow-remote-requests=yes servers=8.8.8.8,8.8.4.4
/ip firewall filter
add action=accept chain=input connection-state=established,related
add action=drop chain=input connection-state=invalid
add action=accept chain=input protocol=icmp
add action=drop chain=input
add action=accept chain=forward comment="wireguard access" out-interface=\
    wireguard1 src-address=192.168.88.0/24
add action=fasttrack-connection chain=forward connection-state=\
    established,related hw-offload=yes
add action=accept chain=forward connection-state=established,related
add action=drop chain=forward connection-state=invalid
add action=accept chain=forward comment="local internet access" \
    in-interface-list=LAN out-interface-list=WAN
add action=accept chain=forward disabled=yes in-interface=bridge1 \
    src-address=192.168.188.0/24
add action=accept chain=input disabled=yes in-interface=bridge1 src-address=\
    192.168.188.0/24
add action=drop chain=forward disabled=yes in-interface=!bridge1
add action=drop chain=forward comment="drop all else"
/ip firewall mangle
add action=mark-routing chain=prerouting disabled=yes new-routing-mark=\
    rtab-wg passthrough=no src-address=192.168.188.2-192.168.188.255
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1
add action=masquerade chain=srcnat out-interface=wireguard1
/ip route
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    wireguard1 routing-table=rtab-wg scope=30 suppress-hw-offload=no \
    target-scope=10
/routing rule
add action=lookup-only-in-table comment="permites local traffic" disabled=no \
    min-prefix=0 table=main
add action=lookup-only-in-table disabled=no src-address=192.168.188.0/24 \
    table=rtab-wg
/system clock
set time-zone-name=Europe/London
/system note
set show-at-login=no

I suspect an issue with DNS and so lets try some things…before I get there some more work required on firewall rules.

  1. You need access as admin to the router so we need to add that to the input chain rules.
    To do this the easiest method is to identify the admins devices on the network wired and wifi.]
    Go to DHCP leases and make those devices leases STATIC/fixed.
    We should also add any of your devices using wireguard when remote and away from the router (laptop/iphone etc..)

/ip firewall address-list
add address=192.168.188.X list=AUTHORIZED comment=“local admin desktop”
add address=192.168.188.Y list=AUTHORIZED comment=“local admin wifi”
add address=10.7.0.Z list=AUTHORIZED comment=“remote admin laptop/smartphone”

and then add the rule to your input chain…not sure how you access it now as according to the rules there should be no access LOL
/ip firewall filter
add action=accept chain=input connection-state=established,related,untracked
add action=drop chain=input connection-state=invalid
add action=accept chain=input protocol=icmp

add action=accept chain=input comment=“admin access” src-address-list=AUTHORIZED
add action=drop chain=input

  1. FORWARD CHAIN, you have the first rule out of place needs to be properly placed in order and get rid of the useless rules NOISE, vice disable.

add action=fasttrack-connection chain=forward connection-state=
established,related hw-offload=yes
add action=accept chain=forward connection-state=established,related
add action=drop chain=forward connection-state=invalid
add action=accept chain=forward comment=“local internet access”
in-interface-list=LAN out-interface-list=WAN

add action=accept chain=forward comment=“users to wg” src-address=192.168.188.0/24 out-interface=wireguard1
add action=drop chain=forward comment=“drop all else”

We might not even need the rule to allow the lan subnet out wireguard because we have the rule above that allowing LAN to WAN interfaces
and since WG is part of WAN interface list, its is already allowed to hit the wireguard interface…
Once we have it up and running we can add a log rule to the second rule and if not hits, confirm our logic and then can remove the presumably extra rule.

  1. MODIFY IP DNS TO ( remove remote requests ) ALSO find out what dns servers are in use at the private server !!!1
    /ip dns
    set servers=8.8.8.8,8.8.4.4,1.1.1.1

  2. MODIFY /ip DHCP network server
    FROM:
    /ip dhcp-server network
    add address=192.168.188.0/24 dns-server=192.168.188.1 gateway=192.168.188.1

TO:
/ip dhcp-server network
add address=192.168.188.0/24 dns-server=10.7.0.1 gateway=192.168.188.1

Okay, done. Doesnt work.
8.8.8.8 and 8.8.4.4 - are server dns.
and i access router via mac address, didnt have problem with it.
Also fixed one typo: add action=accept chain=forward comment=“wireguard access” out-interface=
wireguard1 src-address=192.168.188.0/24
I see a problem with thid part:

add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    wireguard1 routing-table=rtab-wg scope=30 suppress-hw-offload=no \
    target-scope=10
  • its status is unreachable and inactive

Updated config:

# 2024-11-12 19:25:57 by RouterOS 7.16.1
# software id = 4NIX-BDJQ
#
# model = RBD52G-5HacD2HnD
# serial number = 92F109F00470
/interface bridge
add name=bridge1
/interface wireless
set [ find default-name=wlan1 ] disabled=no installation=indoor mode=\
    ap-bridge ssid="PieFi setup" wireless-protocol=802.11 wps-mode=disabled
set [ find default-name=wlan2 ] mode=ap-bridge ssid=MikroTik \
    wireless-protocol=802.11
/interface ethernet
set [ find default-name=ether1 ] comment=WAN
/interface wireguard
add listen-port=13231 mtu=1420 name=wireguard1
/interface list
add name=LAN
add name=WAN
/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa2-psk mode=dynamic-keys \
    supplicant-identity=MikroTik
/ip pool
add name=dhcp_pool0 ranges=192.168.188.2-192.168.188.5
/ip dhcp-server
add add-arp=yes address-pool=dhcp_pool0 interface=bridge1 name=dhcp1 \
    server-address=192.168.188.1
/routing table
add disabled=no fib name=rtab-wg
/interface bridge port
add bridge=bridge1 interface=ether5
add bridge=bridge1 interface=ether2
add bridge=bridge1 interface=ether3
add bridge=bridge1 interface=ether4
add bridge=bridge1 interface=wlan2
add bridge=bridge1 interface=wlan1
/ip neighbor discovery-settings
set discover-interface-list=LAN
/ipv6 settings
set disable-ipv6=yes forward=no
/interface list member
add interface=bridge1 list=LAN
add interface=ether1 list=WAN
add interface=wireguard1 list=WAN
/interface wireguard peers
add allowed-address=0.0.0.0/0 endpoint-address=ip endpoint-port=\
    51820 interface=wireguard1 name=peer3 persistent-keepalive=25s \
    preshared-key="key" public-key=\
    "key"
/ip address
add address=192.168.188.1/24 interface=bridge1 network=192.168.188.0
add address=10.7.0.2/24 comment=wg interface=wireguard1 network=10.7.0.0
/ip dhcp-client
add interface=ether1
/ip dhcp-relay
add dhcp-server=192.168.188.1 disabled=no interface=wlan1 name=relay1
/ip dhcp-server network
add address=192.168.188.0/24 dns-server=10.7.0.1 gateway=192.168.188.1
/ip dns
set servers=8.8.8.8,8.8.4.4
/ip firewall address-list
add address=192.168.188.2 list=AUTHORIZED
add address=192.168.188.3 list=AUTHORIZED
add address=192.168.188.4 list=AUTHORIZED
add address=192.168.188.5 list=AUTHORIZED
add address=10.7.0.2 list=AUTHORIZED
/ip firewall filter
add action=accept chain=input connection-state=established,related,untracked
add action=drop chain=input connection-state=invalid
add action=accept chain=input protocol=icmp
add action=accept chain=input comment="admin access" src-address-list=\
    AUTHORIZED
add action=drop chain=input
add action=accept chain=forward comment="wireguard access" disabled=yes \
    out-interface=wireguard1 src-address=192.168.188.0/24
add action=fasttrack-connection chain=forward connection-state=\
    established,related hw-offload=yes
add action=accept chain=forward connection-state=established,related
add action=drop chain=forward connection-state=invalid
add action=accept chain=forward comment="local internet access" \
    in-interface-list=LAN out-interface-list=WAN
add action=accept chain=forward comment="users to wg" out-interface=\
    wireguard1 src-address=192.168.188.0/24
add action=drop chain=forward comment="drop all else"
/ip firewall mangle
add action=mark-routing chain=prerouting disabled=yes new-routing-mark=\
    rtab-wg passthrough=no src-address=192.168.188.2-192.168.188.255
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1
add action=masquerade chain=srcnat out-interface=wireguard1
/ip route
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    wireguard1 routing-table=rtab-wg scope=30 suppress-hw-offload=no \
    target-scope=10
/routing rule
add action=lookup-only-in-table comment="permites local traffic" disabled=no \
    min-prefix=0 table=main
add action=lookup-only-in-table disabled=no src-address=192.168.188.0/24 \
    table=rtab-wg
/system clock
set time-zone-name=Europe/London
/system note
set show-at-login=no

At some point, Mikrotik has added the min-prefix parameter to routing rules, but the explanation in Mikrotik manual just refers to the name of the feature as used in general Linux, and references I could find are also not very verbose regarding “side effects” (putting that in quotes as those effects may actually be intended).

In your configuration, there is the following:

/routing rule
add action=lookup-only-in-table min-prefix=0 table=main
add action=lookup-only-in-table src-address=192.168.188.0/24 table=rtab-wg

What the first rule actually says is: if there is any route in table main that matches the destination address of the packet better than the default one, use that table for the packet. Otherwise, skip to the next rule. So the handshake packet the router itself sends to the address of the Wireguard server definitely will skip to the next rule. The next rule matches on src-address=192.168.188.0/24 so that handshake packet will skip it too as its address is the WAN one. And here comes the question - is routing table main still the default/falback choice even though the first rule has already acted and its action was not just lookup (which permits fallback) but lookup-only-in-table? Before I can test that here, I suggest you add a third routing rule that says just action=lookup-only-in-table table=main (without min-prefix) and see whether that helps.

Hi Sindy since order is specific, should it be…
/routing rule
add action=lookup-only-in-table table=main
add action=lookup-only-in-table min-prefix=0 table=main disabled=yes { disabled as to test your thinking }
add action=lookup-only-in-table src-address=192.168.188.0/24 table=rtab-wg

No. When I say the new rule should be added as a third one, I mean it literally. The description before gives the reasons.