设为首页收藏本站

简体中文 繁體中文 English 日本語 Deutsch 한국 사람 بالعربية TÜRKÇE português คนไทย french

搜索
热搜: 活动 交友 discuz

debian 安装配置 openvpn [复制链接]
查看:50 | 回复:5

72

主题

281

回帖

834

积分

高级会员

积分
834
发表于 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目录然后启动即可。

224

主题

2144

回帖

5032

积分

论坛元老

积分
5032
发表于 2012-8-17 23:14:11 | 显示全部楼层
技术贴~

10

主题

61

回帖

190

积分

注册会员

积分
190
发表于 2012-8-17 23:16:05 | 显示全部楼层
很多步骤啊

85

主题

2334

回帖

5021

积分

论坛元老

积分
5021
发表于 2012-8-17 23:26:35 | 显示全部楼层
好长 很有难度

79

主题

977

回帖

2251

积分

金牌会员

积分
2251
发表于 2012-8-17 23:27:32 | 显示全部楼层
现在都玩goagent了,玩vpn多不好

41

主题

424

回帖

1027

积分

金牌会员

积分
1027
发表于 2012-8-17 23:36:48 | 显示全部楼层
技术贴。。支持下
您需要登录后才可以回帖 登录 | 立即注册

论坛客服/商务合作/投诉举报:2171544 (QQ)
落伍者创建于2001/03/14,本站内容均为会员发表,并不代表落伍立场!
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论!
落伍官方微信:2030286 邮箱:(djfsys@gmail.com|tech@im286.com)
© 2001-2014

浙公网安备 33060302000191号

浙ICP备11034705号 BBS专项电子公告通信管[2010]226号

  落伍法律顾问: ITlaw-庄毅雄

Archiver|手机版|Discuz! X

GMT+8, 2026-7-25 22:40 , Processed in 0.015661 second(s), 3 queries , Gzip On, Redis On.

返回顶部