SurfShark Wireguard VPN Issues

Never mind! I figured it out.

I have the client address on the CHR side as a 32 bit address and on the local side as 24 bit. As soon as I made it a 24 bit address space on both sides, it worked.

I knew it was something simple and little!

Well, further update. While I have connectivity when trying to ping or do things via my local router, when I set my routing rules to say route my laptop through the CHR connection, I get nothing. So I still have some sort of routing issue going on.

At the most basic level, I can ping the remote LAN IP of 192.168.2.1 from my local router. I cannot ping it from my laptop.

I can ping the far end of all my other tunnels. All the routing settings are the same with the exception of my ProtonVPN ones being 32 bit addresses. But that should not make a difference - right?

Also, from the CHR, I can't ping my local router. So for example, if I try to ping 192.168.2.2 from the CHR, I don't get any responses.

So I either have some routing issues or firewall issues on possibly both ends... I'm stuck.

So all valid questions...

1.) Traffic flow - The main purpose of the CHR is to create my own VPN. So main traffic is going to be from home router out to internet through the CHR. Secondly, if another device were to connect to the CHR, I would want it to be able to access the home network. And the home network could also access that other device.

Make sense?

2.) Are /32 addresses needed in Wireguard as a requirement? I was hoping to basically create a "LAN" on the CHR where all connected clients would be in that subnet.

3.) I am not sure why the export of the CHR's settings does not show the fixed address. But it is absolutely there:

[admin@MikroTik] /ip> address print
Flags: D - DYNAMIC
Columns: ADDRESS, NETWORK, INTERFACE
#   ADDRESS           NETWORK      INTERFACE
0 D 172.xxx.xxx.xxx/24  172.xxx.xxx.xxx  ether1   
1   192.168.2.1/24    192.168.2.0  wg1 

4.) Regarding the sourcenat, I just don't know enough about what to do which is why I am here asking questions. :smiley:

And mainly at this point, I am just trying to get traffic flowing.

OK. I must have fat fingered something when entering the firewall commands because I lost connection to the CHR and can't get it back. I can't get in over SSH either. So I'll have to wipe the VPS and start all over. Gonna be a day or two before I can get this done again...

You can use safe mode in Winbox to avoid losing access to the device in case of an incorrect configuration, and you should still have access to CHR through the console in your VPS provider's personal account.

OK. I do have access via the console. But I don't know what I did wrong and I can't select and copy text from the console...

Yeah, I can export to a file but no way to get the file down to me...

Thank for for the tip on safe mode. Never knew what that was for!

If you want to use the CHR as the gateway to the internet then:

  • On the CHR:

    • In the peer setting associated with your MikroTik router, set allowed-address=192.168.2.2/32, don't set persistent-keepalive.

    • In the peer setting associated with your Laptop, set allowed-address=192.168.2.3/32, don't set persistent-keepalive. Normally you have to avoid giving overlapping address ranges between different peers of one WireGuard interface. Both peers having allowed-address=0.0.0.0/0 won't work.

    • You should apply proper firewall rules to protect your CHR. You can use the 7.21 defconf rules from this post of @rextended Buying - RB1100AHx4 Dude Edition - Questions about Firewall - #4 by rextended. Currently you have allow-remote-requests=yes for DNS on the CHR, so without proper firewall configuration your CHR will be abused to perform DNS amplification attacks for example.

    • Once you have the firewall in place, enable WAN connection on ether1 (you currently have DHCP client disabled and no static IP address & gateway configuration).

  • On your RB5009:

    • This NAT rule is wrong:

      /ip firewall nat
      add action=masquerade chain=srcnat in-interface=WG_VPS
      

      It should be out-interface=WG_VPS instead. But better is to remove the rule and add WG_VPS to the interface list WAN. Currently you have that interface in the list LAN! Having the interface in the WAN list will automatically apply the masquerade for you (by using the defconf: masquerade rule).

      You should treat WG_VPS like you treated ProtonVPN-IL50 and ProtonVPN-IL530 with regard to address list membership.

    • Also apply the two change-mss mangle rule to out-interface=WG_VPS.

If you've lost access, you've either changed the routing or the firewall, display the configuration in the console and look for suspicious settings.

ip/route/print

Perhaps you created a default route with your tunnel as the gateway, or something similar.

I've removed a bunch of firewall rules and still nothing. Also removed anything but dynamic routes. I think at this point it's easiest to just reset everything and reinstall it all.

EDIT: Got it back! Somehow I removed the WAN IP address.

So I'm going to still pretty much start over with setting things up and make sure I have all my rules in place, etc.

I forgot about the fact that WG peers can't have overlapping addresses. So if I want to have a "LAN" IP range on the CHR, then I really need to have a different set of 32 bit addresses for the WG connections.

Thanks on the other stuff. I'll fix the firewall rules and the rest.

OK. Seeing some success. I have connectivity now from devices on my local network that I route through the WG tunnel to the VPS. So that's good.

I'm still not able to ping my local LAN from the CHR, but I can ping my local router. Would that be some sort of firewall rule on my local end?

First you might need to reconsider, whether you really need the CHR to be access devices in your LAN or not. Because allowing that have big security consequence: if some bad guys gain access to your VPS, they'll have access to your whole LAN.

Currently with the setup modifications I mentioned in the previous post, the CHR is on the "WAN" side of your RB5009, like any other hosts on the internet. Your RB5009 when configured correctly obviously will block access from the internet to the devices in your LAN. It's normal and working as intended that you cannot ping your LAN devices from the CHR, just like the forum.mikrotik.com server cannot ping your PC in your LAN.

If you really want the CHR to have access to all the devices in your LAN (again, make sure that you really NEED that) then the following modifications need to be made:

  • On the RB5009:

    • Move WG_VPS out of interface list WAN back in interface list LAN.
    • If you had the masquerade rule with out-interface=WG_VPS remove it.
  • On the CHR:

    • Edit the peer associated with the RB5009 and change to allowed-address=192.168.2.2/32,192.168.0.0/23,192.168.200.0/24,192.168.100.0/24 (here besides 192.168.2.2/32 you'll put all the subnets of the bridges and VLANs on the RB5009 that you want to be able to access from the CHR).
    • Under /ip route add the corresponding routes with dst-address to those subnets and gateway=wg1.

Again, really think about whether you should give the CHR access to your LAN subnets or not.

I can see both sides of the coin here. CGG makes some very good points. Yes, if a bad actor were to take over the CHR, then they could get access to your LAN.

However, I would expect that CHR to be just as secure as my 5009 - no? Because if a bad actor got access to my 5009, they'd have full access to my LAN.

And yes, I only want to have traffic through Wireguard. So let me ruminate on this further.

Looks like the first thing I need to do is upgrade my VPS from a shared resource model (it was really cheap to get started and testing) to a dedicated resource VPS. I'm not getting anywhere near enough bandwidth from the shared VPS...

I set up a server on Massive Grid. Their prices seemed pretty good. The shared VPS was like $2.99 for what I selected. It's on a shared 5 Gbit network arm but I was only getting maybe 150 to 250 Mbps on it. So I just upgraded to dedicated with 2 TB throughput per month. It's $7.95.

I will say that I was shocked to see the number of attempted logins that were happening on the VPS. I've shut down things like https, telnet, etc. and moved my SSH port to a different port. I also have a very long and complex password! :smiley:

This can 100% be done on the RB5009 that OP has physical control at his place. Just a matter of drop rules on the forward chain, with dst-address=CHR_WG_TUNNEL_IP and src-address-list of OP's choice.

I will never trust the VPS to be secure. VPS means cheap price and SHARED physical server with too many factors that OP cannot control:

  • The hypervisor might have (yet to be public) security holes that allow cross-VM exploit, that's enough for some other customers to gain access to OP's VM. Or just plain remote exploits of the servers, that allow people from outside to gain access to the VPS.
  • The hosting company might have some rogue/disgruntled employees who gain unauthorized access to customers' VMs.
  • Maybe not even disgruntled employees, but the government authority where the VPS is hosted might request access, you might not even know what their laws can do.
  • They may be sloppy with their backup & image dump, and someone can gain read access to the CHR image -> they have the WireGuard private keys and all peer settings -> can gain access to your LAN from their laptop without needing to run code on the CHR VPS.

Again, in all the "exploits" above there is no need to guess OP's RouterOS password. The bad guy only need read access to the disk image of the VM, because RouterOS doesn't encrypt the storage. The WG keys and settings can be extracted and used to connect to the RB5009 from everywhere. That's how WireGuard works. It's made for roaming.

No reason to make the VPS a portal to your LAN. Even if the RB5009 had no public IP address and OP needs to access his LAN using the VPS's public IP address, he should forward an UDP port to the WG port on the RB5009 instead, so that the VPS only see the encrypted outer WG traffic.

The VPS can be used as 2nd portal to the internet, something similar to ProtonVPN or SurfShark, because what it can see in that case is what the ISPs normally also can see, namely mostly encrypted HTTPS traffic.

Like I wrote above. The security of the RB5009 only depends on MikroTik's code quality and your RouterOS configuration. But the security of the CHR not only depends on those factors, but also many more (for what I've listed some examples).

Well, I don't know how this whole thing is going to work out. I'm supposed to be on a 10Gbps dedicated line now and yet I'm getting speed tests of 124 Mbps through the CHR. Service ticket opened with the provider...

So what are you guys using for VPS CHR's? I'm not getting very good networking performance right now. I went with a basic 1 Xeon CPU core, 1 GB of RAM and 32 GB disk space and I have upgraded to dedicated hardware - VDS.

I'm getting about 150 Mb/s network speed. Not good. It's supposed to be sitting on a dedicated 10 Gbps link. MassiveGrid (the provider) says that it's because I need more CPU cores and memory. But that contradicts what MikroTik lists as resource requirements and when speed testing, I'm only seeing about 25% CPU usage on the CHR. So I have a hard time believing it's the server resources I have purchased...

What do you guys use for yours?

If you get 150 Mbps network speed through Wireguard, you’re definitely not restricted by license limitations of the CHR.

If you have 25% CPU usage and you have 4 “virtual cores” (threads for multi-threaded cores or actual cores if they are single-threaded) in total, it would suggest that Wireguard might run single-threaded on RouterOS so all packets of the same flow are handled by the same CPU “core”, so that single “core” gets saturated even though the rest is idling. As there is no way to be sure about this unless someone from Mikrotik development or product management would comment on that, the fastest way to check seems to me to set up another Wireguard interface (listening on another UDP port) at both the CHR and your 5009, load them both and see whether you get a 50% CPU usage that way.

If the CPUs support AES encryption in hardware, you may try to switch from Wireguard to IPsec and choose ciphering algorithms that are supported in hardware at both the CHR host and the 5009; that way, you might get to almost 0.5 Gbps if the bottleneck is the 5009. Which also suggests that the 150 Mbps bottleneck for Wireguard (chacha20poly1305 in software) may actually be the 5009 rather than the CHR - what is the CPU load on the 5009 when you hit that limit?

Oh, it's definitely not the 5009 that is the bottleneck here. I have WG connections to my current VPN provider (Proton) and get over a gigabit.

I have one single virtual CPU. According to their website, it's an Intel Xeon Gold 6130. Looking up specs on that CPU, it 16 Cores and 32 threads.

Now what I don't know since this is all virtualized is if I have a single core in that CPU or if I have the entire CPU. I would think that the entire CPU would be more than enough.

Looking further, I think I have one core in that CPU allocated to me. Because on their website, they advertise 1 to 64 vCores from 4x Intel Xeon Gold 6130. If you had 4 of these chips, that would = 64 cores.

Edit: Definitely not the number of cores. I've upgraded to 4 cores and 2 GB of memory now and speeds are still the same.

What does /system/resource/print show in the command line window on the CHR?