OPNsense Forum

English Forums => Virtual private networks => Topic started by: jimjohn on July 21, 2022, 12:31:10 PM

Title: Harden OPNsense for WireGuard Access
Post by: jimjohn on July 21, 2022, 12:31:10 PM
Hi,

I successfully configured WireGuard on an OPNsense behind a Fritz!Box. I did a port forward to the WAN of the OPNsense and was able to connect from my cellphone. So far so good. Before I activate the port forward in the Fritz!Box continuously, I wonder if there is anything I can do on the WAN side of the OPNsense to harden it. For example against any spamming / port scanning / flooding. How do you harden your VPN ports properly?

Second question: if I only want to use the WireGuard for a RoadWarrior usage, would you allow all traffic via the tunnel and block the packages on the WireGuard side via the firewall rules? Or can I somehow decide even earlier on the cellphone?

Third question: I have two interfaces for WireGuard on the OPNsense: the WireGuard (Group) and my specific WireGuard interface. How to you manage the rules here? Is the "Group" interface similar to the "Floating Rules" but only for the WireGuard interfaces?
Title: Re: Harden OPNsense for WireGuard Access
Post by: jimjohn on July 23, 2022, 07:09:24 PM
Noone?
Title: Re: Harden OPNsense for WireGuard Access
Post by: Maurice on July 23, 2022, 08:59:09 PM
1. wg uses a single UDP port and is stateless. It won't respond to invalid packets. No need for further "hardening" imho.

2. Only the phone's tunnel address(es) should be added to the allowed IPs in OPNsense. And only the networks to be made accessible through the tunnel should be added to the allowed IPs on the phone. Further restrictions require firewall rules.

3. WireGuard (Group) includes all wg interfaces (which you can have many of). Firewall rules added to the group apply to all wg interfaces. If you have only one wg interface, it doesn't matter where you add the rules.

Cheers
Maurice
Title: Re: Harden OPNsense for WireGuard Access
Post by: jimjohn on July 23, 2022, 09:20:46 PM
Thanks!
Title: Re: Harden OPNsense for WireGuard Access
Post by: nzkiwi68 on July 28, 2022, 11:54:18 PM
Since you are connecting from a mobile device, it's often diffcult to "lockdown" the WAN interface rule and only allow IP traffic from IP address xxx or yyy because with a mobile device you often cannot say in advanced exactly what your IP address will be.

However, there are a few step you can take.


Personally I use WG for remote access and I lock down the WAN to WG firewall rule to only accept IP traffic from New Zealand based IP addresses.
Title: Re: Harden OPNsense for WireGuard Access
Post by: RamSense on July 29, 2022, 07:29:05 AM
I have also been trying to get this one step further, but did not got it to work.
I added a captive portal to Wireguard and in that I added to "Allowed MAC addresses" the MAC addresses of the mobiles being allowed to connect.
This seems not to be working from outside/over wan and only works local / LAN, but it can also be that I missed something. So if anybody tried this and got it to work, I would love to hear that.
Title: Re: Harden OPNsense for WireGuard Access
Post by: jimjohn on July 29, 2022, 07:34:20 AM
Quote from: RamSense on July 29, 2022, 07:29:05 AM
I added a captive portal to Wireguard and in that I added to "Allowed MAC addresses" the MAC addresses of the mobiles being allowed to connect.

Nice idea with the MAC address. You could still make a firewall rule for the MAC address though ...
Title: Re: Harden OPNsense for WireGuard Access
Post by: RamSense on July 29, 2022, 07:42:36 AM
sounds like an option, but I seem not to being able to add mac addresses into the firewall-rules-wan rule?

Or should the rule be: source "any" being changed to source "aliases with mac addresses" ?
Title: Re: Harden OPNsense for WireGuard Access
Post by: jimjohn on July 29, 2022, 07:47:19 AM
You can set the MAC address as an alias and add it as the source in the firewall rule.
Title: Re: Harden OPNsense for WireGuard Access
Post by: RamSense on July 29, 2022, 07:50:28 AM
Exaclty. But I am getting the same problem. Works over LAN but not over WAN/4g/5g being away from home.

Do you get it to work?
Title: Re: Harden OPNsense for WireGuard Access
Post by: jimjohn on July 29, 2022, 07:52:18 AM
No, I did not try it, only using it in the LAN. Do a PCAP and check if the correct MAC address is in the package coming from the mobile device.
Title: Re: Harden OPNsense for WireGuard Access
Post by: nzkiwi68 on August 11, 2022, 04:42:38 AM
The Wireguard VPN client is routed layer 3, not a layer 2 broadcast domain, therefore the OPNsense firewall never learns the MAC address of the WG client.

Therefore it's quite impossible to use a MAC address based firewall rule.