配置linux的openvpn客户端

前提:在前面实验的基础上,增加一台linux主机作为openvpn客户端

linux主机配置openvpn客户端

查看版本号

[root@A-linux ~]# uname -r
2.6.32-431.el6.x86_64
[root@A-linux ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@A-linux ~]# crontab -l
#time update by root
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1
编译安装lzo和openvpn软件
[root@A-linux openvpn]# ls
lzo-2.06.tar.gz openvpn-2.2.2.tar.gz
[root@A-linux openvpn]# tar xf lzo-2.06.tar.gz
[root@A-linux openvpn]# cd lzo-2.06
[root@A-linux lzo-2.06]# ./configure
[root@A-linux lzo-2.06]# make && make install
[root@A-linux openvpn]# tar xf openvpn-2.2.2.tar.gz
[root@A-linux openvpn]# cd openvpn-2.2.2
[root@A-linux openvpn-2.2.2]# yum install -y openssl*
[root@A-linux openvpn-2.2.2]# ./configure --with-lzo-headers=/usr/local/include --with-lzo-lib=/usr/local/lib
[root@A-linux openvpn-2.2.2]# make && make install

将原来Windows openvpnGUI软件下已成功拨号的用户整个文件夹打包为zip格式上传到linux主机openvpn客户端下

[root@A-linux openvpn]# ll
总用量 12
drwxr-xr-x 2 root root 4096 1月 29 15:34 test
-rw-r--r-- 1 root root 4432 2月 14 12:52 test.zip
[root@A-linux openvpn]# rm -f test.zip
[root@A-linux openvpn]# cp test/* ./
[root@A-linux openvpn]# ll
总用量 20
-rw-r--r-- 1 root root 1310 2月 14 12:54 ca.crt
drwxr-xr-x 2 root root 4096 1月 29 15:34 test
-rw-r--r-- 1 root root 3879 2月 14 12:54 test.crt
-rw-r--r-- 1 root root 1062 2月 14 12:54 test.key
-rw-r--r-- 1 root root 173 2月 14 12:54 test.ovpn
[root@A-linux openvpn]# rm -fr test
[root@A-linux openvpn]# mv test.ovpn client.conf
[root@A-linux openvpn]# cat client.conf 
client
dev tun
proto tcp
remote 10.0.0.5 52115
resolv-retry infinite
nobind
persist-key
persist-tun
ca /etc/openvpn/ca.crt
cert /etc/openvpn/test.crt
key /etc/openvpn/test.key
ns-cert-type server
comp-lzo
verb 3

[root@A-linux openvpn]# /usr/local/sbin/openvpn --config /etc/openvpn/client.conf &      #<===后台启动openvpn客户端
[root@A-linux openvpn]# echo "--script-security 3" >>/etc/openvpn/client.conf      #<===遇到报错,追加此行至文件结尾,或者将配置文件改名重新测试
[root@A-linux openvpn]# pkill openvpn
[root@A-linux openvpn]# /usr/local/sbin/openvpn --config /etc/openvpn/client.conf &

  

猜你喜欢

转载自www.cnblogs.com/blog-tim/p/10374080.html