全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1594|回复: 6
打印 上一主题 下一主题

[疑问] debian 安装配置 openvpn

[复制链接]
跳转到指定楼层
1#
发表于 2012-8-17 23:12:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 小白 于 2012-8-17 23:15 编辑

本片文章主要讲述如何在vps上安装以及配置openvpn。本人已经在tinyvz的 vps上测试成功!

——

0)安装openvpn之前的任务

# apt-get update
# apt-get upgrade
# apt-get install iptables -y


1) 下载并且安装OpenVPN

# apt-get install openvpn

2) 移动相关文件到确定的地方

# cp -R /usr/share/doc/openvpn/examples/easy-rsa /etc/openvpn

3) 创建服务器以及客户端相关证书

# cd /etc/openvpn/easy-rsa/2.0

# . ./vars     

# ./clean-all     

# ./build-ca

# ./build-key-server server

# ./build-key client1

# ./build-dh

请一路回车, 如果需要回答 yes/no 请回答 yes

在输密码处不要输入密码,直接按回车确认

4) 配置 iptables 规则:

# chmod 755 /etc/rc.local

# nano /etc/rc.local

默认内容如下所述

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0

我们在 “exit 0″之前添加如下内容

用你自己的ip地址来替换 “208.110.73.134″

如下所示

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# 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

exit 0

5) 创建openvpn 配置文件

# nano /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 8.8.8.8"
    push "dhcp-option DNS 4.2.2.4"

    comp-lzo

6) 启动 OpenVPN:

# /etc/init.d/openvpn start
# /etc/rc.local &

—————

现在下载下述文件到客户端(windows)

/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

最后,创建客户端配置文件(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

———–

OpenVPN windows 客户端 http://deploy.ramhost.org/vps/openvpn-2.0.9-gui-1.0.3-install.exe

安装好客户端后 把上述三个文档以及自己创建的配置文件放入C:\Program Files\OpenVPN\config目录然后启动即可。
2#
发表于 2012-8-17 23:14:11 | 只看该作者
技术贴~
3#
发表于 2012-8-17 23:16:05 | 只看该作者
很多步骤啊
4#
发表于 2012-8-17 23:26:35 | 只看该作者
好长 很有难度
5#
发表于 2012-8-17 23:27:32 | 只看该作者
现在都玩goagent了,玩vpn多不好
6#
发表于 2012-8-17 23:36:48 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
7#
发表于 2012-8-18 09:12:24 | 只看该作者
技术贴。。支持下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2026-1-13 18:29 , Processed in 0.062383 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表