Networking

pfSense Wireguard: Setup Fast Open-Source VPN Configuration

Explore the world of pfSense WireGuard, learn how to configure a secure VPN tunnel, manage IP addresses, and troubleshoot common issues.

pfSense has a lot of great features that allow you to have an enterprise firewall in your home lab or even production environment for free. You can setup VPN connections using a variety of VPN solutions. One of these is Wireguard. Let’s look at pfSense Wireguard setup and see how this is configured.

What is pfSense?

It’s an open-source firewall solution you can download for free that is built on top of FreeBSD. It has many features, including VPN and can be installed on most hardware platforms. Using pfSense you can also have an endpoint that serves as a DNS server and allows you to do things like DNS query forwarding, DNS server override for DNS servers, and more with your DNS server settings, like enable forwarding mode.

Learn more about pfSense here: pfSenseยฎ – World’s Most Trusted Open Source Firewall.

pfSense open source firewall
pfSense open source firewall

pfSense open source firewall allows you to add a new gateway for your Wireguard server so you can have a security and VPN solution.

What is Wireguard

Wireguard has gained a lot of momentum in VPN solutions since it is an extremely lightweight and secure VPN protocol that also performs really well. These two things appeal to most when looking for a VPN solution in the home lab or enterprise.

Wireguard is fast secure and increasingly common
Wireguard is fast secure and increasingly common

Wireguard is fast, secure and getting to be more common among VPN solutions today that allows you to add a VPN gateway and VPN interface in combination with your firewall rule configuration on your pfSense firewall.

Learn more about Wireguard here: WireGuard: fast, modern, secure VPN tunnel.

pfSense and WireGuard together

When you combine the two, they provide a router, firewall and VPN solution all rolled into one and without any cost. Using pfSense with Wireguard, you can built really fast VPN tunnels that work well for your users.

Installing the WireGuard Package in pfSense

Let’s see how you can install WireGuard in pfSense as this is the first step. We need to go to the pfSense Package Manager and search for “wireguard.” This will display the available packages built on top of WireGuard.

Click install next to the package you want to install. Make sure to check the ‘Enable WireGuard’ box after installation.

pfSense includes Wireguard as a system package for installation
pfSense includes Wireguard as a system package for installation

Next, you will need to confirm the installation of the package on your pfSense instance.

Confirm the Wireguard package installation in pfSense
Confirm the Wireguard package installation in pfSense

You will see the package installer status.

The pfSense Wireguard package installs successfully
The pfSense Wireguard package installs successfully

Now, you will see the Wireguard option listed under the VPN menu.

Wireguard appears under the VPN menu in pfSense
Wireguard appears under the VPN menu in pfSense

Creating the WireGuard Tunnel

Let’s create the WireGuard tunnel for your VPN. Under WireGuard -> Tunnels, you will create your tunnel configuration. This will have as part of the config, the private key, listen port, and interface addresses. Check the tunnel settings and click save.

Below, we are clicking theย Add Tunnelย button.

Add tunnel in pfSense Wireguard configuration
Add tunnel in pfSense Wireguard configuration

Here, you will configure a listen port, generate the interface keys, and assign an interface address. You will also generate the keypair that will be used for creating connections securely. Then just click the Save Tunnel button.

Create the Wireguard tunnel and configuration settings
Create the Wireguard tunnel and configuration settings

Configuring the WireGuard Interface

In the Interface Assignment tab you will assign the Wireguard interface. After adding the tunnel, you will see the new OPT interface, which may be numbered differently depending on your existing interfaces.

Wireguard interface assignment
Wireguard interface assignment

If you configure your OPT interface, you have the option to Enable interface. Also, set the IPv4 or IPv6 configuration type. Set your IP address configuration.

Enabling the Wireguard interface and configuring the IP address information
Enabling the Wireguard interface and configuring the IP address information

You can see the Address/Assignment is configured for the Wireguard tunnel.

Address listen port and interface are all assigned
Address listen port and interface are all assigned

If you just use an address and don’t create a new interface (which is perfectly fine), you will see the tunnel created and it looks like the following.

Saving configuration and tunnel created
Saving configuration and tunnel created

Firewall Rules

Go to your Firewall -> Rules -> WireGuard settings. Setting up firewall rules to govern the traffic flow through your WireGuard tunnel is an extremely important step. You will want to pay attention to rules about the local network (LAN net) and the allowed IPs for connecting. After you make sure of the rules, click save. You can also add rules later as needed.

Wireguard firewall rules in pfSense
Wireguard firewall rules in pfSense
Allowing Wireguard traffic on the WAN interface
Allowing Wireguard traffic on the WAN interface
Allowing all traffic on the Wireguard interface
Allowing all traffic on the Wireguard interface

Peer Configuration

Next is peer configuration. For each Wireguard peer (e.g., client device), you will want to have a unique public key and IP address (allowed IPs). Also configure endpoint IP addresses and endpoint ports for the purposes of dynamic resolution.

Security can be increased by using a pre-shared key for the tunnel. You can also manually enter an IP address and if you are doing that, uncheck the Dynamic Endpoint checkbox.

Creating a new peer in pfSense for connecting to Wireguard
Creating a new peer in pfSense for connecting to Wireguard

Make sure to apply all your changes to your Wireguard configuration.

Wireguard changes applied successfully in pfSense
reguard changes applied successfully in pfSense

Wrapping Up: Harnessing the Power of pfSense and WireGuard

Combining both pfSense and Wireguard VPN for a firewall and VPN solution is a great way to have enterprise features and connectivity without any cost. I really like pfSense as it is fairly intuitive and you get a lot of features right out of the box. Wireguard is definitely the VPN solution of choice among most today since it is lightweight, secure, and is fast. These are all the things most look for in a VPN solution.

Subscribe to VirtualizationHowto via Email ๐Ÿ””

Enter your email address to subscribe to this blog and receive notifications of new posts by email.



Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at Virtualizationhowto.com, and a 7-time VMware vExpert, with over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, He has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family. Also, he goes through the effort of testing and troubleshooting issues, so you don't have to.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.