Wireguard not working

Hello,

please help with setting of WG, its not working,..


Router1


/interface wireguard
add listen-port=443 mtu=1420 name=wireguard1
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface lte apn
set [ find default=yes ] ip-type=ipv4

/interface bridge port
add bridge=bridge comment=defconf ingress-filtering=no interface=ether3
add bridge=bridge comment=defconf ingress-filtering=no interface=ether4
add bridge=bridge interface=Mikrotik5
add bridge=bridge interface=ether5
add bridge=bridge interface=Mikrotik2

/interface wireguard peers
add allowed-address=192.168.144.0/24 endpoint-address=185.16.81.136 \
    endpoint-port=443 interface=wireguard1 public-key=\
    "+C9Z1BF0zXAdkyHKW+BShKYuzcLFbGdajR/fJMg9f0A="
/ip address
add address=192.168.3.1/24 comment=defconf interface=bridge network=\
    192.168.3.0
add address=192.168.2.1/24 interface=bridgeEther2 network=192.168.2.0
add address=192.168.144.1/24 interface=wireguard1 network=192.168.144.0
/ip dhcp-client
add comment=defconf interface=ether1

/ip dns static
add address=192.168.3.1 comment=defconf name=router.lan
/ip firewall filter
add action=drop chain=forward comment=Ring disabled=yes src-address=\
    192.168.3.187
add action=accept chain=input dst-port=443 protocol=udp src-address=\
    185.16.81.136
add action=accept chain=input disabled=yes dst-port=443 protocol=udp \
    src-address=185.16.81.156
add action=accept chain=forward dst-address=10.1.168.0/24 src-address=\
    192.168.144.0/24
add action=accept chain=forward dst-address=192.168.144.0/24 src-address=\
    10.1.168.0/24
add action=accept chain=input in-interface=zerotier5
add action=accept chain=forward in-interface=zerotier5
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 disabled=yes 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



Router 2


/interface wireguard
add listen-port=443 mtu=1420 name=wireguard1
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN

/interface wireguard peers
add allowed-address=10.1.168.0/24 endpoint-address=185.5.225.240 \
    endpoint-port=443 interface=wireguard1 public-key=\
    "iSzlqEaPbNpZdkfy6+R0v1aE+IsWpIkrP48ATO4F4hg="
/ip address
add address=192.168.1.1/24 comment=defconf interface=bridge network=\
    192.168.1.0
add address=10.1.168.1/24 interface=wireguard1 network=10.1.168.0
/ip dhcp-client
add default-route-distance=2 interface=ether1 use-peer-dns=no

/ip firewall filter
add action=accept chain=input dst-port=443 protocol=udp src-address=\
    185.5.225.240
add action=accept chain=forward dst-address=192.168.144.0/24 src-address=\
    10.1.168.0/24
add action=accept chain=forward dst-address=10.1.168.0/24 src-address=\
    192.168.144.0/24
add action=accept chain=forward in-interface=zerotier1
add action=accept chain=input in-interface=zerotier1
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 disabled=yes 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 nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
    ipsec-policy=out,none out-interface-list=WAN
/ip smb
set domain=workgroup
/ip smb shares
add directory=/disk1 name=share1
/ip upnp
set show-dummy-rule=no
/snmp
set enabled=yes
/system clock
set time-zone-name=Europe/Prague

Suggest you have some basic understanding issues first to navigate and learn prior to making a wireguard configuration.

Pay particular attention to setting up both client and server (local and remote) peer settings. Half an hour spent here will pay dividends and it would not surprize me if you come back and say its all working fine now. Do some planning go through the steps and you will be fine!
https://forum.mikrotik.com/viewtopic.php?t=182340

Thank you for the guide, I will go through.

Please is here anyone who could help me more? Who could point where is the issue?

Lol…you might get some paid support…
What do you exactly mean by “its not working…”?

Things I notice (just a quick glance):

  • running on port 443…sure there is nothing else running on port 443?
  • what does logging say (you might want to add some ligging)?
  • you only accept wireguard connections from a specific IP address, is this rule hit (tip: counter)?

Additional tip:
Please sort your firewall rules (input, forward)

And another one:
https://help.mikrotik.com/docs/display/ROS/WireGuard

I mean no handshake no traffic.

  • running on port 443…sure there is nothing else running on port 443? Which ports do you suggest? I knowthe 443 should not by blocked.
  • what does logging say (you might want to add some ligging)? Sorry but im not sure how to log WG?
  • you only accept wireguard connections from a specific IP address, is this rule hit (tip: counter)? The allowed adress are correct, I could change it to subnests? But I have fallowed the guide which you have mentioned and there is exact IP not subnet.


    Please sort your firewall rules (input, forward) - I have added the FW rulles according the guide from you.

Could be caused by this rule, sure this is the public IP you use to connect from:

/ip firewall filter
add action=accept chain=input dst-port=443 protocol=udp src-address=\
    185.5.225.xxx

You could remove the src-address and add logging.
You can first try to make it work locally and then remotely.

How could I add logging?

Sure MikroTik is the best device for you?

/ip firewall filter
add action=accept chain=input dst-port=443 protocol=udp log=yes

Might want to add in-interface as well (and please don’t ask how, it is described in the help page I linked prefiously).
Just wondering…is the 185.5.225.xxx your public IP adress? Then it is correct (but you might want to remove it).

Im learning with MT and I could set up even the Zerotier, but this WG is problem. I have fallowed the guide but its not working…

yes, this is my public IP adress 185.5.225.xxx. So

So you say…

If you write down and answer these questions, and provide a network diagram I will be able to help.
Step 1: Identify all the connecting devices involved
Step2: Identify all the users, either individuals (like a smart phone or road warrior/laptop), or groups of users (aka a subnet of users).
Step3: Identify which user(s) need access to internet through WG (and thus not from their local ISP)
Step4: Identify which user(s) need access to the subnet at the other end of the tunnel (could be on an MT device or another router up or down from the MT device).
Step5: Identify as you the admin, which MT devices you wish to manage/Config from your local MT end of the WG tunnel.
Step6: Identify between applicable pairs of WG devices devices, WHICH device, for the initial connection, will be acting as SERVER (listening port active) and which will be CLIENT (sends original request).

In a nutshell one should do the following:

  1. PLAN Traffic Flows - from where to where for all use cases! (Dont forget Admin to Router for configuration if required)
  2. PLAN Initial Tunnel Connection - which site will start the tunnel request (client).
  3. PLAN Firewall Rules - how to get the traffic, entering and exiting the wg interface, to where it needs to go.
  4. PLAN Routing of Traffic - how to get the traffic routed properly (IP routes predominantly, and possibly dynamically accomplished by IP address if assigned to WG interface)

Adding to all previous made remarks …

A diagram would certainly clear out a lot of questions and/or assumptions.

Port 443 is default https when using TCP. Not sure about UDP.
Some other VPN protocols also use it (via TCP) but (my view) I think it’s a bad choice for wireguard since it’s UDP only.

And how do you know it’s not blocked ?
Outgoing most likely not (https, remember).
But what about incoming (ASSUMING you want to have your Mikrotik act as “server” ) ?? That’s what needs to work.

Since you say followed the guide, start with the port suggested there (and make SURE it gets forwarded on whatever device is sitting in between so your Mikrotik can be reached using that port, or it will NEVER work).
Change the port later once you understand how it is supposed to work.

But first some more info is needed.
We’re fishing here … but we don’t know where or for what.

Which port do you suggest to use? Why would anyone blocked 443 UDP? There was a time and WG had handshake on this port.I do not know if this port 13231 is not blocked…

To be honest I do not know how to recognize server and client?, when i need only one tunel between two mikroticks.

How could I check that Mikrotik can be reached using that port?

I have this in my FW, what is supposed to do?

/ip firewall filter
add action=accept chain=input dst-port=443 protocol=udp log=yes

@Rox169
443 UDP is used by QUIC a Google tech … so if you use chrome or any chrome derivative you will have issue with that port under WG. I suggest that you use port 44355 and see if that helps you. I have not checked your config properly so I cannot make further comment other that to suggest that you get WG working first before you introduce ZeroTier …

You didn’t even explain how you wanted to set up wireguard. Do you want those two routers connected to each other over wireguard? Or are you simply setting up two completely different routers for a roadwarrior type configuration? or is it something else?

Thank you I will try your suggestion…44355

Thank you for helping…yes, I want those two routers connected to each other over wireguard.

mducharme, the OP refuses to communicate despite given all the tools and ways and means to do so. Language barriers are not an excuse as google translate can be used both ways to answer the questions posed… Clearly there has been very little attempt to learn or read any reference material available or linked.
If the OP doesnt want to communicate not much else can be done.

OP: If it is PTP you want, I notice you have each router on a different wireguard subnet - it is nonsensical. One router has 192.168.144.1/24 on the wireguard interface and the other has 10.1.168.1/24 on its wireguard interface. I don’t see how you expect to get a point to point link working when using different subnets. I think you have not really understood the tutorials that you read, or you do not have a basic understanding of routing. It is the same scenario as configuring an IP on one router on one subnet on ether2 and configuring an IP on another router on ether2 on a different subnet and plugging the ether2’s together and expecting to get a response - you would not.

Guys please do not SPAM here, if you have nothing to say, be quite…

When you set up WG In routing table is dynamic route created to WG so there should not be a problem,no?