While Browsec VPN is primarily known as a browser extension, integrating its capabilities at the OPNsense firewall level allows for network-wide protection, bypassing browser-specific limitations. This involves using OPNsense's OpenVPN client functionality to connect to a suitable VPN server that mimics the protection offered by Browsec.
First, identify a VPN provider that offers OpenVPN configuration files and server locations similar to those offered by Browsec's browser extension. Download the OpenVPN configuration file (.ovpn) for your desired server location.
Next, configure an OpenVPN client instance in OPNsense under VPN > OpenVPN > Clients. Import the downloaded .ovpn file. You may need to manually adjust settings such as:
Server host or address: Extracted from the .ovpn file.
Server port: Typically 1194, but verify in the .ovpn file.
Username and password: Provided by your chosen VPN service.
TLS Authentication: If present in the .ovpn, copy the tls-auth key into the "TLS Key" field. Set "TLS Key Usage Mode" accordingly.
Encryption Algorithm: Match the cipher specified in the .ovpn file (e.g., AES-256-CBC).
Auth Digest Algorithm: Match the digest algorithm specified in the .ovpn file (e.g., SHA512).
Tunnel Settings: Ensure "IPv4 Tunnel Network" is empty unless specifically required by the VPN provider.
Enable the client and ensure it connects successfully. The OPNsense dashboard should show the OpenVPN client as "up."
To route traffic through the Browsec VPN (via the configured OpenVPN client), create a gateway under System > Gateways > Single. Select the OpenVPN client interface as the "Interface."
Next, configure firewall rules to direct traffic through this gateway. Under Firewall > Rules, create a new rule (or modify an existing one) on the desired interface (e.g., LAN).
Action: Pass
Interface: LAN (or your internal network interface)
Address Family: IPv4
Protocol: Any
Source: Your internal network (e.g., LAN net)
Destination: Any
Gateway: Select the newly created OpenVPN gateway.
This rule will route all traffic originating from your internal network through the VPN.
For DNS, prevent DNS leaks by forcing all DNS queries through the VPN tunnel. Under System > Settings > General, set "DNS servers" to the DNS servers provided by your VPN provider (if available). Alternatively, use public DNS servers like 1.1.1.1 or 8.8.8.8, but ensure these are also routed through the VPN by adding a firewall rule. This rule should block outbound port 53 traffic on the WAN interface and redirect it to the VPN gateway.
Implement firewall rules to prevent traffic from leaking outside the VPN tunnel. Create a block rule on the WAN interface that blocks all outbound traffic originating from your internal network. This ensures that if the VPN connection drops, no traffic will be sent over the WAN interface.
Performance can be affected by the VPN connection's speed and the encryption algorithms used. Experiment with different encryption ciphers in the OpenVPN client configuration. AES-128-CBC is generally faster than AES-256-CBC, but offers slightly less security. The CPU load on the OPNsense firewall can also become a bottleneck, especially with weaker hardware. Monitor CPU usage during heavy traffic periods. Consider enabling hardware crypto acceleration if your OPNsense hardware supports it.
Verify that your traffic is being routed through the VPN by checking your public IP address. Use a website like whatismyip.com before and after enabling the VPN rules. The IP address should change to the VPN server's IP address.
If the VPN connection fails, check the OpenVPN client logs under Status > System Logs > OpenVPN. Common issues include incorrect credentials, firewall rules blocking the connection, or problems with the OpenVPN configuration file. Ensure that the time and date are correctly set on the OPNsense firewall, as TLS authentication can fail if the time is significantly out of sync.
Using a third-party VPN service introduces a trust element. Select a reputable provider with a clear privacy policy. Performance will depend on the VPN server's location and load. Expect some speed degradation compared to a direct internet connection.
The Browsec browser extension offers per-browser control. This level of granularity is lost when implementing the VPN at the firewall level; all traffic routed through the VPN will be affected. Consider creating separate VLANs for devices that require VPN protection and those that don't. This allows for more granular control over which traffic is routed through the Browsec VPN.