Ubuntu 20.04 中使用OpenVPN搭建VPN服务器

Other-经验分享 2025-12-10

和其它的文章不同,以下是很简单的搭建方法
1、升级系统打上补丁可以使用以下命令行

sudo apt update
sudo apt upgrade -y

2、下载openvpn的安装脚本,使用脚本安装省去安装证书等过程。我们可以通过以下命令下载脚本并运行脚本

wget https://git.io/vpn -O openvpn-ubuntu-install.sh
chmod -v +x openvpn-ubuntu-install.sh
sudo ./openvpn-ubuntu-install.sh

在安装过程选择如下图:
主要选项是协议一般选择UDP,DNS可以任意选择,Client名称可以自己名字,运行完脚本最终会在 /root目录下生成一个 .ovpn文件,这个正是我们上网的凭证文件。同时vpn服务也会自动安装好了
3、我们可以通过以下命令来管理vpn服务

sudo systemctl status openvpn-server@server.service
sudo systemctl start openvpn-server@server.service
sudo systemctl stop openvpn-server@server.service
sudo systemctl restart openvpn-server@server.service

4、如果我们还要添加用户可以继续运行以下脚本

 sudo ./openvpn-ubuntu-install.sh

端口测试

nc -vuz 159.135.192.235 1194
// Connection to 159.135.192.235 1194 port [udp/openvpn] succeeded!

https://gist.github.com/ebta/301f286fa9056d67e61bfc7cedd4ad56
相关链接:
https://linuxconfig.org/basic-ubuntu-22-04-openvpn-client-server-connection-setup
https://kifarunix.com/install-and-setup-openvpn-server-on-ubuntu-22-04/
https://www.cyberciti.biz/faq/ubuntu-20-04-lts-set-up-openvpn-server-in-5-minutes/


本文由 Surou 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处。

还不快抢沙发

添加新评论