How to Put unRAID containers on their own VLAN inside a VPN Tunnel using PFSense¶
Credits:
Written by Schwiing#3404
Based on the work of IamSpartacus#3678
Disclaimer: This guide makes the following assumptions:
-
You're using PFsense as your Firewall
-
You're using unRAID
-
You have a VPN Provider (In this example I used mullvad)
-
You have a managed switch and know how to tag VLAN traffic on that switch (In this example I used unifi)
Create OpenVPN Clients in PFSense¶
-
Head to VPN -> OpenVPN -> Clients -> + Add
-
Fill out the client information based on your provider. I use mullvad, so I followed this guide: mullvad.net
-
The only differences I made were:
a. Set Server Host to: (a server closer to you from this list)
b. Make sure these are checked:
-
Bars the server from adding routed to the client's routing table
-
Don't add or remove routes automatically
-
-
Mullvad supports up to 5 connections at once. So if you want to go down that route, add 5 clients
a. Make sure to add a different server host for each client
Add interface assignments for each OpenVPN Client¶
-
This is just a matter of creating an interface for each new ovpnc* you made earlier
-
Interfaces -> Assignments -> + Add. I named them based on the server each interface would connect to
-
For example, my first interface name is MULLVAD_CHICAGO_002 (same as the server it connects to)
-
Create the rest of your interfaces (remember, up to 5)
Create a VLAN¶
-
Interfaces -> VLANs -> + add
-
Select your LAN as your parent interface (Physical NIC)
-
Pick a VLAN Tag. Make sure you remember this for later. I picked "90", so my network is 192.168.90.0/24
-
Add a description. I used "DOCKER_VPN"
Create NAT Mappings¶
-
Firewall -> NAT -> Outbound
-
Make sure Outbound NAT Mode = Manual
-
Add a rule to the top of the list with the following settings:
- Interface: MULLVAD_CHICAGO_002
- Protocol: Any
- Source: Network, 192.168.90.0/24 (Fill in whatever your VLAN Tag + Network is here)
Create Gateway Group¶
-
System -> Routing -> Gateway Groups -> + Add
-
Set all of your new gateways to Tier 1
-
Trigger Level: Packet Loss or High Latency
-
Keep WAN_DHCP at "Never" Tier
-
Name it. I called it "Mullvad Gateway Group"
Create VLAN Rule¶
-
Select your new VLAN (Mine is DOCKER_VPN)
-
Top Rule:
- Action: Pass
- Interface: DOCKER_VPN
- Address Family: IPv4
- Source: DOCKER_VPN net
- Destination: LAN net
-
Bottom Rule:
- Hit "Display Advanced" under Extra Options
- Action: Pass
- Interface: DOCKER_VPN
- Address Family: IPv4
- Source: DOCKER_VPN net
- Destination: any
- Gateway: Mullvad_VPN_Group
Add DNS Servers to VLAN¶
-
Services -> DHCP Server -> DOCKER_VPN
-
DNS Servers (these are for mullvad. YMMV):
- 193.138.218.74
- 10.8.0.1
Misc PFsense Steps¶
-
System -> Advanced -> Miscellaneous
-
Gateway Monitoring: Do not create rules when gateway is down -> CHECKED
unRAID steps¶
-
Go to Network settings
- Enable VLANs: Yes
- VLAN Number: 90 (whatever you set your VLAN Tag earlier in Pfsense)
- Network Protocol: Ipv4 Only
- IPv4 Address: 192.168.90.31 (whatever you want here, under the same subnet)
- IPv4 default gateway: 192.168.90.1
-
Next, Docker settings. Enable Docker: No, Advanced view: on
- Host Access to custom networks: Enabled
- Ipv4 custom network on interface br0.90:
- Subnet: 192.168.90.0/24
- Gateway: 192.168.90.1
- DHCP Pool: 192.168.90.240/28 (16 hosts) [Set whatever you want here. 16 was plenty for me]
-
Once done, you now have a new VLAN in Unraid.
-
Assign docker container new network. Set a static IP if it's easier for your Reverse Proxied containers