This script requires the following packages to be installed:
openvpn- OpenVPN clientdante-server- SOCKS5 server (providesdanted)socat- Socket relaycurl- For testing connectivityiproute2- Network namespace management (usually pre-installed)iptables- Firewall rules (usually pre-installed)
sudo apt update
sudo apt install openvpn dante-server socat curl iproute2 iptablescd /path/to/dev-socks-isolation/linux/Ubuntu
chmod +x connect.sh
./connect.shThe script will prompt you for:
- Namespace name (default: vpnspace)
- Path to your OpenVPN config file (.ovpn)
- Network interface (auto-detected)
- Host IP address (auto-detected)
- SOCKS5 ports configuration
- DNS server (default: 8.8.8.8)
- Whether to launch VSCode automatically
./disconnect.shUbuntu 20.04+ uses systemd-resolved for DNS management. The script handles this automatically by creating namespace-specific DNS configuration in /etc/netns/.
Ubuntu uses AppArmor for security. If you encounter permission issues with OpenVPN, you may need to adjust the AppArmor profile:
sudo aa-complain /usr/sbin/openvpnOr disable AppArmor for OpenVPN (not recommended for production):
sudo ln -s /etc/apparmor.d/usr.sbin.openvpn /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.openvpnCreate a systemd service for automatic startup:
sudo nano /etc/systemd/system/vscode-vpn-proxy.serviceAdd:
[Unit]
Description=VSCode VPN SOCKS5 Proxy
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/path/to/dev-socks-isolation/linux/Ubuntu/connect.sh
ExecStop=/path/to/dev-socks-isolation/linux/Ubuntu/disconnect.sh
StandardInput=tty-force
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.targetThen enable it:
sudo systemctl daemon-reload
sudo systemctl enable vscode-vpn-proxy.serviceThis script is compatible with:
- Ubuntu (20.04 LTS, 22.04 LTS, 24.04 LTS and newer)
- Linux Mint (20, 21, 22)
- Pop!_OS (20.04, 22.04 and newer)
- Zorin OS (16, 17)
- Elementary OS
- Other Ubuntu-based distributions
Solution:
sudo apt install dante-serverNote: On Ubuntu/Debian, the Dante server binary might be called danted instead of sockd.
Solution: Check if systemd-resolved is running:
systemctl status systemd-resolvedIf it's active, the script should handle DNS automatically. If not, you can manually set DNS servers.
Solution: Ensure your user has sudo privileges:
sudo usermod -aG sudo $USERThen log out and log back in.
Solution: List your network interfaces:
ip link show
# Common names: eth0, enp*, wlp* (wifi)If you're using UFW (Ubuntu's default firewall), you may need to allow forwarding:
sudo ufw allow from 10.200.200.0/24
sudo ufw route allow from 10.200.200.0/24If you're using NetworkManager's OpenVPN plugin, you can still use this script with manually exported .ovpn files.
For better privacy, consider using:
- Cloudflare: 1.1.1.1
- Quad9: 9.9.9.9
- OpenDNS: 208.67.222.222
You can run multiple isolated VPN connections simultaneously by using different namespace names.
For Ubuntu-specific issues, check: