debian 6 openvpn

1:安装
apt-get install openvpn iptables

2:配置服务端

cp -R /usr/share/doc/openvpn/examples/easy-rsa /etc/openvpn
cd /etc/openvpn/easy-rsa/2.0
chmod +x vars
source ./vars
./clean-all

./build-ca
这一步,您一直回车就行,不要填密码,如果要求你回答Y还是N,选Y回车

./build-key-server server

./build-key client1
这2步也跟上面一样,一路回车和选择Y回车

./build-dh

3:配置转发
vi /etc/rc.local
添加以下语句,您只要替换“208.110.73.134”为您自己的ip就行
# add iptables rule for openvpn
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o venet0 -j SNAT --to 208.110.73.134

4:增加服务器端conf文件
vi /etc/openvpn/openvpn.conf
增加如下内容
dev tun
proto tcp
port 1194

ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt
cert /etc/openvpn/easy-rsa/2.0/keys/server.crt
key /etc/openvpn/easy-rsa/2.0/keys/server.key
dh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem

user nobody
group nogroup
server 10.8.0.0 255.255.255.0

persist-key
persist-tun

#status openvpn-status.log
#verb 3
client-to-client

push “redirect-gateway def1″
push “dhcp-option DNS 69.197.153.253″
push “dhcp-option DNS 69.30.192.15″

comp-lzo

ok,启动openvpn服务
/etc/init.d/openvpn start
nohup /etc/rc.local &

5:客户端安装配置
http://openvpn.net/index.php/open-source/downloads.html 下载winodws客户端
安装后,然后从服务器把以下3个文件拷贝到windows安装路径下的config目录
这3个文件分别是
/etc/openvpn/easy-rsa/2.0/keys/ca.crt
/etc/openvpn/easy-rsa/2.0/keys/client1.crt
/etc/openvpn/easy-rsa/2.0/keys/client1.key

6:增加客户端配置文件
在config增加一个配置文件,文件名为client.ovpn
内容如下:
client
dev tun
proto tcp

# The hostname/IP and port of the server.
# CHANGE THIS TO YOUR VPS IP ADDRESS
remote 208.110.73.134 1194

resolv-retry infinite
nobind

persist-key
persist-tun

ca ca.crt
cert client1.crt
key client1.key

comp-lzo
verb 3

 

 

File excerpt:/etc/sysctl.conf

net.ipv4.ip_forward=1

Issue the following command to set this variable for the current session:

echo 1 > /proc/sys/net/ipv4/ip_forward
Last modified onSunday, 14 October 2012 04:07

Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169
  • Published in Openvpn
  • Read 1760 times

Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478
back to top