Skip to content

Instantly share code, notes, and snippets.

@hiphopsmurf
Forked from rameshkrishna/openvpncloudlared.txt
Created February 11, 2025 01:03
Show Gist options
  • Save hiphopsmurf/1343eef5369aa5ed9117c1a5c87b3d1e to your computer and use it in GitHub Desktop.
Save hiphopsmurf/1343eef5369aa5ed9117c1a5c87b3d1e to your computer and use it in GitHub Desktop.
OpenVPN with Cloudflared Tunnels - No Port Fowarding - No Static IP - NO DDNS
Task:
Access OpenVPN or any Service on Home Network from Public Networks (Hotel) without configuring router and without static IP
Step 1:
Install OpenVPN on any device connected to Home Network (Raspberry mychoice with pivpn)
- Change default OpenVPN protocol from UDP to TCP (Cloudflare doesn't support UDP)
- Make a note of TCP port number (default is 443)
- Grab the OpenVPN client config file
Step 2:
Install Cloudflared on Raspberry PI
- Create a tunnel
- Add route to tunnel (cloudflared tunnel route dns tunnelName tunnelName.domain.com)
- Example config:
tunnel: 6ff42ae2-765d-4adf-8112-31c55c1551ef
credentials-file: /root/.cloudflared/6ff42ae2-765d-4adf-8112-31c55c1551ef.json
ingress:
- hostname: tunnelName.domain.com
service: tcp://127.0.0.1:443 (OpenVPN Server's Local IP )
- service: http_status:404
- Run the tunnel (You can also setup cloudflare service)
Step 3:
- Install Cloudflared on your Machine - OpenVPN Client Machine (Machine on Public Network)
- Create a connection to your OpenVPN Server
cloudflared access tcp --hostname tunnelName.domain.com --url 127.0.0.1:87548 (port_of_your_choice)
- Now update remote in OpenVPN config file with 127.0.0.1:87548
- If you want to protect your openvpn with Cloudflare's free Protection add to Cloudflare Teams, When Profile is imported and
connected user will be prompted with login page. as a 2FA
Step 4:
- Download OpenVPN Client
- Import profile and Connect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment