使用openvpn+easyrsa搭建VPN测试环境

环境安装

1. 命令行安装

1
2
3
4
5
6
7
# centos
$ yum install -y lzo openssl pam
$ yum install -y epel-release
$ yum install -y openvpn easy-rsa iptables-services

# ubuntu
$ apt-get install openvpn

2. 源码安装

1
2
3
4
5
6
7
8
9
10
11
12
# To get the latest release of OpenVPN, go to https://openvpn.net/community-downloads/:
$ wget https://swupdate.openvpn.org/community/releases/openvpn-2.6.12.tar.gz

# To Build and Install,
$ tar -zxf openvpn-<version>.tar.gz
$ cd openvpn-<version>
$ ./configure
$ make
$ make install

# easyrsa
$ wget https://github.com/OpenVPN/easy-rsa/releases/download/v3.1.2/EasyRSA-3.1.2.tgz

配置

  • 默认配置路径:/etc/openvpn/

命令行使用

1.服务端

1
$ openvpn --ifconfig 10.10.0.1 10.10.0.2 --dev tun

2.客户端

1
2
3
4
$ openvpn --ifconfig 10.10.0.2 10.10.0.1 --dev tun --remote 100.100.2.181

# alpine平台上需要手动加载tun驱动
$ modprobe tun

参考

相关项目