openVPN搭建

安装git

1
2
3
4
sudo apt-get update
sudo apt-get upgrade

sudo apt-get install git

安装openVPN

1
2
cd ~
git clone https://github.com/Nyr/openvpn-install.git

运行openVPN

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
cd openvpn-install/
ls
chmod +x openvpn-install.sh
sudo ./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: 192.168.10.2

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

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

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... <Enter>

回答完问题后按enter开始安装成功后,收到成功消息

创建虚拟接口

1
2
3
4
5
6
7
8
9
ip ad | grep tun0

ip route | grep tun0

测试要安装
sudo apt-get install traceroute

然后
traceroute 10.8.0.1

生成配置文件

1
./openvpn-install.sh

把配置文件保存到客户端