CentOS安装OpenVPN-2.3.2傻瓜版

2013年11月13日4730

以CentOS6 32位源为例,如果是CentOS5或者64位可替换下面的第一行中的源。

http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

 

##!/bin/bash
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
yum install openvpn -y
cp /usr/share/doc/openvpn-*/sample/sample-config-files/server.conf /etc/openvpn
sed -i '[email protected]*f1.*@push "redirect-gateway def1 bypass-dhcp"@' /etc/openvpn/server.conf
sed -i '[email protected]*222.*@push "dhcp-option DNS 8.8.8.8"@' /etc/openvpn/server.conf
sed -i '[email protected]*220.*@push "dhcp-option DNS 8.8.4.4"@' /etc/openvpn/server.conf
sed -i '[email protected];user [email protected] [email protected]' /etc/openvpn/server.conf
sed -i '[email protected];group [email protected] [email protected]' /etc/openvpn/server.conf
cp /usr/share/doc/openvpn-*/sample/sample-keys/* /etc/openvpn
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
service iptables save
service iptables restart
sed -i "s/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g" /etc/sysctl.conf
sysctl -p
service openvpn restart
chkconfig openvpn on

 

Windows客户端程序:openvpn-install-2.3.2-I003-i686.exe

登陆方法:

拷备服务器 /etc/openvpn/ 目录下的 ca.crt client.crt client.key 三个文件

放到 openvpn-install-2.3.2-I003-i686.exe 安装目录C:Program Files (x86)OpenVPNconfig文件夹中

并在config文件夹内新建文件名为:client.ovpn 填入以下内容(x.x.x.x 替换服务器IP或域名)

 

client
dev tun
proto udp
remote x.x.x.x 1194
resolv-retry infinite
nobind
persist-key
persist-tun
comp-lzo
verb 3
ca ca.crt
cert client.crt
key client.key

点击OpenVPN GUI 连接即可。

0 0