自创open vp n windows步骤


Easy Windows Guide?

This page contains a no-frills guide to getting OpenVPN up and running on a Windows server and client(s). For a more detailed understanding of setting up OpenVPN and its advanced features, see the ?HOWTO page.

Table of contents?

  1. Downloading and Installing OpenVPN
  1. Certificates and Keys

2.1 Preparatory Steps

2.2 Building Certificates and Keys

  1. Configuration Files

3.1 Server Config File

3.2 Client Config Files

  1. Copying the Server and Client Files to Their Appropriate Directories
  1. Starting OpenVPN
  1. Further Considerations / Troubleshooting

6.1 Firewall Configuration

6.2 Port Forwarding

6.3 Static Internet IP

6.4 Running OpenVPN as a Service

6.5 Security Tips

Downloading and Installing OpenVPN?

  1. Download the installer from ?here and run it on the server computer.
  1. Install OpenVPN on each client. (This step can be skipped for now and done at any convenient time)

Certificates and Keys?

Preparatory Steps?

  1. Navigate to the C:\Program Files\OpenVPN\easy-rsa folder in the command prompt:

    1. Press Windows Key + R
    2. Type "cmd.exe" and press Enter.
      cmd.exe
      
    3. Navigate to the correct folder:
      cd "C:\Program Files\OpenVPN\easy-rsa"
      
  1. Initialize the OpenVPN configuration:

    init-config
    
    • NOTE: Only run init-config once, during installation.
  1. Open the vars.bat file in a text editor:

    notepad vars.bat
    
  1. Edit the following lines in vars.bat, replacing "US", "CA," etc. with your company‘s information:

    set KEY_COUNTRY=US
    set KEY_PROVINCE=CA
    set KEY_CITY=SanFrancisco
    set KEY_ORG=OpenVPN
    set [email protected]
    
  1. Save the file and exit notepad.
  1. Run the following commands:

    vars
    
    clean-all
    

Building Certificates and Keys?

  1. The certificate authority (CA) certificate and key:

    build-ca
    
    • When prompted, enter your country, etc. These will have default values, which appear in brackets. For your "Common Name," a good choice is to pick a name to identify your company‘s Certificate Authority. For example, "OpenVPN-CA":

      Country Name (2 letter code) [US]:
      State or Province Name (full name) [CA]:
      Locality Name (eg, city) [SanFrancisco]:
      Organization Name (eg, company) [OpenVPN]:
      Organizational Unit Name (eg, section) []:
      Common Name (eg, your name or your server‘s hostname) []:OpenVPN-CA
      Email Address [[email protected]]:
      
  1. The server certificate and key:

    build-key-server server
    
    • When prompted, enter the "Common Name" as "server"
    • When prompted to sign the certificate, enter "y"
    • When prompted to commit, enter "y"
  1. Client certificates and keys:
  1. For each client, choose a name to identify that computer, such as "mike-laptop" in this example.

    build-key mike-laptop
    
    • When prompted, enter the "Common Name" as the name you have chosen (e.g. "mike-laptop")
  2. Repeat this step for each client computer that will connect to the VPN.
  1. Generate Diffie Hellman parameters (This is necessary to set up the encryption)

    build-dh
    

Configuration Files?

  1. Find the sample configuration files:

    Start Menu -> All Programs -> OpenVPN -> OpenVPN Sample Configuration Files
    

Server Config File?

  1. Open server.ovpn
  1. Find the following lines:

    ca ca.crt
    cert server.crt
    key server.key
    
    dh dh1024.pem
    
  1. Edit them as follows:

    ca "C:\\Program Files\\OpenVPN\\config\\ca.crt"
    cert "C:\\Program Files\\OpenVPN\\config\\server.crt"
    key "C:\\Program Files\\OpenVPN\\config\\server.key"
    
    dh "C:\\Program Files\\OpenVPN\\config\\dh1024.pem"
    
  1. Save the file as C:\Program Files\OpenVPN\easy-rsa\server.ovpn

Client Config Files?

This is similar to the server configuration

  1. Open client.ovpn
  1. Find the following lines:

    ca ca.crt
    cert client.crt
    key client.key
    
  1. Edit them as follows:

    ca "C:\\Program Files\\OpenVPN\\config\\ca.crt"
    cert "C:\\Program Files\\OpenVPN\\config\\mike-laptop.crt"
    key "C:\\Program Files\\OpenVPN\\config\\mike-laptop.key"
    
    • Notice that the name of the client certificate and key files depends upon the Common Name of each client.
  1. Edit the following line, replacing "my-server-1" with your server‘s public Internet IP Address or Domain Name. If you need help, see Static Internet IP below.

    remote my-server-1 1194
    
  1. Save the file as C:\Program Files\OpenVPN\easy-rsa\mike-laptop.ovpn (in this example. Each client will need a different, but similar, config file depending upon that client‘s Common Name.)

Copying the Server and Client Files to Their Appropriate Directories?

  1. Copy these files from C:\Program Files\OpenVPN\easy-rsa\ to C:\Program Files\OpenVPN\config\ on the server:

    ca.crt
    dh1024.pem
    server.crt
    server.key
    server.ovpn
    
  1. Copy these files from C:\Program Files\OpenVPN\easy-rsa\ on the server to C:\Program Files\OpenVPN\config\ on each client (mike-laptop, in this example):

    ca.crt
    mike-laptop.crt
    mike-laptop.key
    mike-laptop.ovpn
    

Starting OpenVPN?

  1. On both client and server, run OpenVPN from:

    Start Menu -> All Programs -> OpenVPN -> OpenVPN GUI
    
  1. Double click the icon which shows up in the system tray to initiate the connection. The resulting dialog should close upon a successful start.

Further Considerations / Troubleshooting?

Firewall Configuration?

If you have connection problems, make sure to set a rule on your server‘s firewall allowing incoming traffic on UDP port 1194.

Port Forwarding?

If your server is behind a router, you will need to forward the port chosen for OpenVPN (in this example UDP 1194) to the server. Consult your router‘s documentation for details on this.

To set up port forwarding, you will likely need to set up the server with a static local IP address instead of the default dynamic (changing) IP. Instructions for Windows XP may be found ?here. Make sure to choose a static IP address that is not in the range your router might assign as a dynamic IP, but is within the router‘s subnet (usually 192.168.0.xxx , 10.0.0.xxx , or similar).

Static Internet IP?

Your server will need to have a static internet IP or Domain Name to be accessible over the long term. One solution is to sign up for an account with DynDNS and install the DynDNS Updater on your server. When signing up you will determine the static Domain Name of your server. (For example, "myserver.dyndns.org") You will use this Domain Name in the client configuration files as part of the "remote" directive.

Running OpenVPN as a Service?

Running OpenVPN as a service will allow:

  1. OpenVPN to be run from a non-administrator account.
  1. OpenVPN to be started automatically on system startup. This is often preferred on the server machine, as well as any machines which will be constantly connected to the server.
  1. Run the Windows Service administrative tool:

    1. Press Windows Key + R
    2. Type "services.msc" and press Enter.
      services.msc
      
  1. Find the OpenVPN service, and set its Startup Type to "automatic."
  1. Optionally, start the service now.

Security Tips?

  1. Transmit all needed files to the client computers using a secure means such as a USB drive (email is not always a secure means).
  2. Choose a port other than UDP 1194, and replace the port number wherever this guide mentions UDP port 1194.

Cloning OpenVPN Servers?

If including OpenVPN in a cloned server build you will find that all servers will have the same MAC address for the TAP device. This will cause packet loss across the network. Standard methods of changing the IP address from scripts do not work on the TAP device, to resolve this delete and recreate the TAP device using the scripts included with OpenVPN:

C:\Program Files\OpenVPN\bin\deltapall
C:\Program Files\OpenVPN\bin\addtap

You will then have to rename the connection to match the entry in the config file.

Last modified 4 weeks ago Last modified on 02/01/17 17:06:32

Download in other formats:

  • Plain Text
时间: 2024-12-23 19:39:56

自创open vp n windows步骤的相关文章

Windows API参考大全新编

书名:新编Windows API参考大全 作者:本书编写组 页数:981页 开数:16开 字数:2392千字 出版日期:2000年4月第二次印刷 出版社:电子工业出版社 书号:ISBN 7-5053-5777-8 定价:98.00元 内容简介 作为Microsoft 32位平台的应用程序编程接口,Win32 API是从事Windows应用程序开发所必备的.本书首先对Win32 API函数做完整的概述:然后收录五大类函数:窗口管理.图形设备接口.系统服务.国际特性以及网络服务:在附录部分,讲解如何

Zabbix安装与简单配置

目录 0. 前言 1. 安装 1.1 准备安装环境 1.1.1 下载安装包 1.1.2 修改文件配置 1.2 开始安装 2. 实验环境 2.1 简易拓扑图 2.2 基本配置 3. 配置 0. 前言 不管是在局域网.广域网还是数据中心IDC,一个健康的网络环境,都离不开一套网管系统. 网管系统不限于如下: 监控平台:用于监控网络设备.服务器.中间件等各项指标,超过阈值触发告警通知: 日志平台:用于收集所有设备日志数据.分析.可视化,报警.追溯等功能: 自动化运维平台:用于减少重复性工作,自动化执行

(一)Java使用Protobuf

学习使用Protobuf,创建java文件 windows : 步骤一:两个文件:proto.exe,  protobuf-Java-2.4.1.jar 步骤二:建立一个工程CreateProtoBuf,在下面建立一个proto文件件,用来存放[proto]文件 步骤三:将proto,exe放在工程下, 步骤四:建立一个msg.proto文件: 1 option java_package = "com.protobuftest.protobuf"; 2 option java_oute

挂载与卸载

一.Linux中的硬件设备号     设 备          设 备 号    IDE硬盘         /dev/hd[a-d]   (并行硬盘)    SCSI硬盘        /dev/sd[a-p]   (串行硬盘)    U盘             /dev/sd[a-p]    光驱            /dev/cdrom    软驱            /dev/fd[0-1]    打印机          /dev/lp[0-2]    鼠标           

linux入门基础_centos(二)--fdisk分区

课时10 使用fdisk进行磁盘管理 fdisk是来自IBM的老牌分区工具,支持绝大多数的操作系统,几乎所有的linux的发行版本都装有fdisk,包括在linux的rescue模式下依然可以使用, fdisk是基于MBR的分区工具,所以如果使用GPT,则无法使用fdisk进行分区 注意: fdisk命令只有具有超级超级用户权限才能操作 fdisk -l     可以列出所有安装的硬盘及分区信息 fdisk /dev/sdb     可以对目标磁盘进行分区操作: 实例: 首先,使用     fd

win7怎么设置保护色

步骤1: 在桌面右键,选择红色框内容: 步骤2: 接着上面的步骤:往下点color 步骤3: 选择windows 步骤4: 最后选择确定

Mac pro 装双系统 参考

15岁觉得游泳难,放弃游泳,到18岁遇到一个你喜欢的人约你去游泳,你只好说"我不会耶".18岁觉得英文难,放弃英文,28岁出现一个很棒但要会英文的工作,你只好说"我不会耶".人生前期越嫌麻烦,越懒得学,后来就越可能错过让你动心的人和事,错过新风景.~~~~~[ 康永,给残酷社会的善意短信 ] 新版本Mac 安装 1.准备材料 一个系统镜像 小道下载地址:https://msdn.itellyou.cn/,必须是64位的 您需要 Mac 附带的键盘和鼠标或触控板.(如

DataGrid Web控件深度历险(3) part2

机器学习是一项经验技能,经验越多越好.在项目建立的过程中,实践是掌握机器学习的最佳手段.在实践过程中,通过实际操作加深对分类和回归问题的每一个步骤的理解,达到学习机器学习的目的. 预测模型项目模板不能只通过阅读来掌握机器学习的技能,需要进行大量的练习.本文将介绍一个通用的机器学习的项目模板,创建这个模板总共有六个步骤.通过本文将学到: 端到端地预测(分类与回归)模型的项目结构. 如何将前面学到的内容引入到项目中. 如何通过这个项目模板来得到一个高准确度的模板. 矩喂房捞棕忱行吧艺狙兄咎蓉蹲郎辞镀

Jenkins 持续集成使用教程

Jenkins 持续集成使用教程 用 jenkins 有什么好处 通过规范化来完成,简单,繁琐,浪费时间的重复工作 规范化工作,以免出现低级错误 实现随时随地任何人一键构建 ...... 安装 jenkins 以 Mac 设备为例(Windows 步骤类似),帮你一步一步搭建好 jenkins.jenkins 属于 java 项目 依赖于 java,需要先安装 java jdk,具体安装方式请自行百度. 安装 jenkins 有常用的三种方式. 使用 pgk 安装包安装 在 官网 下载 pgk