How to make your own vpn server with ngrok and openvpn
Tool for use this script:
- Github Account
- (2) NGROK Account https://ngrok.io/
- Putty(windows) / iTrem / Teminal (macOS & Linux)
- Filezilla / other FTP Software
Follow this step for setup
- Sign in your github account https://github.com/
- Sign in first account Ngrok at https://dashboard.ngrok.com/ and second account ngrok at other window browser
- Remote your VPS with putty/terminal/iTerm & Login
- Use root
sudo su
- Input your vps password
- Install curl and openvpn
sudo apt update && apt install curl openvpn -y
- Get and install openvpn using
curl -O https://raw.githubusercontent.com/galih-prasetyo/ngrok-openvpn/main/openvpn-install.sh
chmod +x openvpn-install.sh
sudo ./openvpn-install.sh
- Here is my basic config. You can follow exact or customize to fill your need
IP Address: 192.168.0.1 (your local static ip address)
Public IPv4 address or hostname: 0.tcp.ngrok.io (or 1.tcp.ngrok.io)
Do you want to enable IPv6 support (NAT)? [y/n]: n
Port choice [1-3]: 1 (Port 1194)
Protocol [1-2]: 2 (TCP) (Ngrok only support TCP by default)
DNS [1-12]: 9 (Google or anything for your taste)
Enable compression? [y/n]: n
Customize encryption settings? [y/n]: n (default should suffice)
Client name: galih (anything suffice)
Select an option [1-2]: 1 (passwordless or password)
- Then you should receive file with .ovpn extension. Copy this file and keep it private
- In this case my file is nana.ovpn at /root/home/galih your filename and folder path might be different
- Download Ngrok binary from https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
- Unzip downloaded file to /home/galih (your user folder)
- Create new dir /home/galih/.ngrok2
- Create ngrok.yml file inside /home/galih/.ngrok2/
authtoken: <YOUR AUTHTOKEN SECOND ACOOUNT NGROK>
tunnels:
openvpn:
addr: 1194
proto: tcp
- Change to your ngrok authtoken https://dashboard.ngrok.com/auth/your-authtoken
- Create service file called ngrok.service and place it in /etc/systemd/system/
[Unit]
Description=ngrok
After=network.target
[Service]
ExecStart=/home/CHANGE-YOUR-NAME/ngrok start --all --config /home/CHANGE-YOUR-NAME/.ngrok2/ngrok.yml
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
Type=simple
[Install]
WantedBy=multi-user.target
- Enable and start ngrok.service
sudo systemctl enable ngrok.service
sudo systemctl start ngrok.service
- To test if everything work correctly, do
sudo systemctl status ngrok.service
it should output something like
● ngrok.service - ngrok
Loaded: loaded (/etc/systemd/system/ngrok.service; enabled; vendor enabled)
Active: active (running) since Mon 2020-08-24 04:35:22 UTC; 5 days ago
Main PID: 682 (ngrok)
Tasks: 11 (limit: 1677)
Memory: 33.3M
CGroup: /system.slice/ngrok.service
└─682 /home/galih/ngrok start --all --config /home/galih/.ngrok2/ngrok.yml
##SETTING VPN ON YOUR DEVICE##
- Install openvpn in your device (it could be your laptop or anything)
- Download your openvpn file with filezilla
- Open galih.ovpn file using your favorite text editor
- Change line to match tunnels url https://dashboard.ngrok.com/status/tunnels at your second ngrok account
for example if your tunnel url is tcp://1.tcp.ngrok.io:15342
then change line to remote 1.tcp.ngrok.io 15342
- And that's it, now you're connected to your VPN
Have a good study