首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 冲浪宝典 > 冲浪技巧 > OpenVPN Install
【标  题】:OpenVPN Install
【关键字】:OpenVPN,Install
【来  源】:http://www.cublog.cn/u/21072/showart.php?id=142479

OpenVPN Install

译者:温占考(Email: wzk<AT>wenzk<DOT>net),来源:OpenVPN.net,转载请注明译者和出处及版权信息,并且不能用于商业用途,违者必究。
由于英语水平有限,如有错误,还望指正!
时间: 2006-06-19 11:00 于 沈阳

在源代码包中的INSTALL文件

OpenVPN安装手册,一个安全隧道程序

Copyright (C) 2002-2005 OpenVPN Solutions LLC.这是一个自由软件;

你可以在遵循自由软件基金会发布的GNU通用公开许可版本2下重新发布/修改本软件。

*************************************************************************

下载OpenVPN

 

        http://openvpn.net/download.html

 

互联网上按部就班的安装说明:

 
        http://openvpn.net/howto.html

 
例子:

 
        http://openvpn.net/examples.html

 

*************************************************************************

 

支持的平台:

  (1) Linux 2.2+

  (2) Solaris

  (3) OpenBSD 3.0+ (默认支持 OpenSSL TUN 设备)

  (4) Mac OS X Darwin

  (5) FreeBSD

  (6) NetBSD

  (7) Windows (Win 2K 或更高版本)


支持的处理器架构:

   一般说来,OpenVPN与字长度和字节序无关,所以支持大部分的处理器。支持的架构包括 Intel x86AlphaSparcAmd64 ARM

 

必须的:

  (1) TUN / TAP 驱动允许用户空间程序控制一个虚拟点对点IP或以太网设备。查看 TUN/TAP 驱动配置章节以获得更多信息。

 

可选择的(但是推荐支持):

  (1) OpenSSL库,加密所必须的库文件,0.9.5或更高版本,可以从http://www.openssl.org/ 获得。

  (2) LZO 实时压缩库,链路压缩所必须的库文件,可以从 http://www.oberhumer.com/opensource/lzo/ 获得。

      OpenBSD用户可以通过portspackages来安装lzo,但是在"configure"时别忘记增加"--with-lzo-headers" "--with-lzo-lib" 选项,分别指向/usr/local/include /usr/local/lib ,否则gcc将会找不到他们。

  (3) Pthread 库。

 

可选的 (仅供开发者):

  (1) Autoconf 2.50 或更高版本 + Automake 1.5 或更高版本

      -- 可以从 http://www.gnu.org/software/software.html 获得

  (2) Dmalloc

      -- 可以从 http://dmalloc.com/ 获得

 

*************************************************************************

 

TAR包编译安装:

 

        ./configure

        make

        make install

 

*************************************************************************

 

CVS中获取代码编译安装:

 

        autoreconf -i -v

        ./configure

        make

        make install

 

*************************************************************************

 

CVS上获取代码创建一个TAR包:

 

        autoreconf -i -v

        ./configure

        make dist

 

*************************************************************************

 

回环测试(编译后):

 

make check (运行下面的所有测试)

 

测试加密:

 

./openvpn --genkey --secret key

./openvpn --test-crypto --secret key

 

测试 SSL/TLS 协商 (运行2分钟):

 

./openvpn --config sample-config-files/loopback-client  (在一个窗口中运行)

./openvpn --config sample-config-files/loopback-server  (同时在另一个窗口中运行)

 

*************************************************************************

 

./configure的参数:

 

  --enable-pthread          编译支持 pthread 来缩短SSL/TLS 密钥

协商时间(仅支持Linux Solaris

 

  --disable-lzo             关闭 LZO 压缩支持

  --disable-crypto          关闭 OpenSSL 加密支持

  --disable-ssl             关闭 OpenSSL 基于TLS的密钥交换支持

 

  --with-ssl-headers=DIR    Crypto/SSL 头文件位置

  --with-ssl-lib=DIR        Crypto/SSL 库文件位置

  --with-lzo-headers=DIR    LZO 头文件文职

  --with-lzo-lib=DIR        LZO 库文件位置

 

  --with-ifconfig-path=PATH   ifconfig路径(仅当不在默认路径时

需要申明)

 

  --with-leak-check=TYPE    编译支持内存泄漏检查

                            TYPE = dmalloc ssl

 

  --enable-strict           使能严谨的编译器警告

 

  --enable-strict-options   使能严谨的邻居间选项检查

 

*************************************************************************

 

LINUX 2.4+中编译成RPM

 

你可以直接使用OpenVPN tar包编译成RPM二进制包:

 

        rpmbuild -tb [tarball]

 

这个命令将会创建一个二进制RPM文件并且存放在系统RPM目录下。你能安装RPM文件通过RPM安装命令:

 

        rpm -ivh [binary-rpm]

 

当你安装二进制RPM文件,它将会安装sample-scripts/openvpn.init文件,这个文件可以在系统启动和关闭时自动启动和停止一个或多个OpenVPN隧道,操作的依据是 /etc/openvpn 目录下的OpenVPN .conf配置文件。

通过查看openvpn.init文件中的注释来了解更多的信息。

 

Linux 2.4中使用RPM安装同时也会自动配置节点的 TUN/TAP设备。

 

需要注意的是目前所使用的openvpn.spec文件,rpm工具编译的指示文件,编译OpenVPN是将会使能所有选项,包括OpenSSLLZOpthread连接。因此这些包必须在编译前预先安装,除非你手工编辑openvpn.spec文件。

 

*************************************************************************

 

TUN/TAP驱动配置:

 

* Linux 2.4 或更高版本 (内置TUN/TAP驱动):

 

  (1)  创建设备文件:           mknod /dev/net/tun c 10 200

  (2a) 增加到/etc/modules.conf文件: alias char-major-10-200 tun

       [译者注:部分系统可能是/etc/modprobe.conf]

  (2b) 加载驱动:               modprobe tun

  (3)  使能路由功能:           echo 1 > /proc/sys/net/ipv4/ip_forward

 

需要注意的是无论是步骤(2a)或步骤(2b)都是足够的。然而(2a)仅仅需要在安装前操作一次,(2b)每次重新启动系统后都需要操作。如果你使用RPM(如前所述)安装并且使用openvpn.init脚本,这些步骤将自动为您完成。

 

* Linux 2.2 Solaris

 

  你应到先获得TUN/TAP版本1.1驱动

  http://vtun.sourceforge.net/tun/

  并且按照安装说明进行安装。

 

  如果你在Linux 2.2 2.4 Solaris上运行OpenVPN,你可能会遇到重负载的时候连接速度变慢的bug。这症状和OpenVPN邮件列表中经常讨论的MTU问题很类似。但是这个bug并不是由于MTU问题引起的。那是TUN/TAP驱动的bug。这个有一个补丁文件:

 

  http://openvpn.net/patch/tun-sb.patch

 

* Solaris

 

  64位系统, 使用 tun-1.1.tar.gz 源代码编译。

 

  当然,这里有一个bug :)

  tun-1-1\solaris\Makefile 文件中需要修改一行来使之能用64位编译器

 

  CFLAGS = $(DEFS) -m64 -O2 -Wall -D_KERNEL -I.

 

  我只增加了-m64 然后就可以正常编译了。

 

  TUN驱动正如我们先前说的工作得很正常,然而我们注意到在Solaris系统上创建多个隧道时会有一个小问题。

Tycho Fruru 修改tun.c的代码锁定tun设备数量为-1。这样就可以指定tun设备的名字了。然而这样仍然是可以创建多个tun设备的。

这个修改使得tun名自动增长从tun0 ---> tunX,如果你认为这个修改对你有用,你能免费使用它。

 

  http://openvpn.net/solaris/tun.c

 

* FreeBSD 4.1.1+:

 

  FreeBSD带有TUN/TAP驱动,并且默认创建tap0tap1tap2tap3tun0tun1tun2,和tun3设备节点。

  然而,仅仅只有TUN驱动是直接编译到GENERIC内核中。

  需要加载TAP驱动,输入:

 

 

        kldload if_tap

 

  查看rc(8)的手册以查找如何在开机的时候执行此命令。

 

  FreeBSD上安装OpenVPN最简单的方法是使用ports系统,port包括一个脚本例子关于如何在启动的时候加载TAP驱动。

* OpenBSD:

  OpenBSD3.5以前版本带有tun0tun1并且默认加载,然而3.5和更高版本动态创建tun*设备,所以你仅仅需要创建一个空的/etc/hostname.tun0 (tun1,tun2等等)文件来创建启动时需要创建的TUN设备。

* Mac OS X:

  2005.02.13: Angelo Laub 开发了一个MAC OS X上的图形界面:

  http://rechenknecht.net/OpenVPN-GUI/

  2004.10.26: Mattias Nissler MAC OS X开发了一个新的 TUN/TAP 驱动:

  http://www-user.rhrk.uni-kl.de/~nissler/tuntap/   

  Christoph Pfisterer 的旧版本的TUN驱动可以从  http://chrisp.de/en/projects/tunnel.html 获得 -- 停止开发。

* Solaris9 Sparc/64

  Solaris的内核模块可以通过增加-m64开关以支持新的gcc编译器(我使用3.2),编译后的内核驱动需要手动复制到/kernel/drv/sparcv9/并且重新启动系统以重新配置。(boot -r

* Windows 2000 XP

  查看INSTALL-win32.txt获得更多信息

查看man页面以获得更多信息,使用例子,和防火墙配置信息。

*************************************************************************

 

告诫&漏洞:

 

* 我注意到Linux TAP驱动(内核2.4.212.4.22)使用TCP对话建立会话,如果--mssifx使用了一个比较小值时会引起会话停止。TCP会话表现为VPN对端ping正常的情况下也会有停止和重新连接的现象。

 

* 如果使用OpenBSD包过滤PF构建的防火墙并且过滤规则中包含“scrub”指令,你通过隧道和Linux系统通信可能会有问题,因为scrubbing将会丢弃从Linux主机发送的分片包。这种现象通常表现为小包和ping报文可以通过但是大包和“正常的流量”将不能通过。为了避免这个情况,增加“no-df”scrub指令,这样包过滤器(PF)将会让分片使用“不分片”标志并且让其通过。

 

* 不建议OFB CFB 加密算法和静态密钥混合使用,并且在OpenVPN版本1.2.1和更高版本将会提示错误。如果你使用--cipher 选项明确的选择使用 OFB CFB 加密算法并且你使用的时静态密钥方式,当两端的OpenVPN程序在刚好在同一个时间发起连接可能会导致IV冲突,因为OpenVPN使用时间戳和一个顺序号作为OFB CFBIV加密算法,如果你使用的时CBC(默认)加密算法,或者你使用OFBCFB加密算法配置SSL/TSL验证将不存在这个问题。


Openvpn.spec文件,用来创建RPM二进制文件包

# OpenVPN spec file, used to drive rpmbuild

 

# OPTIONS

#

# Disable LZO

#   rpmbuild -tb [openvpn.x.tar.gz] --define 'without_lzo 1'

#

# Disable PAM plugin

#   rpmbuild -tb [openvpn.x.tar.gz] --define 'without_pam 1'

#

# Allow passwords to be read from files

#   rpmbuild -tb [openvpn.x.tar.gz] --define 'with_password_save 1'

#

# Use this on RH9 and RHEL3

#   rpmbuild -tb [openvpn.x.tar.gz] --define 'with_kerberos 1'

 

Summary:       OpenVPN is a robust and highly flexible VPN daemon by James Yonan.

Name:           openvpn

Version:        2.0.7

Release:       1

URL:           http://openvpn.net/

Source0:       http://prdownloads.sourceforge.net/openvpn/%{name}-%{version}.tar.gz

 

License:       GPL

Group:         Applications/Internet

Vendor:        James Yonan <jim@yonan.net>

Packager:      James Yonan <jim@yonan.net>

BuildRoot:     %{_tmppath}/%{name}-%(id -un)

 

#

# Include dependencies manually

#

 

AutoReq: 0

 

BuildRequires: openssl-devel >= 0.9.6

Requires:      openssl       >= 0.9.6

 

%if "%{_vendor}" == "Mandrakesoft"

%{!?without_lzo:BuildRequires: liblzo1-devel >= 1.07}

%{!?without_lzo:Requires:      liblzo1       >= 1.07}

%else

%if "%{_vendor}" == "MandrakeSoft"

%{!?without_lzo:BuildRequires: liblzo1-devel >= 1.07}

%{!?without_lzo:Requires:      liblzo1       >= 1.07}

%else

%{!?without_lzo:BuildRequires: lzo-devel >= 1.07}

%{!?without_lzo:Requires:      lzo       >= 1.07}

%endif

%endif

 

%{!?without_pam:BuildRequires: pam-devel}

%{!?without_pam:Requires:      pam}

 

#

# Description

#

 

%description

OpenVPN is a robust and highly flexible VPN daemon by James Yonan.

OpenVPN supports SSL/TLS security,

ethernet bridging,

TCP or UDP tunnel transport through proxies or NAT,

support for dynamic IP addresses and DHCP,

scalability to hundreds or thousands of users,

and portability to most major OS platforms.

 

#

# Define vendor type

#

 

%if "%{_vendor}" == "suse" || "%{_vendor}" == "pc"

%define VENDOR SuSE

%else

%define VENDOR %_vendor

%endif

 

#

# Should we build the auth-pam module?

#

 

%define build_auth_pam 1

%{?without_pam:%define build_auth_pam 0}

 

#

# Other definitions

#

 

%define debug_package %{nil}

 

#

# Build OpenVPN binary

#

 

%prep

%setup -q

 

%build

%configure --disable-dependency-tracking %{?with_password_save:--enable-password-save} %{?without_lzo:--disable-lzo} %{?with_kerberos:--with-ssl-headers=/usr/kerberos/include}

%__make

%__strip %{name}

 

# Build down-root plugin

pushd plugin/down-root

%__make

popd

 

# Build auth-pam plugin

%if %{build_auth_pam}

pushd plugin/auth-pam

%__make

popd

%endif

 

#

# Installation section

#

 

%install

[ %{buildroot} != "/" ] && rm -rf %{buildroot}

 

# Install man page

%__install -c -d -m 755 %{buildroot}%{_mandir}/man8

%__install -c -m 755 %{name}.8 %{buildroot}%{_mandir}/man8

 

# Install binary

%__install -c -d -m 755 %{buildroot}%{_sbindir}

%__install -c -m 755 %{name} %{buildroot}%{_sbindir}

 

# Install init script

%if "%{VENDOR}" == "SuSE"

%__install -c -d -m 755 %{buildroot}/etc/init.d

%__sed -e 's#openvpn=\"/usr/local/sbin/openvpn\"#openvpn=\"/usr/sbin/openvpn\"#' < suse/%{name}.init > %{_tmppath}/%{name}.init

%__install -c -m 755 %{_tmppath}/%{name}.init %{buildroot}/etc/init.d/%{name}

%__rm %{_tmppath}/%{name}.init

%else

%__install -c -d -m 755 %{buildroot}/etc/rc.d/init.d

%__install -c -m 755 sample-scripts/%{name}.init %{buildroot}/etc/rc.d/init.d/%{name}

%endif

 

# Install /etc/openvpn

%__install -c -d -m 755 %{buildroot}/etc/%{name}

 

#

# Build /usr/share/openvpn

#

 

%__mkdir_p %{buildroot}%{_datadir}/%{name}

 

#

# Install the plugins

#

 

%__mkdir_p %{buildroot}%{_datadir}/%{name}/plugin/lib

 

for pi in auth-pam down-root; do

  %__mv -f plugin/$pi/README plugin/README.$pi

  if [ -e plugin/$pi/openvpn-$pi.so ]; then

    %__install -c -m 755 plugin/$pi/openvpn-$pi.so %{buildroot}%{_datadir}/openvpn/plugin/lib/openvpn-$pi.so

  fi

done

 

%__mv -f plugin/README plugin/README.plugins

 

#

# Clean section

#

 

%clean

[ %{buildroot} != "/" ] && rm -rf %{buildroot}

 

#

# On Linux 2.4, make the device node

#

 

%post

case "`uname -r`" in

2.4*)

        /bin/mkdir /dev/net >/dev/null 2>&1

        /bin/mknod /dev/net/tun c 10 200 >/dev/null 2>&1

        ;;

esac

 

#

# Handle the init script

#

 

/sbin/chkconfig --add %{name}

%if "%{VENDOR}" == "SuSE"

/etc/init.d/openvpn restart

%else

/sbin/service %{name} condrestart

%endif

%preun

if [ "$1" = 0 ]

then

        %if "%{VENDOR}" == "SuSE"

        /etc/init.d/openvpn stop

        %else

        /sbin/service %{name} stop

        %endif

        /sbin/chkconfig --del %{name}

fi

 

#

# Files section

#

 

%files

%defattr(-,root,root)

%doc AUTHORS ChangeLog COPYING COPYRIGHT.GPL INSTALL NEWS PORTS README

%{_mandir}/man8/%{name}.8*

%{_sbindir}/%{name}

%{_datadir}/%{name}

%dir /etc/%{name}

%if "%{VENDOR}" == "SuSE"

/etc/init.d/%{name}

%else

/etc/rc.d/init.d/%{name}

%endif

 

# Install extra %doc stuff

%doc contrib/ easy-rsa/ management/ sample-*/ plugin/README.*

 

%changelog

 

* Mon Aug 2 2005 James Yonan

- Fixed build problem with --define 'without_pam 1'

 

* Mon Apr 4 2005 James Yonan

- Moved some files from /usr/share/openvpn to %doc for compatibility

  with Dag Wieers' RPM repository

 

* Sat Mar 12 2005 Tom Walsh

- Added MandrakeSoft liblzo1 require

 

* Fri Dec 10 2004 James Yonan

- Added AutoReq: 0 for manual dependencies

 

* Fri Dec 10 2004 James Yonan

- Packaged the plugins

 

* Sun Nov 7 2004 Umberto Nicoletti

- SuSE support

 

* Wed Aug 18 2004 Bishop Clark (LC957) <bishop@platypus.bc.ca>

- restrict what we claim in /etc/ to avoid ownership conflicts

 

* Sun Feb 23 2003 Matthias Andree <matthias.andree@gmx.de> 1.3.2.14-1.

- Have the version number filled in by autoconf.

 

* Wed Jul 10 2002 James Yonan <jim@yonan.net> 1.3.1-1

- Fixed %preun to only remove service on final uninstall

 

* Mon Jun 17 2002 bishop clark (LC957) <bishop@platypus.bc.ca> 1.2.2-1

- Added condrestart to openvpn.spec & openvpn.init.

 

* Wed May 22 2002 James Yonan <jim@yonan.net> 1.2.0-1

- Added mknod for Linux 2.4.

 

* Wed May 15 2002 Doug Keller <dsk@voidstar.dyndns.org> 1.1.1.16-2

- Added init scripts

- Added conf file support

 

* Mon May 13 2002 bishop clark (LC957) <bishop@platypus.bc.ca> 1.1.1.14-1

- Added new directories for config examples and such

 

* Sun May 12 2002 bishop clark (LC957) <bishop@platypus.bc.ca> 1.1.1.13-1

- Updated buildroot directive and cleanup command

- added easy-rsa utilities

 

* Mon Mar 25 2002 bishop clark (LC957) <bishop@platypus.bc.ca> 1.0-1

- Initial build.


Copyright © 2002-2005 by OpenVPN Solutions LLC <info@openvpn.net>. OpenVPN is a trademark of OpenVPN Solutions LLC.

BGP的路径选择过程。:【上一篇】
QQ 3D表情:【下一篇】
【相关文章】
  • 基于linux操作系统架构openvpn总结
  • install db2 for solaris:一个不是很冲动想法
  • Installing Oracle 9i on RedHat Linux 7.1, 7.2, 7.3
  • 关于openvpn
  • Fedora Core 5 Linux Installation Notes
  • OpenVPNTM Static Key Mini-HOWTO
  • OpenVPNM Install
  • RT73 install failure
  • OpenVPNTM
  • Installing Oracle 9i on Red Hat Enterprise Linux
  • 【随机文章】
  • IP网络设计系列之--IP地址管理
  • 这是一种经历
  • ASP教程:第十四篇 ActiveX 组件
  • 监视注册表写操作的钩子
  • Solaris系统管理培训(第十四章:文件系统挂接)
  • Gmail服务器出问题了
  • 文本到二进制的转换控件,(用于加密)
  • C&C++标准库学习--参考
  • iBATIS和Spring在WEB开发中的应用(三)
  • Maya制作《湖南新闻联播》片头(3)
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.