This guide provides step-by-step instructions to set up an OpenVPN server in bridge mode on a Raspberry Pi or Linux device. Bridged networking allows VPN clients to appear as if they are on the same local network as the server, enabling seamless communication.
-
Static IP Address: Ensure your Raspberry Pi has a static IP address. This can be configured:
- Directly on the Raspberry Pi using
raspi-config
- By reserving an IP address for the Raspberry Pi in your router's DHCP settings
- Directly on the Raspberry Pi using
-
Network Planning: Plan your IP addressing to avoid conflicts:
- Choose a unique private IP range for your home network
- Ensure the range doesn't conflict with common remote networks
- See the Network Planning section below for detailed guidance
-
Bridge Utilities: Install
bridge-utils
for managing network bridges -
OpenVPN: Install and configure OpenVPN using the provided script
Critical: Plan Your IP Addressing Before Setup
One of the most common issues with VPN setups is subnet conflicts. When your home network and the remote network you're connecting from use the same IP range, the VPN will not work properly.
Most home routers use these default IP ranges:
192.168.1.0/24
(192.168.1.1 - 192.168.1.254)192.168.0.0/24
(192.168.0.1 - 192.168.0.254)10.0.0.0/24
(10.0.0.1 - 10.0.0.254)
To avoid conflicts, choose a unique private IP range for your home network that is unlikely to be used elsewhere:
Recommended ranges:
10.99.99.0/24
(10.99.99.1 - 10.99.99.254) - Excellent choice, rarely used172.16.100.0/24
(172.16.100.1 - 172.16.100.254) - Good alternative10.11.12.0/24
(10.11.12.1 - 10.11.12.254) - Another good option
If you choose 10.99.99.0/24
for your home network:
- Router IP:
10.99.99.1
- Raspberry Pi IP:
10.99.99.134
- DHCP Range:
10.99.99.100
-10.99.99.199
- VPN Client Range:
10.99.99.200
-10.99.99.210
- Router IP:
10.11.12.1
(gateway) - OpenVPN Server IP:
10.11.12.2
- DHCP Range:
10.11.12.100
-10.11.12.199
- VPN Client Range:
10.11.12.200
-10.11.12.210
- DNS: Consider setting up
myvpn-63864.duckdns.org
pointing to your public IP
When setting up your VPN, consider these common scenarios:
- Client's network:
192.168.0.1/24
(typical hotel, office, or public WiFi) - Your home network:
10.11.12.0/24
(to avoid conflicts) - Custom DNS: Set up a DNS record like
myvpn-63864.duckdns.org
for easy connection
When you connect to your home VPN from a remote location (hotel, office, etc.), if both networks use the same IP range like 192.168.1.0/24
, your device won't know whether to route traffic locally or through the VPN. Using a unique range like 10.99.99.0/24
eliminates this confusion.
Bridge mode is particularly useful for applications like ham radio (e.g., ExpertSDR3), where devices need to communicate as if they are on the same local network. Unlike routed mode, bridge mode allows broadcast and multicast traffic, which is essential for some applications.
-
Download Raspberry Pi Imager:
- Visit rpi.org and download the imager for your operating system
-
Prepare SD Card:
- Insert a microSD card (16GB or larger recommended) into your computer
- Launch Raspberry Pi Imager
-
Configure the Image:
- Click "Choose OS" and select "Raspberry Pi OS (32-bit)" or "Raspberry Pi OS Lite" for headless setup
- Click the gear icon for advanced options:
- Enable SSH: Check this box
- Set username and password: Use a strong password
- Configure WiFi: Enter your network credentials if using WiFi
- Set locale settings: Configure your timezone and keyboard layout
-
Write to SD Card:
- Select your SD card
- Click "Write" and wait for the process to complete
If you prefer manual setup or need to enable SSH on an existing installation:
-
Enable SSH:
- Create an empty file named
ssh
in the boot partition of the SD card
# On Linux/macOS touch /path/to/boot/ssh
- Create an empty file named
-
Configure WiFi (if needed):
- Create
wpa_supplicant.conf
in the boot partition:
country=US ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="YourNetworkName" psk="YourPassword" }
- Create
-
Insert SD card into Raspberry Pi and power on
-
Find Your Raspberry Pi's IP Address:
- Check your router's admin panel for connected devices
- Use network scanning:
nmap -sn 192.168.1.0/24
(adjust for your network) - Or connect a monitor and keyboard to see the IP address
-
Connect via SSH:
ssh pi@<raspberry-pi-ip> # Example: ssh pi@192.168.1.100
- Default username:
pi
- Use the password you set during imaging
- Default username:
-
Update System Packages:
sudo apt update && sudo apt upgrade -y
-
Run Configuration Tool:
sudo raspi-config
-
Configure Static IP Address:
- In
raspi-config
: Navigate toNetwork Options
>N8 IP Version
>N1 Enable/Disable automatic IP configuration
- Or manually edit
/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
- In
-
Optional: Disable GUI Mode:
- In
raspi-config
:System Options
>Boot / Auto Login
>Console
- This saves resources if using the Pi only as a server
- In
-
Change Default Password:
passwd
Use a strong, unique password.
-
Enable SSH (if not already enabled):
- In
raspi-config
:Interface Options
>SSH
>Enable
- In
-
Reboot to Apply Changes:
sudo 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.
-
Install the package:
sudo apt install unattended-upgrades apt-listchanges -y
-
Configure automatic updates:
sudo dpkg-reconfigure -plow unattended-upgrades
Select "Yes" when prompted.
-
Edit the configuration file:
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
-
Recommended configuration (uncomment and modify these lines):
// 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";
-
Enable automatic updates:
sudo nano /etc/apt/apt.conf.d/20auto-upgrades
Ensure it contains:
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1";
-
Test the configuration:
sudo unattended-upgrades --dry-run
-
Check status:
sudo systemctl status unattended-upgrades
Bridge utilities are essential for creating network bridges that allow the VPN to operate in bridge mode.
sudo apt update
sudo apt install bridge-utils -y
Verify installation:
brctl --version
You should see output similar to: bridge-utils, 1.6
We'll use the Angristan OpenVPN installation script, which provides a secure, modern OpenVPN setup.
-
Download the installation script:
curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
-
Make the script executable:
chmod +x openvpn-install.sh
-
Run the installation script:
sudo ./openvpn-install.sh
When prompted, use these recommended settings:
- IP address: Accept the detected IP (your Raspberry Pi's IP)
- Public IPv4/IPv6 address: Your public IP or Dynamic DNS hostname
- Port:
1194
(default) or choose a custom port like11194
for security - Protocol:
UDP
(recommended for performance) - DNS: Choose
8
for Google DNS (8.8.8.8, 8.8.4.4) - Compression:
n
(disable for better security) - Customize encryption settings:
n
(defaults are secure) - Client name: Enter a descriptive name (e.g., "home-client")
Using Custom Ports: Many users prefer using non-standard ports like 11194
instead of the default 1194
for additional security through obscurity. If you choose a custom port:
- Update your router's port forwarding to forward external port
11194
to internal port11194
- Ensure your firewall forwards UDP traffic from port
11194
to the OpenVPN server on port11194
- Update client configurations to connect to the custom port
- Elliptic Curve: The script will automatically use secure curves (P-521 or similar)
- Cipher: AES-256-GCM is used by default
- Authentication: SHA-512 is used by default
- TLS version: Minimum TLS 1.2
After installation completes:
- The server configuration will be at
/etc/openvpn/server.conf
- Client configuration will be generated (e.g.,
home-client.ovpn
) - OpenVPN service will start automatically
Verify OpenVPN is running:
sudo systemctl status openvpn-server@server
-
Stop OpenVPN service:
sudo systemctl stop openvpn-server@server
-
Edit the server configuration:
sudo nano /etc/openvpn/server.conf
-
Make the following changes:
a) Change from TUN to TAP device:
Find this line:
dev tun
Replace with:
dev tap0
b) Configure bridge mode:
Find and comment out the
server
line:#server 10.8.0.0 255.255.255.0
Add the
server-bridge
configuration:server-bridge <RPI_IP> <NETMASK> <START_IP> <END_IP>
For 10.99.99.0/24 network (recommended):
server-bridge 10.99.99.134 255.255.255.0 10.99.99.200 10.99.99.210
For traditional 192.168.1.0/24 network:
server-bridge 192.168.1.134 255.255.255.0 192.168.1.200 192.168.1.210
For 10.11.12.0/24 network:
server-bridge 10.11.12.2 255.255.255.0 10.11.12.200 10.11.12.210
Modern OpenVPN versions use data-ciphers
instead of the older ncp-ciphers
. Your configuration may need:
# Modern approach (OpenVPN 2.5+)
data-ciphers AES-256-CBC:AES-256-GCM
cipher AES-256-CBC
# Or for maximum compatibility
data-ciphers AES-256-CBC
cipher AES-256-CBC
Note: If you encounter cipher negotiation issues, using AES-256-CBC
with data-ciphers
instead of AES-256-GCM
may provide better compatibility with various clients.
<RPI_IP>
: Your Raspberry Pi's static IP address<NETMASK>
: Network mask (usually 255.255.255.0 for /24 networks)<START_IP>
to<END_IP>
: IP range reserved for VPN clients
-
Ensure no DHCP conflicts:
- The VPN client IP range must not overlap with your router's DHCP range
- Check your router settings to see what range it uses
- Reserve the VPN range or adjust your router's DHCP scope accordingly
-
Additional recommended settings:
Add these lines if not present:
# Improve compatibility with bridged networking client-to-client duplicate-cn comp-lzo no
-
Save and exit the file (Ctrl+X, then Y, then Enter in nano)
The bridge script creates a network bridge that connects your physical network interface with the VPN's TAP interface.
-
Copy the bridge script to OpenVPN directory:
sudo cp bridge_start.sh /etc/openvpn/
-
Make it executable:
sudo chmod +x /etc/openvpn/bridge_start.sh
-
Find your current network configuration:
ifconfig eth0 ip route show default
-
Edit the bridge script:
sudo nano /etc/openvpn/bridge_start.sh
For 10.99.99.0/24 network (recommended):
eth="eth0"
eth_ip="10.99.99.134"
eth_netmask="255.255.255.0"
eth_broadcast="10.99.99.255"
eth_gateway="10.99.99.1"
eth_mac="e4:5f:01:75:0b:9e" # Use your actual MAC address
For traditional 192.168.1.0/24 network:
eth="eth0"
eth_ip="192.168.1.134"
eth_netmask="255.255.255.0"
eth_broadcast="192.168.1.255"
eth_gateway="192.168.1.1"
eth_mac="e4:5f:01:75:0b:9e" # Use your actual MAC address
To get the correct values for your setup:
Get MAC address:
cat /sys/class/net/eth0/address
Get current IP configuration:
ip addr show eth0
ip route show default
Calculate broadcast address (for /24 networks):
- For 10.99.99.0/24 → broadcast is 10.99.99.255
- For 192.168.1.0/24 → broadcast is 192.168.1.255
- Check your script configuration:
cat /etc/openvpn/bridge_start.sh | grep "eth_"
The script will:
- Create a bridge interface (br0)
- Add your physical ethernet interface to the bridge
- Add the TAP interface to the bridge
- Configure iptables rules for proper packet forwarding
-
Edit the rc.local file:
sudo nano /etc/rc.local
-
Add the bridge script before
exit 0
:# Start bridge for OpenVPN /etc/openvpn/bridge_start.sh exit 0
For better control and logging, create a systemd service:
-
Create a systemd service file:
sudo nano /etc/systemd/system/openvpn-bridge.service
-
Add this configuration:
[Unit] Description=OpenVPN Bridge Setup Before=openvpn-server@server.service Wants=network-online.target After=network-online.target [Service] Type=oneshot ExecStart=/etc/openvpn/bridge_start.sh RemainAfterExit=yes StandardOutput=journal StandardError=journal [Install] WantedBy=multi-user.target
-
Enable and start the service:
sudo systemctl daemon-reload sudo systemctl enable openvpn-bridge.service
-
Test the bridge script manually:
sudo /etc/openvpn/bridge_start.sh
-
Verify bridge creation:
brctl show ip addr show br0
You should see output showing the bridge interface (br0) with your ethernet interface attached.
- Check for errors:
sudo systemctl status openvpn-bridge.service journalctl -u openvpn-bridge.service
-
Locate the client configuration file: The OpenVPN installation script creates a
.ovpn
file in your home directory, typically named something likeclient.ovpn
or with the name you specified during installation. -
Edit the client configuration:
nano client.ovpn
-
Change from TUN to TAP:
Find this line:
dev tun
Replace with:
dev tap0
Note: Use
tap0
(not justtap
) to match the server configuration for bridge mode. -
Update cipher configuration (if needed):
If you encounter connection issues, you may need to update the cipher configuration:
# Replace 'cipher' line with 'data-ciphers' if present data-ciphers AES-256-CBC
-
Verify the remote server address:
Ensure the
remote
line contains your correct public IP or Dynamic DNS hostname:remote your-public-ip-or-ddns 1194
For custom ports, update accordingly:
remote myvpn-63864.duckdns.org 11194
-
Optional: Add Windows-specific settings (if using Windows clients):
# Windows-specific TAP adapter settings route-method exe route-delay 2
-
Optional: Add DNS push settings (if not already present):
# Ensure clients use proper DNS dhcp-option DNS 8.8.8.8 dhcp-option DNS 8.8.4.4
-
Transfer the client file to your client device:
- Use
scp
to copy from your Pi:scp pi@<pi-ip>:client.ovpn .
- Or copy the content and paste into a new file
- Use
-
Import into OpenVPN client:
- Windows: Use OpenVPN GUI or OpenVPN Connect
- macOS: Use Tunnelblick or OpenVPN Connect
- Linux: Use NetworkManager or command line
- Mobile: Use OpenVPN Connect app
-
Start OpenVPN server (if not already running):
sudo systemctl start openvpn-server@server sudo systemctl enable openvpn-server@server
-
Verify server status:
sudo systemctl status openvpn-server@server sudo journalctl -u openvpn-server@server -f
-
Find your router's IP address:
ip route show default
The gateway IP is your router's address (e.g., 10.99.99.1 or 192.168.1.1)
-
Access router admin panel:
- Open a web browser and navigate to your router's IP
- Log in with admin credentials (often found on router label)
-
Locate port forwarding settings:
- Look for "Port Forwarding", "Virtual Servers", or "NAT" in router settings
- Different router brands use different terminology
-
Create a new forwarding rule:
- Service Name: OpenVPN or VPN Server
- Protocol: UDP (recommended) or TCP (if you changed it during installation)
- External Port: 1194 (default) or custom port like 11194
- Internal IP: Your Raspberry Pi's IP (e.g., 10.99.99.134, 10.11.12.2)
- Internal Port: 1194 (default) or custom port like 11194
Standard Configuration:
- External Port: 1194 UDP → Internal IP: 10.99.99.134 Port: 1194
Custom Port Configuration:
- External Port: 11194 UDP → Internal IP: 10.11.12.2 Port: 11194
Firewall Note: Ensure your router's firewall forwards UDP traffic from the external port to the OpenVPN server on the same port number.
-
Use a non-standard port (recommended):
- Change from default 1194 to a custom port (e.g., 11194, 21194, 443, 8080)
- Update both router forwarding rule and OpenVPN configuration
- Edit
/etc/openvpn/server.conf
:port 11194
- Update client configuration accordingly:
remote myvpn-63864.duckdns.org 11194
-
Restrict access by IP (if supported):
- Some routers allow restricting port forwarding to specific source IPs
- Useful if you only connect from known locations
For popular router brands:
- Linksys: Advanced → Port Forwarding
- Netgear: Dynamic DNS → Port Forwarding
- ASUS: Adaptive QoS → Port Forwarding
- TP-Link: Advanced → NAT Forwarding → Port Forwarding
- D-Link: Advanced → Port Forwarding
-
Test from external network:
- Use online port checker tools (search "port checker online")
- Or test from mobile data:
telnet your-public-ip 1194
-
Find your public IP:
curl ifconfig.me # or curl ipinfo.io/ip
If your ISP changes your IP address frequently:
- Set up Dynamic DNS:
- Services: No-IP, DuckDNS, Cloudflare, etc.
- Configure on your router or Raspberry Pi
- Use the hostname in client configuration instead of IP address
Problem: VPN connects but no internet access or can't reach local devices.
Cause: Local and remote networks use the same IP range.
Solutions:
-
Change your home network to a unique range (recommended):
- Reconfigure your router to use
10.99.99.0/24
- Update all static device configurations
- Update Raspberry Pi and OpenVPN configurations accordingly
- Reconfigure your router to use
-
Alternative network ranges:
172.16.100.0/24
- Another good choice10.11.12.0/24
- Less commonly used range- Avoid common ranges like
192.168.1.0/24
,192.168.0.0/24
,10.0.0.0/24
-
Quick test for conflicts:
# On VPN client, check for conflicting routes ip route show # Look for duplicate network ranges
Check service status:
sudo systemctl status openvpn-server@server
sudo journalctl -u openvpn-server@server -f
Common issues:
-
Port already in use:
sudo netstat -tulpn | grep :1194 sudo ss -tulpn | grep :1194
-
Certificate problems:
sudo openvpn --config /etc/openvpn/server.conf --verb 4
-
Restart services:
sudo systemctl restart openvpn-server@server sudo systemctl restart openvpn-bridge.service
Check bridge status:
brctl show
ip addr show br0
Common problems:
-
Bridge not created:
# Manually run bridge script to see errors sudo /etc/openvpn/bridge_start.sh
-
Network interface issues:
# Check if ethernet interface exists ip link show # Check for correct interface name (might be enp0s3, ens33, etc.)
-
Permission issues:
sudo chmod +x /etc/openvpn/bridge_start.sh sudo chown root:root /etc/openvpn/bridge_start.sh
Check client logs:
- Windows:
C:\Program Files\OpenVPN\log\
- macOS: Console app → search for "openvpn"
- Linux:
journalctl | grep openvpn
Common client problems:
-
TAP adapter issues (Windows):
- Install/reinstall TAP-Windows driver
- Run OpenVPN client as administrator
-
Firewall blocking:
- Allow OpenVPN through Windows Firewall
- Check antivirus software blocking
-
DNS issues:
# Test DNS resolution on client nslookup google.com
From Raspberry Pi:
# Test internet connectivity
ping google.com
# Test local network
ping 10.99.99.1 # Your router
# Check listening ports
sudo netstat -tulpn | grep openvpn
From client (when connected):
# Test VPN server
ping 10.99.99.134 # Your Pi's IP
# Test other local devices
ping 10.99.99.1 # Your router
# Test internet through VPN
ping google.com
-
Check CPU usage:
top htop
-
Network bandwidth test:
# Install iperf3 sudo apt install iperf3 # On server iperf3 -s # On client iperf3 -c <server-ip>
-
Optimize OpenVPN settings (add to server.conf):
# Increase buffer sizes sndbuf 524288 rcvbuf 524288 # Use fast cipher cipher AES-128-GCM # Reduce compression overhead comp-lzo no
Enable verbose logging:
sudo nano /etc/openvpn/server.conf
# Change: verb 3
# To: verb 4 or verb 5
Key log locations:
- OpenVPN server:
/var/log/openvpn/status.log
- System logs:
journalctl -u openvpn-server@server
- Bridge script:
journalctl -u openvpn-bridge.service
Common error patterns:
- "TLS handshake failed" → Certificate/key issues
- "Cannot allocate TUN/TAP" → TAP driver or permissions
- "RESOLVE: Cannot resolve host" → DNS or network issues
- "Connection reset by peer" → Firewall or port forwarding
- OpenVPN Official Documentation
- OpenVPN TAP Bridge Mode Guide
- OpenVPN Ethernet Bridging
- OpenVPN Security Hardening
- No-IP - Free dynamic DNS with limited features
- DuckDNS - Free and simple dynamic DNS
- CloudNS - Professional DNS services
- Cloudflare - Free tier includes dynamic DNS
- OpenVPN Connect - Official client for Windows/macOS/mobile
- Tunnelblick - macOS OpenVPN client
- NetworkManager - Linux integration
Bridge mode VPN setup provides powerful network extension capabilities, allowing remote devices to seamlessly integrate with your home network. However, it requires careful planning and configuration to ensure security and avoid conflicts.
- Network Planning: Choose unique IP ranges to avoid conflicts with remote networks
- Security: Keep your system updated and use strong authentication
- Testing: Thoroughly test the setup from different locations and networks
- Monitoring: Regularly check logs and system status
- Documentation: Keep notes of your specific configuration for future reference
Use Bridge Mode when:
- Applications require broadcast/multicast traffic (e.g., network discovery, gaming, media streaming)
- You need devices to appear on the same network segment
- Legacy applications expect local network behavior
- You want to access network services like file sharing, printers, etc.
Use Routed Mode when:
- You only need internet access through the VPN
- You want better security isolation
- You have limited IP address space
- Performance is more critical than full network integration
- Change default passwords and use strong authentication
- Consider using certificate-based authentication for clients
- Regularly update both server and client software
- Monitor connection logs for unusual activity
- Use non-standard ports when possible
- Consider setting up fail2ban for additional protection
- Monitor system resources (CPU, memory, network)
- Check logs regularly for errors or security issues
- Test VPN connectivity periodically
- Keep client configurations backed up
- Document any configuration changes
- Monitor certificate expiry dates and renew before expiration
- Regularly check for OpenVPN and system updates
For detailed certificate management procedures, see the Certificate Management section in the Configuration Guide.
By following this guide, you should have a robust OpenVPN bridge mode server that provides secure, seamless access to your home network from anywhere in the world.