2018-10-16 18:45:16 +00:00
=======================================
WireGuard MullvadVPN Road Warrior Setup
=======================================
------------
Introduction
------------
MullvadVPN is a cloud-based VPN provider, offering secure tunneling in respect to privacy.
To set up a WireGuard VPN to MullvadVPN we assume you are familiar with the concepts of WireGuard you that
2018-11-03 14:31:59 +00:00
you have read the basic howto :doc: `wireguard-client` .
2018-10-16 18:45:16 +00:00
----------------------------------
Step 1 - Setup WireGuard Instance
----------------------------------
2019-04-30 09:28:13 +00:00
Go to tab **Local** and create a new instance. Give it a **Name** and set a desired **Listen Port** .
2018-10-16 18:45:16 +00:00
If you have more than one server instance be aware that you can use the **Listen Port** only once. In
the field **Tunnel Address** insert an unsused private IP address and subnet mask. We don't need it in
the first step, but as it is required we can't go on without it. Every other field can be left blank.
Hit **Save** and open your instance again to write down your public key. You need it to get the rest
of the configuration from the Mullvad API servers.
2021-11-20 02:53:22 +00:00
Now change to your OPNsense CLI via SSH or Console and execute *either* of the curl strings below. Please replace
**YOURACCOUNTNUMBER** with your own ID you got from MullvadVPN and **YOURPUBLICKEY** with the one in your **Local**
The command below is for Mullvad's standard API. DNS requests through a tunnel that uses tunnel IPs generated via this API are "hijacked", so that Mullvad's DNS servers are used to avoid leaks:
.. code-block :: sh
curl -sSL https://api.mullvad.net/wg/ -d account=YOURACCOUNTNUMBER --data-urlencode pubkey=YOURPUBLICKEY
The alternative command below is for Mullvad's other API. DNS requests through the tunnel are not hijacked when using tunnel IPs generated via this API:
2018-10-16 18:45:16 +00:00
.. code-block :: sh
2021-11-20 02:53:22 +00:00
curl -sSL https://api.mullvad.net/app/v1/wireguard-keys -H "Content-Type: application/json" -H "Authorization: Token YOURACCOUNTNUMBER" -d '{"pubkey":"YOURPUBLICKEY"}'
2018-10-16 18:45:16 +00:00
2019-11-15 13:46:35 +00:00
What you receive is what WireGuard calls **Allowed IP** for your local instance. Edit your instance again and remove
the value of **Tunnel Address** you used when setting it up and change it to the one you got.
2018-10-16 18:45:16 +00:00
2019-07-09 20:58:58 +00:00
On **Endpoint** tab create a new Endpoint, give it a **Name** , set 0.0.0.0/0 in **Allowed IPs** and set
2019-08-26 07:41:44 +00:00
the **DNS** to 193.138.218.74. This is the one MulladVPN provides for privacy.
2018-10-16 18:45:16 +00:00
Now go to the WireGuard server list_ and choose the one you like to use as your breakout. Write down it's
2021-09-18 06:33:14 +00:00
public key and set it as **Public Key** .
Also do not forget **Endpoint Address** and **Endpoint Port** . The **Endpoint Port** is 51820. The **Endpoint Address** will depend on which Mullvad server you wish to use. For example, if you want to use the "nl1-wireguard" server, the **Endpoint Address** will be :code: `nl1-wireguard.mullvad.net` .
2018-10-16 18:45:16 +00:00
.. _list: https://www.mullvad.net/en/servers/#wireguard
2019-04-30 09:28:13 +00:00
Go back to tab **Local** , open the instance and choose the newly created endpoint in **Peers** .
2018-10-16 18:45:16 +00:00
Now we can **Enable** the VPN in tab **General** and continue with the setup.
--------------------------------
Step 2 - Assignments and Routing
--------------------------------
To let you internal clients go through the tunnel you have to add a NAT entry. Go to
2019-03-06 17:27:21 +00:00
:menuselection: `Firewall --> NAT --> Outbound` and add a rule. Check that rule generation is set to manual
2018-10-16 18:45:16 +00:00
or hybrid. Add a rule and select Wireguard as **Interface** . **Source** should be your
LAN network and set **Translation / target** to **interface address** .
When assigning interfaces we can also add gateways to them. This would offer you the chance to
balance traffic via different VPN providers or do more complex routing scenarios.
2021-03-03 10:19:40 +00:00
See the how-to on selective routing for further information :doc: `wireguard-selective-routing`
2018-10-16 18:45:16 +00:00