Skip to content

Commit b43c3ca

Browse files
committed
added additional steps from slides
1 parent 10abfaa commit b43c3ca

29 files changed

Lines changed: 312 additions & 0 deletions
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
---
2+
title: Wireguard OpenWRT Travel Router Tutorial
3+
author_profile: false
4+
toc: true
5+
toc_label: "Table of Contents"
6+
toc_icon: "cog"
7+
tags: openwrt wireguard vpn travel-router
8+
categories: self-hosted
9+
header:
10+
teaser: /assets/images/travelRouter.PNG
11+
---
12+
{% include video id="" provider="youtube" %}
13+
14+
# OpenWRT Wireguard Travel Router
15+
16+
# Pre-Requisite
17+
The travel router will be a Wireguard Peer, so you will need an existing Wireguard server setup.
18+
Any of the previous examples will work as the Wireguard server. This tutorial will only cover setting up the Peer, not the server, since those steps were covered in other tutorials on the site.
19+
20+
You will also need:
21+
- Raspberry Pi
22+
- Wireless Adapter Compatible with OpenWRT
23+
- Micro-SD card for OpenWRT
24+
- OpenWRT
25+
- Wi-Fi
26+
- Ethernet cable
27+
28+
# Setup
29+
Download OpenWRT for your Raspberry Pi. Install it onto the sd card and then follow the next steps.
30+
31+
1. Power on your Raspberry Pi and connect a LAN cable to the ethernet port and connect your computer to that LAN cable.
32+
33+
2. The router should give out a DHCP address. If not, you will have to set your IP to 192.168.1.
34+
OpenWRT uses 192.168.1.1 by default
35+
36+
37+
# OpenWRT
38+
Once you are able to access the admin gui interface on the Raspberry Pi navigate to the wireless section.
39+
40+
# Radio0
41+
Network -> Wireless
42+
43+
![Radio0](/assets/images/radio0.png)
44+
45+
1. Radio0 is the on-board wifi of the Rpi. Enable this device and then scan for wifi.
46+
2. Find your home network and connect to it.
47+
48+
![Radio0 Connection](/assets/images/joinNetwork.png)
49+
50+
3. After you’ve found your network select “Replace wireless configuration”
51+
4. Set the name to wwan
52+
5. Enter the WPA passphrase of your network and then click submit.
53+
6. You will be brought to another config page, but just click save and do not make changes
54+
7. This will give the Rpi network access.
55+
56+
57+
# Update and Install Packages
58+
After you’ve connected the RPi to your local wifi you can update and install packages.
59+
60+
You will need to SSH into the Raspberry Pi and then run these commands.
61+
62+
To ssh run the following `ssh root@<rpi-IP>`. Repace `<rpi-IP>` with your actual IP. Usually it's `192.168.1.1`
63+
64+
Run
65+
```bash
66+
opkg update
67+
```
68+
to download the package repository list.
69+
70+
Then install wireguard.
71+
```bash
72+
opkg install wireguard-tools luci-app-wireguard
73+
```
74+
75+
Both these commands can be run in the GUI.
76+
77+
## Install USB Drivers
78+
After you’ve installed Wireguard you will also need to install USB Drivers.
79+
80+
Run:
81+
```bash
82+
opkg install kmod-rt2800-lib kmod-rt2800-usb kmod-rt2x00-lib kmod-rt2x00-usb kmod-usb-core kmod-usb-uhci kmod-usb-ohci kmod-usb2 usbutils
83+
```
84+
85+
# Radio1
86+
87+
![lsusb before](/assets/images/lsusb%20before.png)
88+
Run `lsusb` in the console to see what devices are connected to the RPi. After you have the list connect your wifi card to the USB port on your RPi.
89+
90+
![lsusb after](/assets/images/lsusbafter.png)
91+
Run `lsusb` again to see if a new device has been discovered. In this case the `Ralink 802.11 n WLAN` device has been found. Now you can switch back to the GUI
92+
93+
## Radio1 Config
94+
Under Network→Wireless you should now see a second radio device (radio1). Click Edit to bring up the config menu.
95+
![radio1](/assets/images/radio1.png)
96+
97+
![radio1Config](/assets/images/raido1.PNG)
98+
1. Mode: Access Point
99+
2. ESSID: Anything you want (default OpenWRT)
100+
3. Network: wwan
101+
102+
Select Wireless Security.
103+
![radio1 Security](/assets/images/radio1ConfigSecurity.png)
104+
105+
1. Encryption: WPA2-PSK/WPA3-SAE Mixed Mode
106+
2. Key: This should be no less than 16 characters
107+
3. Click Save
108+
4. Then on the main Wireless Screen click save and apply
109+
5. Also be sure to enable the device
110+
111+
# Wireguard Setup
112+
Network → Interfaces
113+
1. Select Add new interface
114+
115+
![Create new Interface](/assets/images/createNewInt.png)
116+
117+
1. Name: wg0
118+
2. Protocol: WireGuard VPN
119+
120+
**NOTE**: If `WireGuard VPN` does not show in the protocol list you may have to reboot your raspberry pi.
121+
![wg0 interface](/assets/images/wg0Interface.png)
122+
123+
## General Settings
124+
**NOTE You will need to create a peer on your Wireguard server prior to completing this step. The tutorial assumes you have already done so.**
125+
126+
1. Generate new Key Pair
127+
2. Ip Addresses: This will be the IP of the Peer you configure on your WG server.
128+
129+
The Public Key here will also go on your WG server as the Peer Public Key.
130+
![wg0 Config](/assets/images/wg0Config.png)
131+
132+
## wg0 Peer
133+
![wg0 Peer Config](/assets/images/peerConfig.png)
134+
135+
1. Description: Anything you want
136+
2. Public Key: Server’s public key
137+
3. Private key: leave blank
138+
4. Preshared Key: PSK generated from server (do not generate here)
139+
5. Allowed IP’s: `0.0.0.0/0,::/0` (allow all IPv4 & IPv6 Traffic)
140+
6. Route Allowed IPs: `Check`
141+
7. Endpoint Host: Public IP of your server
142+
8. Enpoint Port: Port that wireguard is running on your server.
143+
144+
Once this has been completed. Click save and then click save and apply on the main Interface Page. You may have to restart the `wg0` interface to establish a connection.
145+
# Firewall
146+
Next we have to move back to the terminal to setup the firewall rules.
147+
148+
I reccommend copying the commands 1 by 1 to ensure everything is correct.
149+
```bash
150+
uci rename firewall.@zone[0]="lan"
151+
uci rename firewall.@zone[1]="wan"
152+
uci del_list firewall.wan.network="wg0"
153+
uci add_list firewall.wan.network="wg0"
154+
uci commit firewall
155+
/etc/init.d/firewall restart
156+
```
157+
158+
1. Set zone 0 to lan
159+
2. Set zone 1 to wan
160+
3. Remove wg0 from wan network
161+
4. Add wg0 to wan network
162+
5. commit changes
163+
6. restart the firewall
164+
165+
# Verify
166+
After committing firewall changes you may have to reboot the RPi to get successful connection.
167+
168+
Once the device comes back online you should see traffic on the Network→Interfaces page under the wg0 interface. Rx & Tx should have numbers.
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
---
2+
title: PfSense Wireguard Server Tutorial
3+
author_profile: false
4+
toc: true
5+
toc_label: "Table of Contents"
6+
toc_icon: "cog"
7+
tags: pfsense wireguard vpn travel-router
8+
categories: self-hosted
9+
header:
10+
teaser: /assets/images/pfsense.PNG
11+
---
12+
{% include video id="" provider="youtube" %}
13+
14+
# Install Wireguard Package
15+
Go to System → Package Manager → Available Packages.
16+
17+
Search for “Wireguard”
18+
19+
![Wireguard Package](/assets/images/wgpkg.PNG)
20+
At the time of making this, version 0.1.6_2 is the most up to date.
21+
# Tunnel Config
22+
23+
From the menu at the top, select VPN → Wireguard.
24+
25+
Select [+ Add Tunnel]
26+
27+
![Tunnel](/assets/images/tunnel.PNG)
28+
29+
![Tunnel Config](/assets/images/tunnelConfig.PNG)
30+
31+
1. Enable tunnel
32+
2. Set a description for the tunnel
33+
3. Set the port to anything. (Default is 51820)
34+
4. Click “Generate” to create your public and private keys.
35+
5. Create interface addresses.
36+
37+
Interface addresses can be any internal IP address range. Here I chose the `10.0.0.1/24` subnet.
38+
39+
Meaning I can use `10.0.0.2-10.0.0.255`
40+
See [RCF1918](https://www.rfc-editor.org/rfc/rfc1918).
41+
42+
Once finished, click save. Then go to Peers.
43+
44+
# Peer Config
45+
46+
![Wireguard Peer](/assets/images/wgpeer.PNG)
47+
1. Enable peer.
48+
2. Select the tunnel you created (in this case tun_wg0).
49+
3. Set a Description.
50+
4. Keep the endpoint dynamic.
51+
5. Keep Alive: leave blank.
52+
6. Public Key* this will be generate from your app.
53+
7. Pre-Shared Key (optional but can provide quantum protection) Click [Generate] to create one.
54+
8. Allowed IP’s: Set this to an address that has not been used in your subnet yet.
55+
Ex: 10.0.0.2/32 (means only 10.0.0.2)
56+
57+
58+
# App Config: Android
59+
![Pfsense Peer](/assets/images/pfSensePeer.png)
60+
61+
1. Interface Name: Pfsense or any name you prefer
62+
2 Click the refresh icon in the Private Key section to generate a public and private key.
63+
3. The addresses should be the address you gave to the peer. In this case it is 10.0.0.2/32.
64+
4. DNS Servers: You can set the DNS server to the upstream DNS on your network (usually 192.168.0.1 or 10.0.0.1) if you created a DNS for the tun0 interface, or leave this blank.
65+
5. MTU leave empty.
66+
6. Copy the Public Key and paste it into the Public Key section for the Peer on the server. See Slide 7, #6.
67+
68+
Then select “Add Peer” at the bottom
69+
![PfSense Config](/assets/images/pfSenseConfig.png)
70+
1. Public Key: Copy the public from the server. (Slide 6 #4)
71+
2. Pre-shared key: Copy the pre-shared key from the server. (Slide 7 #7)
72+
3. Persistent keepalive: Leave Blank
73+
4. Enpoint: This should be the public IP of your server. In my case my PFsense box is a VM on my local net so the IP is 192.168.0.44. Also :51820 is the port specification we configured.
74+
5. Allowed IPs: 0.0.0.0/0 means any IP address on IPv4 and ::/0 means any IP address on IPv6. Setting it up this way means we created a Full-Tunnel. All traffic on the device will be routed through the wireguard VPN.
75+
76+
# Firewall Config
77+
Select Firewall → Rules from the main menu.
78+
79+
![Firewall Wan Default](/assets/images/FirewallRulesWANDefault.PNG)
80+
By default your WAN should only have 1 rule.
81+
82+
Block bogon networks.
83+
84+
Mine has an additional rule since I do not have a LAN address on this VM. Ignore this rule.
85+
86+
Select “Add \/”
87+
88+
![Firewall Rule Settings](/assets/images/FirewallRuleSetting.PNG)
89+
1. Action: Pass
90+
2. Interface: WAN
91+
3. Address Family: IPv4
92+
4. Protocol: UDP
93+
5. Source: any
94+
6. Destination: WAN address
95+
7. Destination Port Range: Custom: 51820 to Custom: 51820
96+
8: Log Packets: Optional (can create a lot of spam)
97+
9. Description: Wireguard – Allow WAN 51820
98+
99+
Then click Save. You may have to click appy changes after you save.
100+
101+
## Wireguard Firewall
102+
By default there are no rules to allow Wireguard traffic anywhere. We need to create 1 rule to allow all traffic. But be warned, this tutorial does not cover how to properly segment your network and add additional security to your wireguard interface. VLANs, proper firewall rules, and network segmentation is important.
103+
104+
![WG Rules](/assets/images/wgRules.PNG)
105+
106+
Select Add to create a new rule
107+
108+
109+
![Allow All](/assets/images/AllowAll.PNG)
110+
1. Action: Pass
111+
2. Interface: Wireguard
112+
3. Address Family: IPv4
113+
4. Protocol: Any
114+
5. Source: Any
115+
6. Destination: Any
116+
7. Log: Optional
117+
8. Description: Allow all
118+
9. Save
119+
120+
121+
Apply Changes after saving
122+
123+
## NAT Rules
124+
Select Firewall → NAT and then Outbound to arrive at this page.
125+
![NAT Default](/assets/images/HybridNAT.PNG)
126+
127+
In order to route Wireguard traffic back out the WAN we need to configure a few things in the NAT settings.
128+
129+
Set Outbound NAT Mode to Hybrid.
130+
131+
![NAT Default](/assets/images/FirewallNATOutbound.PNG)
132+
Select “Add /\” under Mappings to create a new NAT Outbound Mapping.
133+
134+
![NAT Settings](/assets/images/NAT-settings.PNG)
135+
1. Interface: WAN
136+
2. Address Family: IPv4
137+
3. Protocol: any
138+
4. Source: Network – 10.0.0.1/24
139+
140+
Then click save. You may need to apply the changes after clicking save.
141+
142+
# Verify
143+
![Verify](/assets/images/VerifyStatus.PNG)
144+
After saving and reloading the firewall go back to VPN → Wireguard → Status. Click the down arrow on the tun_wg0 tunnel. You should see that the peer you created has successfully been created.

‎assets/images/AllowAll.PNG‎

83.9 KB
Loading
71.2 KB
Loading
100 KB
Loading
42.6 KB
Loading

‎assets/images/HybridNAT.PNG‎

22.4 KB
Loading

‎assets/images/NAT-settings.PNG‎

48.7 KB
Loading

‎assets/images/VerifyStatus.PNG‎

33.8 KB
Loading

‎assets/images/createNewInt.png‎

65 KB
Loading

0 commit comments

Comments
 (0)