Skip to content

Instantly share code, notes, and snippets.

@rameshkrishna
Last active May 20, 2024 07:04
Show Gist options
  • Save rameshkrishna/17e14ee67405fe41dab997d48b65f4f5 to your computer and use it in GitHub Desktop.
Save rameshkrishna/17e14ee67405fe41dab997d48b65f4f5 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
@kim3k
Copy link

kim3k commented Mar 21, 2023

is it working?

No.. i did end up install pivpn and open port on router.. :/ but its working great!

@amanjuman
Copy link

Same setup works fine with V2Ray, CGNET works fine.

@RogerMarty
Copy link

Just got this to work. Thanks!!!
The only thing that was incorrect and needed adjustment was the change in the OpenVPN config file. It needs to be 127.0.0.1 87548 instead of 127.0.0.1:87548. Whitspace instead of ":".
Everything else worked fine.

@J-494
Copy link

J-494 commented Sep 6, 2023

I have been trying on this but not working for me.
i followed the same config.yaml as above including the command on client machine.

It showing error as below
image

OpenVPN config
image

Can anyone help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment