利用sh安装OPENVPN,除去锁碎配置,快速搭建安全专属通道。
下载openvpn-install.sh并安装以及赋予x权限
shell > wget http://git.io/vpn --no-check-certificate -O openvpn-install.sh; chmod +x openvpn-install.sh;
安装openvpn-install.sh
Centos : sh openvpn-install.sh Ubuntu : sudo openvpn-install.sh
注意事项
First I need to know the IPv4 address of the network interface you want OpenVPN listening to. IP address: 1.2.3.4 //本机IP What port do you want for OpenVPN? Port: 1194 //默认VPN端口 What DNS do you want to use with the VPN? 1) Current system resolvers 2) OpenDNS 3) Level 3 4) NTT 5) Hurricane Electric 6) Google DNS [1-6]: 6 //按6设置google为DNS,默认是1 Finally, tell me your name for the client cert Please, use one word only, no special characters Client name: client-vpn //配置客户端VPN名称 Okay, that was all I needed. We are ready to setup your OpenVPN server now Press any key to continue... //按任意键开始安装 . . 省 略 . . Your client config is available at ~/client-vpn.ovpn //找到这个配置文件下载到本地 If you want to add more clients, you simply need to run this script another time!
查看下OpenVPN运行状态
shell > ps ax|grep openvpn
会看的这下这些
16103 ? Ss 0:00 /usr/sbin/openvpn --daemon --writepid /var/run/openvpn/server.pid --cd /etc/openvpn --config server.conf --script-security 2 16120 pts/0 S+ 0:00 grep openvpn
检查sysctl.conf并保存
shell > vi /etc/sysctl.conf net.ipv4.ip_forward = 1 shell > sysctl -p /etc/sysctl.conf
iptables nat 地址转换
iptables -t nat -A POSTROUTING -s 1.2.3.4/24 -o eth0 -j MASQUERADE
到这里基本OK了,下面就是下载openvpn-install安装,然后把刚才从服务器上下载下来的client-vpn.ovpn文件放到C:\Program Files(x86)\OpenVPN\config\下面,启动OpenVPN GUI,右击Connect经行连接。