chj-frodo

C++博客 首页 新随笔 联系 聚合 管理
  1 Posts :: 1 Stories :: 0 Comments :: 0 Trackbacks

2008年10月29日 #

#################################################
# Sample OpenVPN 2.0 config file for            #
# multi-client server.                          #
#                                               #
# This file is for the server side              #
# of a many-clients <-> one-server              #
# OpenVPN configuration.                        #
#                                               #
# OpenVPN also supports                         #
# single-machine <-> single-machine             #
# configurations (See the Examples page         #
# on the web site for more info).               #
#                                               #
# This config should work on Windows            #
# or Linux/BSD systems.  Remember on            #
# Windows to quote pathnames and use            #
# double backslashes, e.g.:                     #
# "C:\\Program Files\\OpenVPN\\config\\foo.key" #
#                                               #
# Comments are preceded with '#' or ';'         #
#################################################

# 哪一个本地地址将要被OpenVPN进行监听
# Which local IP address should OpenVPN
# listen on? (optional)
;local a.b.c.d

# OpenVPN将要监听哪一个TCP/UDP端口
# Which TCP/UDP port should OpenVPN listen on?
# If you want to run multiple OpenVPN instances
# on the same machine, use a different port
# number for each one.  You will need to
# open up this port on your firewall.
port 1194

# 使用TCP或者UDP
# TCP or UDP server?
;proto tcp
proto udp

# “dev tun”将建立一个路由IP通道
# “dev tap”将建立一个以太网通道。
#  如果你用了以太桥接并且预先建立了一个tap0的虚拟
# 接口,并且把它和你的以太接口进行了桥接,那么使用 "dev tap0"
# 如果你想控制在VPN上的访问策略,那么你必须要为TUN/TAP接口
# 建立防火墙策略。
# 在非window系统上,你可以指定一个显式的单元数字,比如tun0。
# 在windows系统上,使用"dev-node"
# 在绝大多数的系统,在你部分或者全部将针对TUN/TAP接口的防火墙
# 禁止以前,VPN将不会工作。
#
# "dev tun" will create a routed IP tunnel,
# "dev tap" will create an ethernet tunnel.
# Use "dev tap0" if you are ethernet bridging
# and have precreated a tap0 virtual interface
# and bridged it with your ethernet interface.
# If you want to control access policies
# over the VPN, you must create firewall
# rules for the the TUN/TAP interface.
# On non-Windows systems, you can give
# an explicit unit number, such as tun0.
# On Windows, use "dev-node" for this.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun

# 如果你有超过一个的TAP适配器,那么Windows
# 需要通过网络控制面板得到TAP-Win32适配器名字。
# 在XP SP2或者更高版本,你可能需要禁止在TAP适配器
# 上的Windows防火墙。 非windows系统通常不需要这么做。
#
# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel if you
# have more than one.  On XP SP2 or higher,
# you may need to selectively disable the
# Windows firewall for the TAP adapter.
# Non-Windows systems usually don't need this.
;dev-node MyTap

# SSL/TLS根证书(ca),证书(cert),私钥(key)。
# 每一个客户和服务器必须有他们自己的证书和私钥
# 服务器和所有的客户端必须要使用同样的根证书。
#
# 在"easy-rsa" 目录可以看到产生RSA证书和私钥的
# 的脚本。记住对每一个客户和服务器使用一个唯一的
# 名称(Common Name)
#
# 任意的X509 密钥管理系统都可以使用。OpenVPN也
# 能够使用一个PKCS #12格式的密钥文件(可以在man
# 页面参考# "pkcs12" 命令)
#
# SSL/TLS root certificate (ca), certificate
# (cert), and private key (key).  Each client
# and the server must have their own cert and
# key file.  The server and all clients will
# use the same ca file.
#
# See the "easy-rsa" directory for a series
# of scripts for generating RSA certificates
# and private keys.  Remember to use
# a unique Common Name for the server
# and each of the client certificates.
#
# Any X509 key management system can be used.
# OpenVPN can also use a PKCS #12 formatted key file
# (see "pkcs12" directive in man page).
ca ca.crt
cert server.crt
key server.key  # This file should be kept secret


# Diffie hellman参数
# 使用如下命令产生你自己的:
# openssl dhparam -out dh1024.pem 1024
# 如果你要使用2048位密钥,那么将命令中的1024替换为2048
#
# Diffie hellman parameters.
# Generate your own with:
#   openssl dhparam -out dh1024.pem 1024
# Substitute 2048 for 1024 if you are using
# 2048 bit keys.
dh dh1024.pem


# 配置服务模式,并且提供要将提供给客户地址的一个VPN的
# 子网。这个服务器本身将要使用 10.8.0.1地址。客户将使用
# 其余的地址。每一个客户将可以通过  10.8.0.1 到达服务器。
# 如果是你在使用以太网的桥接模式,请将此行注释。
#
# Configure server mode and supply a VPN subnet
# for OpenVPN to draw client addresses from.
# The server will take 10.8.0.1 for itself,
# the rest will be made available to clients.
# Each client will be able to reach the server
# on 10.8.0.1. Comment this line out if you are
# ethernet bridging. See the man page for more info.
server 10.8.0.0 255.255.255.0


# 在这个文件里面维护一个client 到 虚ip的关联。
# 如果OpenVPN进程推出或者重新启动,那么重新连接的
# 客户将被分配到与上次分配的地址一样的虚IP地址上。
#
# Maintain a record of client <-> virtual IP address
# associations in this file.  If OpenVPN goes down or
# is restarted, reconnecting clients can be assigned
# the same virtual IP address from the pool that was
# previously assigned.
ifconfig-pool-persist ipp.txt


# 为“以太桥接”配置服务器模式。
# 你必须首先使用操作系统的桥接功能来把TAP接口和以太
# 网卡(NIC)接口桥接起来。 然后你必须在桥接接口上
# 手动的设置IP/子网掩码,在这里我们假设为10.8.0.4/255.255.255.0
# 最后,我们必须设定一个IP地址范围(start=10.8.0.50 end=10.8.0.100)
# 分配给 将要连接的客户。
# 除非你使用了以太桥接模式,否则将这一行注释保留。
#
# Configure server mode for ethernet bridging.
# You must first use your OS's bridging capability
# to bridge the TAP interface with the ethernet
# NIC interface.  Then you must manually set the
# IP/netmask on the bridge interface, here we
# assume 10.8.0.4/255.255.255.0.  Finally we
# must set aside an IP range in this subnet
# (start=10.8.0.50 end=10.8.0.100) to allocate
# to connecting clients.  Leave this line commented
# out unless you are ethernet bridging.
;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100

# 将路由Push给客户,以便允许客户可以访问在这个服务器后的
# 私有子网。记住:这些私有子网也同样需要知道将OpenVPN的客户
# 地址 (10.8.0.0/255.255.255.0)路由回OpenVPN服务器。
#
# Push routes to the client to allow it
# to reach other private subnets behind
# the server.  Remember that these
# private subnets will also need
# to know to route the OpenVPN client
# address pool (10.8.0.0/255.255.255.0)
# back to the OpenVPN server.
;push "route 192.168.10.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"


# 要把分配一个特定的IP地址给一个特定的客户 或者
# 如果一个连接的客户有一个私有的子网,并且这个子网也需要
# 进行VPN的访问, 那么使用ccd目录作为存放 特定客户配置文件的目录。
# To assign specific IP addresses to specific
# clients or if a connecting client has a private
# subnet behind it that should also have VPN access,
# use the subdirectory "ccd" for client-specific
# configuration files (see man page for more info).


# 例如: 假设一个证书common name为"Thelonious"的客户
# 在他连接VPN的机器上还有诸如“192.168.40.128/255.255.255.248”
# 的一个小的子网
# 第一步: 将下面的这些注释去除
;client-config-dir ccd
;route 192.168.40.128 255.255.255.248
# 然后建立一个文件内容包含下面这行的 ccd/Thelonious文件
#   iroute 192.168.40.128 255.255.255.248
# 这将允许Thelonious的私有子网访问VPN。这个例子将仅仅在
# 你在routing模式,而不是bridging模式下工作,比如你正在
# 使用“dev tun” 和“server” 命令
#
# EXAMPLE: Suppose the client
# having the certificate common name "Thelonious"
# also has a small subnet behind his connecting
# machine, such as 192.168.40.128/255.255.255.248.
# First, uncomment out these lines:
;client-config-dir ccd
;route 192.168.40.128 255.255.255.248
# Then create a file ccd/Thelonious with this line:
#   iroute 192.168.40.128 255.255.255.248
# This will allow Thelonious' private subnet to
# access the VPN.  This example will only work
# if you are routing, not bridging, i.e. you are
# using "dev tun" and "server" directives.


#例如:如何给一个客户每次分配一个固定的IP的地址
# EXAMPLE: Suppose you want to give
# Thelonious a fixed VPN IP address of 10.9.0.1.
# First uncomment out these lines:
;client-config-dir ccd
;route 10.9.0.0 255.255.255.252
# Then add this line to ccd/Thelonious:
#   ifconfig-push 10.9.0.1 10.9.0.2

# 假设你想为不同的组或者客户制定不同的防火墙策略
# Suppose that you want to enable different
# firewall access policies for different groups
# of clients.  There are two methods:
# (1) Run multiple OpenVPN daemons, one for each
#     group, and firewall the TUN/TAP interface
#     for each group/daemon appropriately.
# (2) (Advanced) Create a script to dynamically
#     modify the firewall in response to access
#     from different clients.  See man
#     page for more info on learn-address script.
;learn-address ./script

# 如果设定了这个选选,那个它会将所有客户的缺省网关
# 设定为VPN,引起所有的IP通讯诸如web浏览,DNS查询将
# 会通过VPN。(为了让让这些工作正常,OpenVPN服务器
# 可能需要进行转发 (NAT) TUN/TAP接口到Internet)
# 警告: 如果客户本地的DHCP服务器的数据包被路由道了
# VPN通道,这可能会破坏客户的网络配置。 解决方案:确保
# 客户本地的DHCP服务器可以通过一个比缺省路由0.0.0.0/0.0.0.0
# 更加具体的route设定到达。
#
# If enabled, this directive will configure
# all clients to redirect their default
# network gateway through the VPN, causing
# all IP traffic such as web browsing and
# and DNS lookups to go through the VPN
# (The OpenVPN server machine may need to NAT
# the TUN/TAP interface to the internet in
# order for this to work properly).
# CAVEAT: May break client's network config if
# client's local DHCP server packets get routed
# through the tunnel.  Solution: make sure
# client's local DHCP server is reachable via
# a more specific route than the default route
# of 0.0.0.0/0.0.0.0.
;push "redirect-gateway"

# 某些windows特定的网络设置诸如DND或者WINS服务器地址
# 可以push到客户端。
# Certain Windows-specific network settings
# can be pushed to clients, such as DNS
# or WINS server addresses.  CAVEAT:
# http://openvpn.net/faq.html#dhcpcaveats
;push "dhcp-option DNS 10.8.0.1"
;push "dhcp-option WINS 10.8.0.1"


#将下面这个注释去掉可以允许不同的客户可以相互可见
# Uncomment this directive to allow different
# clients to be able to "see" each other.
# By default, clients will only see the server.
# To force clients to only see the server, you
# will also need to appropriately firewall the
# server's TUN/TAP interface.
;client-to-client

# 如果要允许不同的客户使用相同的certificate/key或者
# 相同的common name,那么可以将下面的注释去除。
# 这种情况一般推荐在测试情况下使用。如果是产品目的使用
# 每一个client应该有个他自己的证书/秘钥
# Uncomment this directive if multiple clients
# might connect with the same certificate/key
# files or common names.  This is recommended
# only for testing purposes.  For production use,
# each client should have its own certificate/key
# pair.
#
# IF YOU HAVE NOT GENERATED INDIVIDUAL
# CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
# EACH HAVING ITS OWN UNIQUE "COMMON NAME",
# UNCOMMENT THIS LINE OUT.
;duplicate-cn

# The keepalive directive causes ping-like
# messages to be sent back and forth over
# the link so that each side knows when
# the other side has gone down.
# Ping every 10 seconds, assume that remote
# peer is down if no ping received during
# a 120 second time period.
# 设定每次ping间格10秒,如果120秒内没有收到
# 回应,则认为对方已经down机
keepalive 10 120


#如果需要除了已经提供的SSL/TLS以外的的安全性
# 可以建立一个“HMAC firewall”来帮助抵御大量的
# Dos攻击和UDP端口洪水攻击
# For extra security beyond that provided
# by SSL/TLS, create an "HMAC firewall"
# to help block DoS attacks and UDP port flooding.
#
# Generate with:
#   openvpn --genkey --secret ta.key
#
# The server and each client must have
# a copy of this key.
# The second parameter should be '0'
# on the server and '1' on the clients.
;tls-auth ta.key 0 # This file is secret

#选择加密算法,这个选项也必须被copy到客户端的配置文件
# Select a cryptographic cipher.
# This config item must be copied to
# the client config file as well.
;cipher BF-CBC        # Blowfish (default)
;cipher AES-128-CBC   # AES
;cipher DES-EDE3-CBC  # Triple-DES

# 允许在VPN链接上进行压缩。如果服务器端压缩
# 选项打开,那么客户端的配置文件里面也应该打开。
# Enable compression on the VPN link.
# If you enable it here, you must also
# enable it in the client config file.
comp-lzo

# 设定允许的最大的客户端并发数。
# The maximum number of concurrently connected
# clients we want to allow.
;max-clients 100

# 在完成初始化后可以减少OpenVPN后台进程的权限是个
# 非常好的主意。
# 在非windows的系统上可以将下面的2行注释符去除。
# It's a good idea to reduce the OpenVPN
# daemon's privileges after initialization.
#
# You can uncomment this out on
# non-Windows systems.
;user nobody
;group nobody

# The persist options will try to avoid
# accessing certain resources on restart
# that may no longer be accessible because
# of the privilege downgrade.
persist-key
persist-tun

# 输出一个小的状态文件,包括当前的连接情况,
# 每分钟更新这个文件。
# Output a short status file showing
# current connections, truncated
# and rewritten every minute.
status openvpn-status.log


#设定日子文件的输出方式
# By default, log messages will go to the syslog (or
# on Windows, if running as a service, they will go to
# the "\Program Files\OpenVPN\log" directory).
# Use log or log-append to override this default.
# "log" will truncate the log file on OpenVPN startup,
# while "log-append" will append to it.  Use one
# or the other (but not both).
;log         openvpn.log
;log-append  openvpn.log

# 日子级别
# Set the appropriate level of log
# file verbosity.
#
# 0 is silent, except for fatal errors
# 4 is reasonable for general usage
# 5 and 6 can help to debug connection problems
# 9 is extremely verbose
verb 3

# Silence repeating messages.  At most 20
# sequential messages of the same message
# category will be output to the log.
;mute 20

posted @ 2008-10-29 16:21 frodo 阅读(163) | 评论 (0)编辑 收藏

仅列出标题