I’m trying to build a simple wireguard setup on a very simple test network. This is my own training environment with nothing else significant connected to the network, so if I botch a firewall rule or something, it’s not the end of the world. But I’m struggling to get it working. I read https://forum.mikrotik.com/viewtopic.php?t=182340 and several other threads but I am not able to solve this.
Assumptions:
-I have a WAN connection on sfp1 on my hex/s
-My routerOS bridge (LAN) is assigned the address 192.168.88.1
-There is a raspberry pi on the LAN – assigned 192.168.88.8
-My ISP is kind enough to really never change my public address, and as far as I can tell they don’t block anything.
-“Server” refers to the hex/s
-“Client” refers to a linux laptop I would like to connect, via wireguard, from over the internet, and be able to log in to the hex/s and to the raspberry pi.
-The public IP of my client laptop could be anything since I will travel around with it, including connecting to the internet via mobile hotspot.
-I would like my client laptop to have a LAN IP address of 192.168.88.100 once it is connected thru wireguard.
-No other wireguard peers are planned at this time-- I’ll experiment with that after I get a basic connection working.
-I don’t need the client laptop to be able to access the internet again through the hex/s right now, but I would like to configure that at a later time.
Network diagram:
Most of the online tutorials assume you are trying to set up a PTP wireguard tunnel with 10.0.0.x subnetting; for instance, one mikrotik device to another. Since I’m not connecting two mikrotik devices, I don’t understand how to adapt these tutorials to my situation. Here are the rules I have set up on the hex/s (the “server”). But they don’t seem to work…
/interface wireguard
add listen-port=51820 mtu=1420 name=wireguard1
/interface wireguard peers
add interface=wireguard1 public-key="[REDACTED]"
/ip address
add address=192.168.88.1/24 comment=defconf interface=bridge network=192.168.88.0
add address=192.168.88.100 interface=wireguard1 network=192.168.88.0
/ip firewall
add action=accept chain=input comment="defconf: accept established,related,untracked" connection-state=established,related,untracked
add action=accept chain=input comment="Allow Wireguard/UDP/51820" dst-port=51820 log=yes protocol=udp
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=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
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" ipsec-policy=out,none out-interface-list=WAN
I can ping the public address of my hex/s from my client. nmap UDP scan of port 51820 says the port is closed. So naturally, Wireguard won’t connect.
Assuming that I have the right public IP, and the ISP is not blocking anything, and my client wireguard configuration is correct, (I’m reasonably confident in these points, and I’m verifying them separately), Can anyone advise me:
- In general, does my approach seem to reflect any gross misunderstandings of wireguard?
- Is it feasible, or reasonable practice, to just have my wireguard client take an IP address of 192.168.88.100, or should I be following the example of making 10.0.0.x subnets like many tutorials describe? If so, what purpose would this serve?
- Since my current configuration fails, what rules may I have forgotten or set incorrectly?
Any help is much appreciated. I’d like to just get a simple wireguard proof of concept working before I try doing things like setting up a Tailscale container, or adding other complexities. Everyone seems to say wireguard is simple to set up, but I’m struggling.
Thank you,
Colm
PS. I actually just noticed the announcement of the new BTH VPN feature http://forum.mikrotik.com/t/new-feature-back-to-home-vpn/168434/1 but I want to learn to do things the hard way first