⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cipe.texinfo

📁 cipe 编程
💻 TEXINFO
📖 第 1 页 / 共 5 页
字号:
(This section is only relevant to readers who want to understand thesource, not to the regular user.)The module consists of an output driver, an input driver, theencapsulation routines and some stuff to keep it all together. Theoutput driver is largely an adapted version of @code{new_tunnel} from@cindex tunnel driverthe Linux distribution. @footnote{From Linux 2.2 on, this has been mergedinto the @code{ipip} module, but the functionality is the same.}In Linux 2.0 its actual packet sending is done via the@cindex Kernel IP forwarding optionkernel IP forwarding engine. This implies that (a) forwarding must beenabled in the kernel and (b) the encrypted packets, being UDP packetswith the source/dest addresses given as "me" and "peer", are checked@cindex firewall rulesagainst the forwarding (as well as the output) firewall. (If itdoesn't work for you, first make sure that your firewall rules let thepackets pass!)The input driver is an adaptation from the kernel UDP receiver. Toactivate it, ciped has to set a socket into a special mode with an@code{ioctl} call. This has to be a connected UDP socket. The@code{ioctl_attach(2cipe)} call replaces the socket's @code{sendto(2)} and@code{recvfrom(2)} operations with special versions that do decryptionof traffic internally and only pass key exchange blocks to the userlayer. The whole work of decrypting and rerouting incoming traffic isdone inside a blocking @code{recvfrom(2)}. This means that unlikenormal IP forwarding, it is called from user mode and the needed CPUtime is charged to the ciped process, although the data never passesinto user mode. @code{sendto(2)} encodes the block as a key exchangeblock and sends it to the peer. The socket should not use@code{read(2)}, @code{write(2)}, @code{select(2)} or nonblocking mode(yet).Before attaching the socket, the operational parameters of the devicehave to be set using a @code{ioctl_setpar(2cipe)} call. The key exchangeprocess supplies keys to the kernel via @code{ioctl_setkey(2cipe)}.The netdevice can only be opened (configured "UP") if it has acontrolling socket. When the controlling socket is closed, the netdevicegets closed. Conversely, closing the netdevice (with @code{ifconfig(8)})closes the socket too. Closing deletes all information that is set byciped on the device.Devices can be dynamically allocated and deallocated using a@code{ioctl_alloc(2cipe)} call. The first device always remainsallocated as a hook for the @code{ioctl} calls.@c --------------------------------------------------------------------------@node Installation, Configuration, Introduction, Top@chapter        Installing the CIPE software package@cindex Obtaining the CIPE packageThe CIPE software package is available via the WWW from @*@url{http://sites.inka.de/~bigred/devel/cipe.html}. It is distributed ina @code{tar.gz} file, currently about 138k in size. After unpacking thedistribution, run the @command{configure} script, possibly specifyingoptions there. Then run @command{make}.@menu* Prerequisites::       What you need before installing.* Protocols and ciphers::  Important compile-time options to select.* Advanced compiling::  Configuring the compile for different targets.* Install::             Compiling and installing the software.* Compilation errors::  If something goes wrong.* Run::                 Running the software.@end menu@node Prerequisites, Protocols and ciphers, Installation, Installation@section        Prerequisites@cindex Kernel versionsCIPE runs under Linux 2.0.* since 2.0.12, 2.1.* since about 2.1.103,2.2.*, 2.3.* since 2.3.48, 2.4.*, and 2.6.*.It was developed for the i386 architecture; other architectures@emph{should} work.@cindex Compiling modulesMake sure you have the complete source tree of the running kernelinstalled (usuallyin @file{/usr/src/linux}). The version @emph{and configuration} of thekernel sources must match the kernel on which it will run exactly,or else you riskbuilding a module which crashes.You also have to use the same compiler version than the one with whichthe kernel was compiled.After reconfiguring and rebuilding thekernel, don't forget to rebuild the CIPE module too. (This applies to allexternally compiled modules.) Enabling "versioned symbols" on the kernelis strongly recommended, because it protects against version skewbetween kernel and modules.@cindex Kernel IP forwarding optionThe kernel needs "IP Forwarding/Gatewaying" enabled in the configurationfor 2.0 kernels. Make sure to enable IP forwarding with@exampleecho 1 > /proc/sys/net/ipv4/ip_forward@end exampleon system boot with 2.2 or later and recent 2.0 kernels. The @code{urandom}device must be available.For kernels that have it (i.e. 2.4.22 upwards or 2.6), the option "CRC32functions" under "Library routines" should be enabled.A suited version of the module utilities (@command{modprobe} and friends)needs to be installed. When in doubt, consult the documentation in thekernel source.The PKCIPE tool needs the OpenSSL package, version 0.9.6 or later. Ifthis is not available, the rest of the CIPE package can still becompiled and installed as usual.@cindex OpenSSLSince version 1.3, CIPE uses an autoconf-generated configure script toconfigure its Makefiles. This script takes the following parameters onthe command line. All of the parameters have defaults which shouldsuffice for a simple installation.@table @samp@item --with-linux=dirPath to the Linux source tree (e.g., @samp{/usr/src/linux}).Using an include tree without complete source is no longer supported, asnewer Linux versions need the kernel's build infrastructure.@file{Makefile} parameters are also used.@item --with-obj=dirPath to the Linux compile tree. When the Linux kernel has beencompiled in a separate object directory (possible since Linux 2.6),this parameter has to be given in addition to @code{--with-linux}.@item --with-ssl-includes=dirPath to the OpenSSL includes, if the script can not find it.@item --with-ssl-libs=dirPath to the OpenSSL libraries, if the script can not find it.@item --enable-protocol=nUse encapsulation protocol @samp{n}. The supported values in CIPE 1.5are 3 and 4. @xref{Protocols and ciphers}, for how to choose the right one.The default is 3.@item --enable-cryptoapiUse the new cryptographic API of Linux 2.4.22 or later or 2.6.@item --disable-debugDisable debugging code in kernel module. Not really useful.@item --disable-dyndevDisable dynamic device allocation. Not really useful.@item --enable-logfacility=xSet syslog facility for @command{ciped} and @command{pkcipe}(default and usually right is LOG_DAEMON).@item --disable-asmDisable use of assembler code. Not really useful.@item --enable-name=nSet a name suffix for the compilation directory.@item --enable-bug-compatibleUse old, broken interpretation of keys. @xref{Keys in older CIPE}.@item --disable-send-configDo not send configuration information to the peer. This is normallysent on startup to help diagnose mismatches, but it is sent unencrypted,which may be unwanted.@item --disable-pkcipeDo not compile and install the PKCIPE tool.@end tableThe script then looks for certain parameters (like whether compiling foran SMP system) in the kernel headers, and it creates a new directorynamed like @code{2.2.6-i386-cb} in which compilation of the module anddaemon will take place. (This would be for Linux 2.2.6 on i386, protocol3 [the "c"], Blowfish [the "b"].)The PKCIPE tool and some library components are built in their sourcedirectories, they do not depend on configuration (in theory;unfortunately @command{pkcipe} is still tied to the particular@command{ciped} in use, but this is going to be fixed).@node Protocols and ciphers, Advanced compiling, Prerequisites, Installation@section        Protocols and ciphersCIPE supports different versions of the encryption protocol, which inturn can be used with different ciphers (encryption algorithms). Whichone is used is chosen at compile time with arguments to the@command{configure} script.As of CIPE 1.5, the following options are possible:Protocol version 3: This is the default protocol and recommended formost use. It is described in detail in this document. @xref{The CIPEProtocol}. The device works as an IP-only point-to-point device muchlike with SLIP or PPP.Protocol version 4: This protocol uses the same data format as protocolversion 3, except that the packets transmitted contain an Ethernet-compatiblelink-level header. With this it is possible to run payload protocolsother than IP, and particularly it is possible to make the CIPE devicepart of an Ethernet bridge.@cindex Ethernet@cindex BridgingThe disadvantage is that the packets get larger than with protocol 3. Itmay be necessary to set the MAC address using the @option{hwaddr} optionto make it unique across the VPN. With this protocol, the device has asubnet mask and broadcast address which can be set with appropriateoptions.Blowfish: This is the default encryption algorithm, used with a 128 bitkey.IDEA: An alternate encryption algorithm with a 128 bit key. Thisalgorithm is patented and may need a licence for commercial use. It isno longer included in the CIPE package, but can (in theory) be used viathe cryptographic API.Since CIPE 1.4, the built-in Blowfish is available in generic C andi386 assembler implementations. The assembler versions are used wherepossible.With CIPE 1.6 it is possible to use the cryptographic API in Linux2.4.22 or later and 2.6 and use the modularized ciphers. In this case,the module and daemon are named like @code{cipc} and @code{ciped-c}(note the lack of the last letter indicating the builtin cipher).The cipher actually used can be specified as a configuration parameter,defaulting to @code{blowfish-internal} which gives the old builtinBlowfish algorithm. Note that this version is not compatible with thekernel Blowfish module, because @code{blowfish-internal} is originallycoded little-endian (real Blowfish is big-endian) and remains so forcompatibility with older versions.Ciphers with a block or IV size other than 64 bits are not supported.@node  Advanced compiling, Install, Protocols and ciphers, Installation@section        Advanced compilingThe use of a separate object directory means it is possible to compileCIPE for separate targets in the same directory. An example would be amachine running different kernels for testing, etc. In that case youwould have kernel directories like @file{/usr/src/linux-2.0.36},@file{/usr/src/linux-2.2.6}, and so on. Running @code{configure--with-linux=/usr/src/linux-2.0.36} and after that @code{configure--with-linux=/usr/src/linux-2.2.6} leaves two directories@code{2.0.36-i386-cb} and @code{2.2.6-i386-cb}. You can run @command{make}@emph{in each of the object directories} separately.Another common case is a setup where one central box compiles kernelsfor different machines. You can rename CIPE's compilation directorieswith the --enable-name option, perhaps name them after the target machine:@example./configure --with-linux=/usr/src/linux-2.2.6-bigbox \            --enable-name=bigboxmake -C 2.2.6-i386-cb-bigbox./configure --with-linux=/usr/src/linux-2.2.6-satellite \            --enable-name=satellitemake -C 2.2.6-i386-cb-satellite./configure --with-linux=/mounts/srv1/linux-2.2.5-small \            --enable-name=laptopmake -C 2.2.5-i386-cb-laptop@end exampleIn the same way distribution maintainers could prepare a set ofdifferently configured CIPE modules (IDEA vs. Blowfish) for one target.The names of the module and driver are chosen so that differentconfigurations can coexist on one target. @xref{Program Names}.Note that real cross-compilation is not possible for now, because theconfigure script always assumes the CPU architecture of the system whereit runs.@node Install, Compilation errors, Advanced compiling, Installation@section        InstallationA simple @command{make} command compiles everything. Compiler warningsshould not occur. Do @command{make install} as@emph{root} to install the software components in their final location.These are a kernel module, named according to the protocol version andencryption algorithm selected, and the driver program, which is (sinceCIPE 1.3) also named after the protocol version and encryptionalgorithm. @xref{Program Names}. The Makefiles accept the semi-standardoptions @code{BINDIR, MODDIR, INFODIR} to specify where the stuff getsinstalled.If PKCIPE was compiled, @command{make install} also installs the@command{pkcipe} program and a helper @command{rsa-keygen}, sets up thenecessary directories and generates a host key if none is already there.@xref{PKCIPE}.@cindex @file{/etc/cipe} directoryYou need to create a directory @file{/etc/cipe} which contains atleast two files, @file{options} and @file{ip-up}. You can copy thefiles from the @file{samples} directory in the distribution here, andedit them to suit your needs. @xref{Configuration}.@node  Compilation errors, Run, Install, Installation@section Compilation errorsThere is a known problem in that the various 2.0.30 and 2.0.31pre-releases disagree on whether they have a certain feature@cindex SO_BINDTODEVICE(@code{SO_BINDTODEVICE}), and detecting this version dependency via theversion number is not foolproof. Apparently, since 2.0.32, this problemis resolved. If @code{output.c} doesn't compile under 2.0.*, change theline@example#ifdef SO_BINDTODEVICE@end exampleto @code{#if 1} or @code{#if 0} as needed.A similar problem exists in the 2.3.99 pre-releases, where the@code{name} part of the @code{net_device} structure has changed. If anerror occurs during compilation of @file{device.c} under 2.3.99pre-n,change the conditional definition of @code{HAVE_DEVNAME_ARRAY} in@file{cipe.h} to @code{#if 1} or @code{#if 0} as needed.@cindex net_device structureSince the 2.4.0 test releases this problem is resolved.@node Run,  , Compilation errors, Installation@section        Running CIPE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -