Linux一键安装openvpn

GitHub:https://github.com/angristan/openvpn-install

下载

1
2
curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
sh openvpn-install.sh

以下基本全部默认即回车就行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
欢迎使用OpenVPN安装程序!

git存储库位于:https://github.com/angristan/openvpn-install



在开始安装之前我需要问你几个问题。

您可以保留默认选项,如果可以,只需按enter键。



我需要知道你想要OpenVPN监听的网络接口的IPv4地址。

除非您的服务器在NAT之后,否则它应该是您的公共IPv4地址。

IP地址:192.168.0.91



似乎这个服务器在NAT后面。它的公共IPv4地址或主机名是什么?

我们需要它让客户机连接到服务器。

公用IPv4地址或主机名:159.138.135.207



正在检查IPv6连接。。。



您的主机似乎没有IPv6连接。



是否要启用IPv6支持(NAT)?[是/否]:n



您希望OpenVPN监听哪个端口?

1) 默认值:1194

2) 风俗习惯

3) 随机[49152-65535]

端口选择[1-3]:1



您希望OpenVPN使用什么协议?

UDP更快。除非它不可用,否则不应该使用TCP。

1) UDP协议

2) TCP协议

方案[1-2]:2



您想在VPN中使用哪些DNS解析程序?

1) 来自系统的电流/决议.conf)

2) 自托管DNS解析程序(未绑定)

3) Cloudflare(Anycast:全球)

4) Quad9(选播:全球)

5) Quad9未经审查(选播:全球)

6) FDN(法国)

(七)DNS.监视(德国)

8) OpenDNS(Anycast:全球)

9) 谷歌(Anycast:全球)

10) Yandex Basic(俄罗斯)

11) AdGuard DNS(Anycast:全球)

12) NextDNS(Anycast:全球)

13) 定制

DNS[1-12]:11



要使用压缩吗?这是不推荐的,因为漩涡攻击利用它。

是否启用压缩?[是/否]:n



是否要自定义加密设置?

除非您知道自己在做什么,否则应该坚持使用脚本提供的默认参数。

请注意,无论您选择什么,脚本中显示的所有选项都是安全的。(与OpenVPN的默认设置不同)

看到了吗https://github.com/angristan/openvpn安装安全性-和加密来了解更多。



自定义加密设置?[是/否]:n



好吧,这就是我所需要的。我们准备好设置您的OpenVPN服务器了。

您将能够在安装结束时生成客户端。

按任意键继续。。。

已加载内:FastTestMirror、产品id、禁用搜索的回购、subscription manager



此系统未向授权服务器注册。您可以使用订阅管理器进行注册。



从缓存主机文件加载镜像速度

*底座:centos.usonyx.net网站

*埃佩尔:我的镜子。千兆位.com网站

*附加服务:centos.usonyx.net网站

*更新:centos.usonyx.net网站

正在解决依赖关系

--> 正在检查事务

--->软-释放.noarch.0.7-12将被升级

--->软-释放.noarch.0.7-13将被更

--> 解决依赖关系完成



依赖关系解决



==================================================================================================================================================================================================================

项目包

==================================================================================================================================================================================================================

正在更新:

epel发布noarch 7-13 epel 15 k



事务概要

==================================================================================================================================================================================================================

升级1软



总下载量:15 k

Created symlink from /etc/systemd/system/multi-user.target.wants/openvpn-server@server.service to /etc/systemd/system/openvpn-server@.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/iptables-openvpn.service to /etc/systemd/system/iptables-openvpn.service.

Tell me a name for the client.
The name must consist of alphanumeric character. It may also include an underscore or a dash.
Client name: qqq

Do you want to protect the configuration file with a password?
(e.g. encrypt the private key with a password)
1) Add a passwordless client
2) Use a password for the client
Select an option [1-2]: 1

Note: using Easy-RSA configuration from: /etc/openvpn/easy-rsa/vars
Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017
Generating a 256 bit EC private key
writing new private key to '/etc/openvpn/easy-rsa/pki/easy-rsa-1189.xDRljc/tmp.YZio3L'
-----
Using configuration from /etc/openvpn/easy-rsa/pki/easy-rsa-1189.xDRljc/tmp.nnabLW
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName :ASN.1 12:'qqq'
Certificate is to be certified until Mar 10 11:03:31 2023 GMT (825 days)

Write out database with 1 new entries
Data Base Updated

Client qqq added.

The configuration file has been written to /root/qqq.ovpn.
Download the .ovpn file and import it in your OpenVPN client.

查看状态与端口

1
2
systemctl status openvpn-server@server
ss -anpt | grep 1194

下载对应操作系统的OpenVPN客户端把/root/qqq.ovpn导入进去,点击连接即可