1)脚本编写

#!/bin/bash

echo -e "\033[33m名为 $0 的脚本 已经开始运行\033[0m"

echo -e "\033[34m======================================\033[0m"

CMD=`netstat -anpu | grep openvpn | awk '{print $4}'`

echo -e "\033[36m服务已经启动 并且正在运行 所监听的地址及端口号为 \033[0m: $CMD"

echo -e "\033[35m======================================================================\033[0m"

IP="$(cat /root/ip.txt)"

for i in ${IP}

do
        ping -c 3 -i 0.0 -W 1 ${i} > /dev/null

if [ "$?" -eq "0" ]

then
        echo -e "\033[32m可以通信的主机有:${i} \033[0m"
else
        echo -e "\033[31m不可通信的主机有:${i} \033[0m"
fi

done

2)安装对应的依赖包

[root@node1 ~]# yum clean all && yum makecache
[root@node1 ~]# yum -y install epel*
[root@node1 ~]# yum -y install pkcs11-helper pkcs11-helper-devel lzo lzo-devel
[root@node1 ~]# yum -y install openssl openssl-devel pam pam-devel gcc gcc-c++ zlib-devel pcre-devel

3)下载OpenVPN软件包

[root@node1 ~]# wget -c http://oss.aliyuncs.com/aliyunecs/openvpn-2.2.2.tar.gz

4)使用RPM方式安装OpenVPN

[root@node1 ~]# rpmbuild -tb openvpn-2.2.2.tar.gz
[root@node1 ~]# rpm -ivh rpmbuild/RPMS/x86_64/openvpn-2.2.2-1.x86_64.rpm

  

12-18 20:59