安装OpenVPN
[root@localhost ~]# yum install -y epel-release
[root@localhost ~]# yum install openvpn lzo -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: my.mirrors.thegigabit.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
软件包 openvpn-2.4.12-1.el7.x86_64 已安装并且是最新版本
软件包 lzo-2.06-8.el7.x86_64 已安装并且是最新版本
无须任何处理
配置客户端文件
[root@localhost ~]# vim /etc/openvpn/client/client.conf
client
dev tun
proto tcp
remote openvpn.if010.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca /etc/openvpn/client/ca.crt
cert /etc/openvpn/client/client.crt
key /etc/openvpn/client/client.key
tls-auth /etc/openvpn/client/ta.key 1
remote-cert-tls server
ns-cert-type server
cipher AES-256-GCM
verb 3
comp-lzo
push-peer-info
key-direction 1
拷贝相关文件
[root@localhost ~]# tree /etc/openvpn/
/etc/openvpn/
├── client
│ ├── ca.crt # 服务端提供
│ └── ta.key # 服务端提供
├── client.ovpn # 客户端配置文件
├── passwd # 账号密码文件,需要新建,第一行账号,第二行是密码
└── server
2 directories, 4 files
启动客户端
[root@localhost ~]# openvpn \
--daemon \
--auth-user-pass /etc/openvpn/client/passwd \
--config /etc/openvpn/client/client.conf \
--log-append /var/log/openvpn.log
命令参数说明:
--daemon # 后台运行
--config # 配置文件名称
--auth-user-pass # 指定账号密码文件
--log-append # 日志文件
查看日志
[root@localhost ~]# cat /var/log/openvpn.log