This page provides detailed step-by-step instructions for setting up OpenVPN in bridge mode on a Raspberry Pi or Linux device.
If you prefer manual setup or need to enable SSH on an existing installation:
ssh in the boot partition of the SD card
# On Linux/macOS
touch /path/to/boot/ssh
wpa_supplicant.conf in the boot partition:
```conf
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1network={ ssid=”YourNetworkName” psk=”YourPassword” } ```
nmap -sn 192.168.1.0/24 (adjust for your network)ssh pi@<raspberry-pi-ip>
# Example: ssh pi@192.168.1.100
pisudo apt update && sudo apt upgrade -y
sudo raspi-config
raspi-config: Navigate to Network Options > N8 IP Version > N1 Enable/Disable automatic IP configuration/etc/dhcpcd.conf:
sudo nano /etc/dhcpcd.conf
Add these lines (adjust for your chosen network range):
interface eth0
static ip_address=10.99.99.134/24
static routers=10.99.99.1
static domain_name_servers=8.8.8.8 8.8.4.4
raspi-config: System Options > Boot / Auto Login > Consolepasswd
Use a strong, unique password.
raspi-config: Interface Options > SSH > Enablesudo reboot
After reboot, verify your static IP is working:
ip addr show eth0
ping google.com
Important: Keeping your system updated is crucial for security, especially for a device exposed to the internet.
sudo apt install unattended-upgrades apt-listchanges -y
sudo dpkg-reconfigure -plow unattended-upgrades
Select “Yes” when prompted.
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
// Automatically upgrade packages from these origins:
Unattended-Upgrade::Origins-Pattern {
"origin=Debian,codename=${distro_codename},label=Debian-Security";
"origin=Raspbian,codename=${distro_codename},label=Raspbian";
};
// Remove unused automatically installed kernel-related packages
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
// Remove unused dependencies
Unattended-Upgrade::Remove-Unused-Dependencies "true";
// Automatically reboot if required
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "02:00";
sudo nano /etc/apt/apt.conf.d/20auto-upgrades
Ensure it contains:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
sudo unattended-upgrades --dry-run
sudo systemctl status unattended-upgrades
If you haven’t configured a static IP yet, or need to change your network configuration:
sudo nano /etc/dhcpcd.conf
# Example static IP configuration for unique network range
interface eth0
static ip_address=10.99.99.134/24
static routers=10.99.99.1
static domain_name_servers=8.8.8.8 8.8.4.4
sudo systemctl restart dhcpcd
sudo nmcli con mod "Wired connection 1" ipv4.addresses 10.99.99.134/24
sudo nmcli con mod "Wired connection 1" ipv4.gateway 10.99.99.1
sudo nmcli con mod "Wired connection 1" ipv4.dns "8.8.8.8 8.8.4.4"
sudo nmcli con mod "Wired connection 1" ipv4.method manual
sudo nmcli con up "Wired connection 1"
We’ll use the Angristan OpenVPN installation script, which provides a secure, modern OpenVPN setup.
curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
chmod +x openvpn-install.sh
sudo ./openvpn-install.sh
When prompted, choose the following options:
1194 (default) or choose a different port if neededUDP (recommended for performance)1 for current system resolvers3 for Cloudflare4 for Quad95 for Googlen (no compression) for better securityn for default settings initiallyThe Angristan script automatically implements several security best practices:
sudo systemctl status openvpn-server@server
sudo systemctl is-enabled openvpn-server@server
.ovpn file in the home directory. This file contains all the necessary configuration and certificates for your VPN client.After completing the installation, you’ll need to:
Continue to the Configuration Guide for the next steps.
If you encounter issues during installation:
sudo apt update and try againFor more detailed troubleshooting, see the Troubleshooting Guide.