WireGuard Road Warrior Setup — OPNsense documentation (2024)

  • »
  • Virtual Private Networking »
  • WireGuard Road Warrior Setup

Introduction

WireGuard is a simple, fast VPN protocol using modern cryptography. It aims to be faster and less complex than IPsec whilst also being a considerably more performant alternative to OpenVPN. Initially released for the Linux kernel, it is now cross-platform and widely deployable.

This how-to describes setting up a central WireGuard Instance (server) on OPNsense and configuring one or more client peers to create a tunnel to it.

Step 1 - Configure the Wireguard Instance

  • Go to VPN ‣ WireGuard ‣ Instances

  • Click + to add a new Instance configuration

  • Configure the Instance configuration as follows (if an option is not mentioned below, leave it as the default):

    Enabled

    Checked

    Name

    Call it whatever you want (eg HomeWireGuard )

    Public Key

    This will initially be blank; Press the cogwheel to auto-generate new keys.

    Private Key

    This will initially be blank; Press the cogwheel to auto-generate new keys.

    Listen Port

    51820 or a higher numbered unique port

    MTU

    1420 (default) or 1412 if you use PPPoE; it’s 80 bytes less than your WAN MTU

    Tunnel Address

    For example, 10.10.10.1/24. See note below

    Peers

    The (client) peers will be specified here; leave it blank initially until the Peer configuration is created in Step 2

    Disable Routes

    Unchecked

Note

The tunnel address must be in CIDR notation and must be a unique IP and subnet for your network, such as if it was on a physically different routed interface. The subnet should be an appropriate size that includes all the client peers that will use the tunnel. For IPv4 it should be a private (RFC1918) address, for example 10.10.10.1/24. For IPv6, it could either be a unique ULA /64 address, or a unique GUA /64 address derived from your prefix delegation. Do not use a tunnel address that is a /32 (IPv4) or a /128 (IPv6)

Note

Leave the DNS Server field (which appears if advanced mode is selected) blank. Otherwise WireGuard will overwrite OPNsense’s DNS configuration

  • Save the Instance configuration, and then click Save again

  • Re-open the Instance configuration

  • Copy the public key that has been generated in the configuration. This will be needed for the client device - see Step 6

  • Save or Cancel to exit the configuration

Step 2 - Configure the client peer

  • Go to VPN ‣ WireGuard ‣ Peers

  • Click + to add a new Peer

  • Configure the Peer as follows (if an option is not mentioned below, leave it as the default):

    Enabled

    Checked

    Name

    Call it whatever you want (eg Phone )

    Public Key

    Insert the public key from the client; if needed skip ahead and start Step 6 to generate the client public key

    Allowed IPs

    Unique tunnel IP address (IPv4 and/or IPv6) of client - it should be a /32 or /128 (as applicable) within the subnet configured on the WireGuard Instance. For example, 10.10.10.2/32

  • Save the Peer configuration, and then click Save again

  • Now go back to VPN ‣ WireGuard ‣ Instances

  • Open the Instance configuration that was created in Step 1 (eg HomeWireGuard)

  • In the Peers dropdown, select the newly created Peer (eg Phone)

  • Save the Instance configuration again, and then click Save once more

  • Repeat this Step 2 for as many clients as you wish to configure

Step 3 - Turn on/restart WireGuard

  • Turn on WireGuard under VPN ‣ WireGuard ‣ General if it is not already on (click Apply after checking the checkbox)

  • Otherwise, restart WireGuard - you can do this by turning it off and on under VPN ‣ WireGuard ‣ General (click Apply after both unchecking and checking the checkbox)

Step 4 - Assignments and routing

Note

The steps outlined in Steps 4(a) and 4(b) below may not be required at all in your circ*mstances. Strictly speaking, if you only intend for your clients to use the tunnel to access local IPs/subnets behind OPNsense, then neither step is actually necessary. If you intend to use the WireGuard tunnel to also access IPs outside of the local network, for example the public internet, then at least one, and perhaps both, of the steps will be required. This is explained below

However, it is useful to complete Step 4(a) anyway, for the reasons explained in that step

Step 4(a) - Assign an interface to WireGuard (recommended)

Hint

This step is not strictly necessary in any circ*mstances for a road warrior setup. However, it is useful to implement, for several reasons:

First, it generates an alias for the tunnel subnet(s) that can be used in firewall rules. Otherwise you will need to define your own alias or at least manually specify the subnet(s)

Second, it automatically adds an IPv4 outbound NAT rule, which will allow the tunnel to access IPv4 IPs outside of the local network (if that is desired), without needing to manually add a rule

Finally, it allows separation of the firewall rules of each WireGuard instance (each wgX device). Otherwise they all need to be configured on the default WireGuard group that OPNsense creates. This is more an organisational aesthetic, rather than an issue of substance

  • Go to Interfaces ‣ Assignments

  • In the dropdown next to “New interface:”, select the WireGuard device (wg1 if this is your first one)

  • Add a description (eg HomeWireGuard)

  • Click + to add it, then click Save

  • Then select your new interface under the Interfaces menu

  • Configure it as follows (if an option is not mentioned below, leave it as the default):

    Enable

    Checked

    Lock

    Checked

    Description

    Same as under Assignments, if this box is not already populated

    IPv4 Configuration Type

    None

    IPv6 Configuration Type

    None

Note

There is no need to configure IPs on the interface. The tunnel address(es) specified in the Instance configuration for your server will be automatically assigned to the interface once WireGuard is restarted

  • Save the interface configuration and then click Apply changes

  • Restart WireGuard - you can do this by turning it off and on under VPN ‣ WireGuard ‣ General (click Apply after both unchecking and checking the checkbox)

Tip

When assigning interfaces, gateways can be added to them. This is useful if balancing traffic across multiple tunnels is required or in more complex routing scenarios. To do this, go to System ‣ Gateways ‣ Configuration and add a new gateway. Choose the relevant WireGuard interface and set the Gateway to dynamic. These scenarios are otherwise beyond the scope of this how-to

Tip

If Unbound DNS is configured with all interfaces registered it requires a reload of Unbound DNS to get the new Wireguard interface added. This is necessary to get DNS working through the VPN tunnel.

Step 4(b) - Create an outbound NAT rule

Hint

This step is only necessary (if at all) to allow client peers to access IPs outside of the local IPs/subnets behind OPNsense - see the note under Step 4. If an interface has already been assigned under Step 4(a), then it is not necessary for IPv4 traffic, and is only necessary for IPv6 traffic if the tunnel uses IPv6 ULAs (IPv6 GUAs don’t need NAT). So in many use cases this step can be skipped

  • Go to Firewall ‣ NAT ‣ Outbound

  • Select “Hybrid outbound NAT rule generation” if it is not already selected, and click Save and then Apply changes

  • Click Add to add a new rule

  • Configure the rule as follows (if an option is not mentioned below, leave it as the default):

    Interface

    WAN

    TCP/IP Version

    IPv4 or IPv6 (as applicable)

    Protocol

    any

    Source invert

    Unchecked

    Source address

    If you assigned an interface under Step 4(a), select the generated alias for the interface subnet(s) (eg HomeWireGuard net ) - see note below if you didn’t assign this interface

    Source port

    any

    Destination invert

    Unchecked

    Destination address

    any

    Destination port

    any

    Translation / target

    Interface address

    Description

    Add one if you wish to

  • Save the rule, and then click Apply changes

  • Restart WireGuard - you can do this by turning it off and on under VPN ‣ WireGuard ‣ General (click Apply after both unchecking and checking the checkbox)

Hint

If you didn’t assign an interface as suggested in Step 4(a), then you will need to manually specify the source IPs/subnet(s) for the tunnel (for example, 10.10.10.0/24). It’s probably easiest to define an alias (via Firewall ‣ Aliases) for those IPs/subnet(s) and use that. If you have only one WireGuard Instance and only one WireGuard Peer configured, you can use the default WireGuard net, although this is generally not recommended due to unexpected behaviour

Step 5 - Create firewall rules

This will involve two steps - first creating a firewall rule on the WAN interface to allow clients to connect to the OPNsense WireGuard server, and then creating a firewall rule to allow access by the clients to whatever IPs they are intended to have access to.

  • Go to Firewall ‣ Rules ‣ WAN

  • Click Add to add a new rule

  • Configure the rule as follows (if an option is not mentioned below, leave it as the default):

    Action

    Pass

    Quick

    Checked

    Interface

    WAN

    Direction

    in

    TCP/IP Version

    IPv4 or IPv4+IPv6 (as desired, depending on how you want clients to connect to the server; note this is distinct from what type of traffic is allowed in the tunnel once established)

    Protocol

    UDP

    Source / Invert

    Unchecked

    Source

    any

    Destination / Invert

    Unchecked

    Destination

    WAN address

    Destination port range

    The WireGuard port specified in the Instance configuration in Step 1

    Description

    Add one if you wish to

  • Save the rule, and then click Apply Changes

  • Then go to Firewall ‣ Rules ‣ [Name of interface assigned in Step 4(a)] - see note below if you didn’t assign this interface

  • Click Add to add a new rule

  • Configure the rule as follows (if an option is not mentioned below, leave it as the default):

    Action

    Pass

    Quick

    Checked

    Interface

    Whatever interface you are configuring the rule on (eg HomeWireGuard ) - see note below

    Direction

    in

    TCP/IP Version

    IPv4 or IPv4+IPv6 (as applicable)

    Protocol

    any

    Source / Invert

    Unchecked

    Source

    If you assigned an interface under Step 4(a), select the generated alias for the interface subnet(s) (eg HomeWireGuard net ) - see note below if you didn’t assign this interface

    Destination / Invert

    Unchecked

    Destination

    Specify the IPs that client peers should be able to access, eg “any” or specific IPs/subnets

    Destination port range

    any

    Description

    Add one if you wish to

  • Save the rule, and then click Apply Changes

Note

If you didn’t assign an interface as suggested in Step 4(a), then the second firewall rule outlined above will need to be configured on the automatically created WireGuard group that appears once the Instance configuration is enabled and WireGuard is started. You will also need to manually specify the source IPs/subnet(s) for the tunnel. It’s probably easiest to define an alias (via Firewall ‣ Aliases) for those IPs/subnet(s) and use that. If you have only one WireGuard Instance and only one WireGuard Peer configured, you can use the default WireGuard net, although this is generally not recommended due to unexpected behaviour

Step 5a - Create normalization rules

  • Go to Firewall ‣ Settings -> Normalization and press + to create one new normalization rule.

  • If you only pass IPv4 traffic through the wireguard tunnel, create the following rule:

    Interface

    WireGuard (Group)

    Direction

    Any

    Protocol

    any

    Source

    any

    Destination

    any

    Destination port

    any

    Description

    Wireguard MSS Clamping IPv4

    Max mss

    1380 (default) or 1372 if you use PPPoE; it’s 40 bytes less than your Wireguard MTU

  • Save the rule

  • If you pass IPv4+IPv6 - or only IPv6 traffic - through the wireguard tunnel, create the following rule:

    Interface

    WireGuard (Group)

    Direction

    Any

    Protocol

    any

    Source

    any

    Destination

    any

    Destination port

    any

    Description

    Wireguard MSS Clamping IPv6

    Max mss

    1360 (default) or 1352 if you use PPPoE; it’s 60 bytes less than your Wireguard MTU

  • Save the rule

Tip

  • The header size for IPv4 is usually 20 bytes, and for TCP 20 bytes. In total thats 40 bytes for IPv4 TCP.

  • IPv6 has a larger header size with 40 bytes. That encreases the total to 60 bytes for IPv6 TCP.

Note

By creating the normalization rules, you ensure that IPv4 TCP and IPv6 TCP can pass through the Wireguard tunnel without being fragmented. Otherwise you could get working ICMP and UDP, but some encrypted TCP sessions will refuse to work.

Step 6 - Configure the WireGuard client

Tip

Key generation can be performed on an appropriate device with WireGuard client tools installed. A one-liner for generating a matching private and public keypair is wg genkey | tee private.key | wg pubkey > public.key. Alternatively, WireGuard apps that can be used on some devices can automate key generation for you

Client configuration is largely beyond the scope of this how-to since there is such a wide array of possible targets (and corresponding configuration methods). An example client (and server) configuration is in the Appendix. The key pieces of information required to configure a client are described below:

[Interface]

Address

Refers to the IP(s) specified as Allowed IPs in the Peer configuration on OPNsense. For example, 10.10.10.2/32

PrivateKey

Refers to the private key that (along with a public key) needs to be manually or automatically generated on the client. The corresponding public key must then be copied into the Peer configuration on OPNsense for the relevant client peer - see Step 2

DNS

Refers to the DNS servers that the client should use for the tunnel - see note below

[Peer]

PublicKey

Refers to the public key that is generated on OPNsense. Copy the public key from the Instance configuration on OPNsense - see Step 1

Endpoint

Refers to the public IP address or publicly resolvable domain name of your OPNsense host, and the port specified in the Instance configuration on OPNsense

AllowedIPs

Refers to the traffic (by destination IPs/subnets) that is to be sent via the tunnel. For example, if all traffic on the client is to be sent through the tunnel, specify 0.0.0.0/0 (IPv4) and/or ::/0 (IPv6)

Note

If the DNS server(s) specified are only accessible over the tunnel, or you want them to be accessed over the tunnel, make sure they are covered by the AllowedIPs

Appendix - Example configurations

Warning

Do not re-use these example keys!

An example client configuration file:

[Interface]PrivateKey = 8GboYh0YF3q/hJhoPFoL3HM/ObgOuC8YI6UXWsgWL2M=Address = 10.10.10.2/32, fd00:1234:abcd:ef09:10:2/128DNS = 192.168.1.254, fd00:1234:abcd:ef09:1:254[Peer]PublicKey = OwdegSTyhlpw7Dbpg8VSUBKXF9CxoQp2gAOdwgqtPVI=AllowedIPs = 0.0.0.0/0, ::/0Endpoint = opnsense.example.com:51820

An example server configuration file:

[Interface]Address = 10.10.10.1/24, fd00:1234:abcd:ef09:10:1/64ListenPort = 51820PrivateKey = YNqHwpcAmVj0lVzPSt3oUnL7cRPKB/geVxccs0C0kk0=[Peer]PublicKey = CLnGaiAfyf6kTBJKh0M529MnlqfFqoWJ5K4IAJ2+X08=AllowedIPs = 10.10.10.2/32, fd00:1234:abcd:ef09:10:2/128
WireGuard Road Warrior Setup — OPNsense  documentation (2024)

FAQs

How to configure WireGuard VPN on OpnSense? ›

WireGuard Road Warrior Setup
  1. Step 1 - Install the WireGuard plugin. ...
  2. Step 2 - Configure the Wireguard Instance. ...
  3. Step 3 - Configure the client peer. ...
  4. Step 4 - Turn on/restart WireGuard. ...
  5. Step 5 - Assignments and routing. ...
  6. Step 6 - Create firewall rules. ...
  7. Step 6a - Create normalization rules. ...
  8. Step 7 - Configure the WireGuard client.

How to configure firewall for WireGuard? ›

Firewall Rules
  • Navigate to Firewall > Rules, WAN tab.
  • Click Add to add a new rule to the top of the list.
  • Use the following settings: Action: Pass. Interface: WAN. Protocol: UDP. Source: any. Destination: WAN Address. Destination Port Range: (other), 51820. Description: Pass traffic to WireGuard.
  • Click Save.
  • Click Apply Changes.
Apr 3, 2024

How to make WireGuard? ›

Setting up a WireGuard VPN requires the following:
  1. A VPS (Virtual Private Server) or a server with a public IP address.
  2. Access to the server's command line (typically via SSH).
  3. WireGuard software installed on both the server and your local machine (client).
  4. Basic knowledge of networking and command-line tools.
Mar 14, 2024

Does pfSense support WireGuard? ›

To use WireGuard, upgrade to the latest version of pfSense Plus or pfSense CE software then install the WireGuard package from the Package Manager.

What ports are required for WireGuard? ›

What ports do you use for WireGuard? UDP ports 53, 80, 443, 1194, 2049, 2050, 30587, 41893, 48574, 58237.

What is the config file for WireGuard VPN? ›

WireGuard config is in INI syntax, defined in a file usually called wg0. conf . It can be placed anywhere on the system, but is often placed in /etc/wireguard/wg0. conf .

What is the best firewall for WireGuard? ›

When setting up a new WireGuard server on Linux, what's the best firewall to use? We recommend using firewalld on WireGuard Endpoints, and nftables on WireGuard Gateways.

Does WireGuard use TCP or UDP? ›

Networking. WireGuard uses only UDP, due to the potential disadvantages of TCP-over-TCP. Tunneling TCP over a TCP-based connection is known as "TCP-over-TCP", and doing so can induce a dramatic loss in transmission performance (a problem known as "TCP meltdown").

Is WireGuard better than OpenVPN? ›

When it comes to internet and VPN connection speeds, WireGuard is the go-to choice. It was specifically designed to offer higher speed performance and be lighter than OpenVPN. To put that into perspective, WireGuard only uses 4,000 lines of code, whereas OpenVPN uses around 70,000.

Do I need a static IP address for WireGuard? ›

If you have a static IP address from your ISP then you don't need to do anything, we can just use the IP name you have been given or the IP itself. If you have a dynamic IP address then you will need to setup dynamic DNS. For my setup I used NoIP.com.

How do I manually set a WireGuard? ›

Connect to the VPN
  1. In the WireGuard application, click on Import tunnel(s) from file.
  2. Now select the Surfshark configuration file you downloaded earlier, and hit Open.
  3. You can rename this uploaded connection to your liking. ...
  4. Lastly, to connect to the VPN, click Activate, and to disconnect from the VPN, click Deactivate.
Jun 19, 2024

Does WireGuard require a server? ›

A WireGuard VPN usually involves a client (the app on your phone, for example) and a VPN server. Like other encryption protocols, WireGuard communicates with the server and establishes an encrypted tunnel between server and client.

What is better, OPNsense or pfSense? ›

If you want high customizability and a large support community, pfSense is a good option. If you prioritize an easy-to-use interface and frequent updates, instead, OPNsense may be better. Ultimately, pfSense offers more flexibility for seasoned users, but OPNsense provides a more polished out-of-box experience.

What port does WireGuard config listen to? ›

The 51820 is the default Wireguard (listening) port. You should have a port forward of 51820 from your main router to the IP address allocated by your main router to your gl.

How do I allow WireGuard through my router? ›

Go to [VPN] > [VPN Server] > enable and click [WireGuard® VPN] > click add button. 4. For general devices like laptops or phones, you can just click the Apply button.

How do I setup a WireGuard VPN client? ›

  1. Step 1: Expose Wireguard VPN Server to the Internet. Your Public IP Address. ...
  2. Step 2: Setup Wireguard VPN Server. Install the wireguard software and dependencies. ...
  3. Step 3: Setup client connections. ...
  4. Step 4: Setup clients. ...
  5. Step 5: Test Connection.
Sep 29, 2023

How to configure WireGuard on Pi? ›

Installing everything we will need for a wireguard connections is as simple as running:
  1. sudo apt-get install wireguard wireguard-tools. ...
  2. sudo add-apt-repository ppa:wireguard/wireguard sudo apt update sudo apt install wireguard wireguard-tools. ...
  3. sudo -i cd /etc/wireguard umask 077.

How to setup WireGuard VPN server on Linux? ›

Setting up WireGuard VPN on Linux Server
  1. sudo apt update. ...
  2. sudo yum install epel-release -y.
  3. sudo yum install wireguard-dkms wireguard-tools -y.
  4. cd /etc/wireguard/ ...
  5. nano /etc/wireguard/wg0.conf.
  6. wg genkey | tee client_private_key | wg pubkey > client_public_key.
  7. nano /etc/wireguard/wg0.conf.
  8. sudo wg-quick up wg0.

Top Articles
How to give away shares in your business
3.2 ASC 606 five-step model
Craigslist Monterrey Ca
Plaza Nails Clifton
Truist Park Section 135
Top Financial Advisors in the U.S.
Poplar | Genus, Description, Major Species, & Facts
Unraveling The Mystery: Does Breckie Hill Have A Boyfriend?
Embassy Suites Wisconsin Dells
Lesson 2 Homework 4.1
Whitley County Ky Mugshots Busted
Aspen.sprout Forum
Vcuapi
Lima Funeral Home Bristol Ri Obituaries
Quest Beyondtrustcloud.com
What Happened To Anna Citron Lansky
Hanger Clinic/Billpay
Td Small Business Banking Login
Is The Yankees Game Postponed Tonight
Football - 2024/2025 Women’s Super League: Preview, schedule and how to watch
Ihub Fnma Message Board
Strange World Showtimes Near Savoy 16
Urban Dictionary Fov
What Equals 16
Marquette Gas Prices
Bay Area Craigslist Cars For Sale By Owner
Divina Rapsing
Rgb Bird Flop
Osrs Important Letter
Mosley Lane Candles
Khatrimmaza
Aladtec Login Denver Health
Wbli Playlist
Pickle Juiced 1234
Craigslist Car For Sale By Owner
Gwu Apps
Toth Boer Goats
303-615-0055
Dcilottery Login
Engr 2300 Osu
The best specialist spirits store | Spirituosengalerie Stuttgart
Bustednewspaper.com Rockbridge County Va
Tommy Bahama Restaurant Bar & Store The Woodlands Menu
Zeeks Pizza Calories
25 Hotels TRULY CLOSEST to Woollett Aquatics Center, Irvine, CA
Rocket League Tracker: A useful tool for every player
Ouhsc Qualtrics
1Tamilmv.kids
Msatlantathickdream
Black Adam Showtimes Near Kerasotes Showplace 14
Campaign Blacksmith Bench
Inloggen bij AH Sam - E-Overheid
Latest Posts
Article information

Author: Eusebia Nader

Last Updated:

Views: 5363

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Eusebia Nader

Birthday: 1994-11-11

Address: Apt. 721 977 Ebert Meadows, Jereville, GA 73618-6603

Phone: +2316203969400

Job: International Farming Consultant

Hobby: Reading, Photography, Shooting, Singing, Magic, Kayaking, Mushroom hunting

Introduction: My name is Eusebia Nader, I am a encouraging, brainy, lively, nice, famous, healthy, clever person who loves writing and wants to share my knowledge and understanding with you.