it's been a couple years since this, and here's a more easier to follow approach i made of this
VM preparation
setup virtualbox (or any hypervisor)
create a vm (needs to have internet)
download debian 11 (net-install preferred) -> install it onto the vm
OS preparation
reset root password by rebooting into single-user mode
at the grub boot menu, press 'e' to edit the first boot option
in the grub menu, find the line that starts with linux and at the end of its line, remove the
ro quiet
and replace it with the following
rw init=/bin/bash
press f10 key and wait until it goes into the # prompt. at the # prompt, type
mount -o remount,rw /
passwd root
{enter the new password twice}
reboot -f
at the debian login, log as the normal user. open terminal and type
su root
{enter the recently changed root password}
at the root part, ensure update of the OS firstly
apt update && apt full-upgrade -y
Install OpenvpnAS for Debian 11 (bullseye)
apt update && apt -y install ca-certificates wget net-tools gnupg
wget
https://as-repository.openvpn.net/as-repo-public.asc -qO /etc/apt/trusted.gpg.d/as-repository.asc
echo "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/as-repository.asc]
http://as-repository.openvpn.net/as/debian bullseye main">/etc/apt/sources.list.d/openvpn-as-repo.list
apt update && apt -y install openvpn-as
take note of the openvpn password
setup openvpn by opening firefox inside the UI, you may type
https://localhost and enter the openvpn password. you will be greeting with a EULA that you need to accept
openvpn will load now, from here, do the following
create a regular user account and specify its password > Save Settings
go to Configuration
> Network Settings (most important part)
set the protocol to TCP > Save Settings
> VPN settings (optional)
have the clients use specific DNS servers (you may specify 8.8.8.8 as primary and 1.1.1.1 or any other specific DNS you prefer)
> Advanced VPN (optional)
enable prefer Openvpn data channel offloading if available (ovpn-dco) > Save Settings
> Web Server (optional)
click yes on the Self-signed Certificate > Save Settings
Setup Ngrok
create a free ngrok account and within ngrok dashboard, go into Setup & Installation
take note of the line under "Connect your account"
at the same terminal window with root privileges, type the following to download and setup ngrok
wget
https://bin.equinox.io/c/bNyj1mQVY4c/ng ... -amd64.tgz
sudo tar xvzf ./ngrok-v3-stable-linux-amd64.tgz -C /usr/local/bin
ngrok authtoken NGROK_AUTHTOKEN
ngrok tcp 443 {take note of the forwarding line -- usually it's in the format of number.tcp.region.ngrok.io:random-port-forward-number (ex: 1.tcp.ap.ngrok.io:12345)}
Client Setup
open a browser window on your client and access the generated URL with the following format
https://number.tcp.region.ngrok.io:random-port-forward-number
login with the regular user account
download the "Yourself(user-locked-profile)" > it will download a *.ovpn file
using a text editor, edit the *.ovpn file by looking for a line that starts with port, change the value from 443 to the random-port-forward-number generated by ngrok. save the file.
install openvpn connect
choose to import profile, and choose file
browse/drag the *.ovpn file you just edited
you should be able to connect to the VPN server under a CGNAT
notes to consider:
ensure ngrok automatically runs upon startup
restarting ngrok changes the random port, thus requires a change of setting at the client-level (will need to redownload updated profile setting)
instead of a vm, you may instead use a raspberry pi to host this using the pi-os