教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 法律文档 >

windows下利用OpenVPN搭建VPN服务器(7)

来源:网络收集 时间:2026-05-27
导读: ca ca.crt auth-user-pass ns-cert-type server tls-auth ta.key 1 comp-lzo # Set log file verbosity. verb 4 --------------Cut Here--------------------- 并且把easy-rsa/keys下的ca.crt ta.key一起放到Client

ca ca.crt auth-user-pass

ns-cert-type server tls-auth ta.key 1 comp-lzo

# Set log file verbosity. verb 4

--------------Cut Here---------------------

并且把easy-rsa/keys下的ca.crt ta.key一起放到Client的 \\config目录下。

Client的配置已经结束,可以连接Server了,在右下角OpenVPN-gui上点右键,然后选择connected。

OK,整个配置就完成了。

#include #include #define MAX 1024

int checkpsw(char *username, char *password) { FILE *f;

char user[MAX+2], pass[MAX+2], active[MAX+2]; /* printf(\

if (!(f=fopen(\{ perror(\ }

printf(\

printf(\return(1);

while(!feof(f)) {

fscanf(f,\

printf(\

if (!strcmp(username,user) && !strcmp(password,pass) && !strcmp(active,\ { }

printf(\fclose(f); return (0);

/*

/*

} {

} fclose(f); return (1);

void main()

int status;

/* printf(\ }

checkpsw.exe OpenVPN用户名/密码验证程序

password.txt checkpsw.exe验证程序使用的用户名和密码程序 checkpsw.c checkpsw.exe源代码文件(TC)

password.txt格式

用户名 密码 是否活动(0/1) 中间用空格隔开 Username Password Active

-------------Cut Here--------------------- wzk wzk 1

-------------Cut Here---------------------

Blog: http://wenzk.cublog.cn

status=checkpsw(getenv(\return (status);

OPENVPN安装手册

来源:www.vfocus.net 作者:vfocus 发布时间:2009-08-18

by:http://blog.vfocus.net

一、在网上下载openvpn的安装包http://openvpn.net/上下载openvpn的最新版,时至今 日是openvpn-2.0.9.tar.gz。

网上都说还需要lzo这个压缩库。这个包是压缩的,我没有安装,在编译程序的时候只需要加上--disable-lzo就可以了。然后再配置文件里面把这项注释掉就可以了,这样所有要安装的就是一个包openvpn-2.0.9.tar.gz。 二、vpn服务端的网络结构

vpn服务端是有两个ip 其中eth0 172.16.6.79 提供vpn服务,由外部通过172.31.16.0/24 通过1194端口拨入,然后通过 eth1 192.168.253.79访问192.168.253.0/24去维护服务器 三、安装openvpn

tar zxvf openvpn-2.0.9.tar.gz cd openvpn-2.0.9

./configure –prefix=/usr/local/openvpn –-disable-lzo make;make install

四、生成openvpn证书

1、cd openvpn-2.0.9/ easy-rsa/ vi vars

根据自己的情况设置

根据自己的情况设置KEY_COUNTRY, KEY_PROVINCE, KEY_CITY, KEY_ORG, KEY_EMAIL,比如我的 export KEY_COUNTRY=CN export KEY_PROVINCE=Beijing export KEY_CITY=Beijing export KEY_ORG=abc

export KEY_EMAIL=abc@123.com 然后保存

. ./vars //注意两个点中间有空格 ./clean-all ./build-ca

build-ca 命令使用openssl 命令生成certificate authority (CA) certificate 和密钥:

./build-ca

Generating a 1024 bit RSA private key ....++++++ .......++++++

writing new private key to 'ca.key' -----

You are about to be asked to enter information that will be incorporated into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. -----

Country Name (2 letter code) [CN]:

State or Province Name (full name) [Beijing]: Locality Name (eg, city) [Beijing]: Organization Name (eg, company) [BUAA]: Organizational Unit Name (eg, section) []:

Common Name (eg, your name or your server's hostname) []:zhang //这里随便输入即可 Email Address [zhangwenhao@wanmei.com]: 这些步骤一直按回车就可以了 2、为vpn server生成证书与密匙 ./build-key-server server

Common Name 处填server,其他默认,为上面编辑vars 文件时设置的值。\[y/n]\和\两处选y。 3、为vpn clients 生成证书与密匙 ./build-key client1 ./build-key client2 ./build-key client3

Common Name 处分别填client1 client2 client3,别的同vpn server 设置 4、生成diffie hellman 参数 ./build-dh

现在生成了所需的文件。目录keys 下生成的文件中,ca.crt 是所有vpn 机器都需要的。vpn server 需要ca.crt ca.key dh1024.pem server.crt server.key,拷贝到vpn server 的/etc/openvpn目录。vpn client1 需要ca.crt ca.key lient1.crt client1.key,拷贝到vpn client1 的/etc/openvpn 目录。client2,client3 和client1 同,只是client1.crt 和client1.key 分别用client2 和client3 的对

应文件。vpn client2 和vpn client3 也把对应的密钥文件拷贝到各自的/etc/openvpn 目录。 五、配置server端与client端

1、server.conf 使用代码包目录sample-config-files 里的server.conf 修改即可。配置文件如下()

################################################# ;local a.b.c.d 绑定的IP 地址,可以不填 port 1194 绑定的端口

proto tdp 选择udp 协议,也可用tcp

# \# \;dev tap

#使用tun 设备,路由IP 通道。FreeBSD 默认支持TUN/TAP 驱动。 dev tun

#下面4 处填上面为vpn server 生成的证书和密钥

ca /etc/openvpn/ca.crt (如果启动的时候带了cd路径,则这里不需要绝对路径) cert /etc/openvpn/server.crt

key /etc/openvpn/server.key # This file should be kept secret dh /etc/openvpn/dh1024.pem

#配置vpn 虚拟网段,会在vpn server 建立一条10.0.0.1 >10.0.0.2 的点对点虚拟链路。 server 10.8.0.0 255.255.255.0

#记录client 对应得虚拟地址,默认600 秒更新一次 ifconfig-pool-persist ipp.txt

#等价于ping 10 和ping-restart 120,对于vpn 机器有可能断开外网联线或者重起的, #或者vpn client 先于vpn server 运行的情况下很重要。Client 会重新连接。 keepalive 10 120

#开启压缩支持。如果编译的时候没有使用LZO 库则注释本行 #comp-lzo

#初始化完成后改变OpenVPN 进程的用户ID 为nobody user nobody

#同上,改变进程的组ID 为nobody。如果是Windows 系统,注释掉这两行 group nobody persist-key persist-tun

#默认每分钟更新状态文件,可以看到client 的真实IP 虚拟IP 等信息。 status openvpn-status.log verb 3

2、client端

…… 此处隐藏:2588字,全部文档内容请下载后查看。喜欢就下载吧 ……
windows下利用OpenVPN搭建VPN服务器(7).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/435384.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)