Linux一键部署OpenVPN脚本

每次架设OpenVPN Server就很痛苦,步骤太多,会出错的地方也多,基本很少一次性成功的。直到我找到了这个项目:
项目地址:https://github.com/guoew/openvpn-install

运行脚本安装服务端

git clone https://github.com/guoew/openvpn-install.git
cd openvpn-install && bash openvpn-install.sh
Welcome to this OpenVPN "road warrior" installer! 
I need to ask you a few questions before starting the setup.     You can leave the default options and just press enter if you are ok with them. 
First, provide the IPv4 address of the network interface you want OpenVPN listening to.
IP address: 172.27.0.2 #默认获取本机ip,直接回车,因为获取到的是容器内IP没意义
This server is behind NAT. What is the public IPv4 address or hostname? 
Public IP address / hostname: xxx.xxx.xxx.xxx #输入自己的公网ip
 Which protocol do you want for OpenVPN connections?
 1) UDP (recommended)
 2) TCP Protocol [1-2]: 1 #选择连接协议
What port do you want OpenVPN listening to? Port: 1194 #设置openvpn监听端口 
Which DNS do you want to use with the VPN? 
 1) Current system resolvers 
 2) 1.1.1.1 
 3) Google 
 4) OpenDNS 
 5) Verisign DNS [1-5]: 1 #选择DNS 
Finally, tell me your name for the client certificate. 
Please, use one word only, no special characters. 
Client name: client #设置客户端名称 
Okay, that was all I needed. We are ready to set up your OpenVPN server now. Press any key to continue... #任意键继续 
... 
An updated CRL has been created.
CRL file: /etc/openvpn/server/easy-rsa/pki/crl.pem
Created symlink /etc/systemd/system/multi-user.target.wants/openvpn-iptables.service → /etc/systemd/system/openvpn-iptables.service. 
Created symlink /etc/systemd/system/multi-user.target.wants/openvpn-server@server.service → /lib/systemd/system/openvpn-server@.service. 
Finished! #安装完毕 
 Your client configuration is available at: /root/client.ovpn #客户端配置文件路径 
If you want to add more clients, you simply need to run this script again!

将客户端配置文件 /root/client.ovpn,下载到本地,使用OpenVPN客户端导入。

添加账号

在openvpn目录下的userfile.sh中添加用户和密码,以空格隔开

vim /etc/openvpn/userfile.sh

在里面加入用于客户端账号密码

user password
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值