This is an old revision of the document!
Setup OpenWRT with WireGuard VPN on a Raspberry Pi 4
Install OpenWRT
-
Model: Raspberry Pi 4
Version: B
For the above:
Use balenaEtcher or other favorite tool to write OpenWRT onto SD card.
See webpage info below for optional step of resizing the default partition.
Put SD card in Pi, connect ethernet and power on.
Setup OpenWRT
-
Set a new password by following the prompts.
Change IP block.
Save Apply and reconnect to new IP address with new password.
From the top menu, click on Network and choose Wireless.
Click Remove next to the existing wireless config and then Save & Apply.
Click Scan to search for available networks, find your and click Join Selected.
Enter your WiFi password in the WPA passphrase box and click Submit and then Save.
Click Save & Apply to connect to your WiFi.
You now have a WAN connection on the internal WiFi adapter and a
LAN connection on the
LAN port.
Now add USB WiFi card as radio1 for our WiFi access point for clients to connect to.
The Wifi card I have from a previous nonWifi Pi bundle seems compatable and may not require any extra install steps. See link below for more info if it does.
From the top menu, click on the Network tab and choose Wireless.
If you see radio1, you are all good with the installation of the second WiFi adapter.
Click Edit for the OpenWrt SSID (under the radio1)
Click Enable for Wireless network is disabled
Change Operating Frequency to 7 or anything that is free
Under Interface Configuration, select the Wireless Security tab, choose WPA2-PSK and enter a password that devices will use to connect.
Click Save
Click Save & Apply
Link: https://tristam.ie/2023/582/#openwrt-install
Setup WireGuard VPN
From OpenWRT top menu, click System tab and choose Software.
Click Update lists button and wait for process to finish.
Click Dismiss
Install the following packages by using the Filter field and clicking Install
Click Network→Interfaces→Add new interface.
Click General Settings tab and enter following parameters from your Wireguard setup.
Bring up on boot: checked
Private Key: Generate new key pair
Public Key: this will go into your home wireguard setup on the other end as the peer's public key)
Listen Port: blank
IP Addresses: whatever you assign it in your home wireguard setup as the peer's ip (10.23.0.13/32)
Click Advanced Settings tab
Click on the Firewall tab and select the WAN zone for Create/Assign firewall-zone. (wan wg0: wwan:)
Click the Peers tab and Add peer
Description: brimble.com
Public Key: from the home wireguard instance setup
Private Key: blank
Preshared key: blank
Allowed IPs: 0.0.0.0/0
Route Allowed IPs: checked
Endpoint Host: brimble.com
Endpoint Port: 51820
Persistent Keep Alive: 25
Click Save and then Save & Apply.
Also, set custom
DNS again in Interfaces→WWAN if not already.
Link: https://tristam.ie/2023/805/
Connect
Setup
-
make sure it is enabled and locked
config type Static IPv4
set IPv4 address to your desire (10.23.79.1/24 for me)
upstream gateway is auto-detect
Save/Apply
go to Interfaces / WAN
make sure it is enabled and locked
block private and bogon networks
config type DHCP (for CenturyLink at least)
Save/Apply
Setting up with CenturyLink Quantum Fiber
This service provider requires traffic from the ONT to go to a router set to VLAN 201
go to Interfaces / Other Types / VLAN
create new by clicking on the “+”
go to Interfaces / Assignments
Plug line from internet into WAN port.
Firewall/NAT
Port Forwarding
go to Firewall / NAT / Port Forward
create new rule by clicking on the “+”
Interface: WAN
Protocol: TCP
Source Advanced should all be “any”
Destination: WAN address
Destination port range: select outside port (example: 80 or 443)
Redirect target IP: Single host or Network / internal IP address of the server (10.23.79.4)
Redirect target port: (other) / internal server port (example: 180 or 1443)
Description: whatever
NAT reflection: Enabled
Filter rule association: Add associated filter rule
Save/Apply
repeat for other forwarded ports
Port Forwarding rules if unraid/ Nginx:
80 Both 10.23.79.X 180 HTTP tomcat
443 Both 10.23.79.X 1443 HTTPS tomcat
22 Both 10.23.79.X SSH brimble
Port Forwarding rules if standalone:
80 Both 10.23.79.X HTTP tomcat
443 Both 10.23.79.X HTTPS
22 Both 10.23.79.X SSH brimble
32400 Both 10.23.79.X Plex
Hairpin NAT:
Wireguard VPN
Create Instance and Peers
go to System / Firmware / Plugins and install os-wireguard
go to VPN / WireGuard / Settings / Instances
create new instance by clicking on the “+”
go to VPN / WireGuard / Settings / General and enable WireGuard
go to VPN / WireGuard / Settings / Peers
create new peer by clicking on the “+”
Enabled: check
Name: iPhone / Macbook / whatever
Public key: PEERPUBLIC (put in the key created when you setup the client… see below)
Allowed IPs: something on the subnet configured above (10.23.0.11/32)
Instances: select above instance (WG1)
Save/Apply
go to VPN / WireGuard / Settings / Instances / Edit WG1
go to Lobby / Dashboard and restart wireguard
Create interface
go to Interfaces / Assignments
in the drop down under new interface, select the WireGuard instance (wg1)
Enable: check
Description: WG1
Save/Apply
go to Interfaces / WG1
Enable: check
Description: WG1
Save/Apply
Create VPN Firewall rules
go to Firewall / Rules / WAN
create new rule by clicking on the “+”
Action: Pass
Quick: check
Interface: WAN
Direction: in
TCP/IP Version: IPv4
Protocol: UDP
Source Invert: unchecked
Source: any
Destination Invert: unchecked
Destination: WAN address
Destination port range: from (other) 51820 to (other) 51820
Description: allow wireguard inbound
Save/Apply
go to Firewall / Rules / [Name of interface assigned above (WG1)]
create new rule by clicking on the “+”
Action: Pass
Quick: check
Interface: WG1
Direction: in
TCP/IP Version: IPv4
Protocol: any
Source Invert: unchecked
Source [Name of interface assigned above NET (WG1 net)]
Destination Invert: unchecked
Destination: any
Destination port range: any
Save/Apply
Setup Clients
NAT for online gaming
Services
DHCPv4
Range Start 10.23.79.100
Range Stop 10.23.79.245
Save Apply
Static MAC/IP Mapping
brimNAS 10.23.79.4
BrimUpstairsAP 10.23.79.5
BrimDownstairsAP 10.23.79.6
DNS (System / Settings / General
-