Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Building And Integrating Virtual Private Networks With Openswan (2006).pdf
Скачиваний:
73
Добавлен:
17.08.2013
Размер:
4.74 Mб
Скачать

Chapter 3

Building KLIPS into the Linux Kernel Source Tree

Sometimes it is more desirable to manually build KLIPS. This involves patching the kernel directory itself, but the resulting source could be used on multiple systems. You may want to change some of the default options in KLIPS. Perhaps you do not want to use modules but want KLIPS as part of your kernel, for instance because you are building a firewall and do not want the security risk of loadable modules for your kernel.

Manually building KLIPS, either as a kernel module or as part of the kernel, can be a little bit more difficult. You will also need to maintain this part if you (or your distribution) upgrade the system's kernel.

Building a Standard Kernel

The kernel source as shipped with most distributions has not been configured, so you will always need to configure the kernel source first.

At some point Red Hat kernel source trees needed some cleanup before you could configure them:

# make distclean

Running make distclean will delete your .config file. If you are using your own

.config file, copy it somewhere outside the kernel tree before running this command, then copy it back in.

If you want to build the kernel according to the default settings provided by the vendor, either from your distribution or the defaults from Linus himself, you can simply run:

# make oldconfig

And if you are using a 2.4 or older kernel, you will also need to run:

# make dep

Of course, if you do not wish to use those defaults, you can run any of the kernel configure commands to reconfigure the kernel to suit your needs. You can use any of these commands:

Method

Description

 

 

make config

This uses a simple command line.

make

menuconfig

This uses an 'ncurses'-based menu system.

make

xconfig

This uses a full graphical menu system using 'qt'.

 

 

 

If you change your kernel configuration, we strongly recommend building the entire kernel at this stage, so that if you encounter problems when compiling KLIPS later on, you know that it is not a general kernel problem. Too often, the Openswan developers find people blaming KLIPS for their compile errors, while in fact the kernel itself or the build system itself was broken. Also do not forget to apply the NAT-T patch as described above.

71

Building and Installing Openswan

To make a kernel on an Intel-based computer, run:

# make bzImage

And if you are also using kernel modules:

# make modules modules_install

If these compilations work, you have confirmed that your current-build system and kernel directory are good. You can then proceed to compile KLIPS.

NAT Traversal

Remember that you should also apply the NAT-Traversal patch if you wish to support IPsec connections from behind NAT.

Patching KLIPS into the Linux Kernel

First we set the KERNELSRC shell variable to point to our Linux kernel source directory, so we do not accidentally compile against a different kernel than the one we're expecting.

Patching KLIPS into the kernel directory then becomes pretty straightforward:

#KERNELSRC=/usr/src/linux-2.6.11

#cd openswan-2

#make applypatch

You cannot start the kernel compile yet, because some new features (KLIPS) have been added to the kernel configuration file. The kernel configuration needs to be re-run.

#cd $KERNELSRC

#make oldconfig

You will be prompted for all the new kernel options related to KLIPS as described earlier. For each option, help information is also available. Of course, you can also use make menuconfig or make xconfig at this point. If using a 2.4 kernel, you should run make dep at this point.

72

Chapter 3

The following figure shows how to enable NAT-T in a kernel using make xconfig:

Be aware that you must not configure both NETKEY and KLIPS to be part of the kernel itself. Such a kernel will act completely unpredictably, and very likely will either fail to build, or crash.

In general, all the ciphers and algorithms can be enabled, since they can be disabled at run time if necessary using the ike= and esp= options. For detailed information about these ciphers and algorithms, see Chapter 2.

One exception is if you want to disable the KLIPS ciphers and algorithms in favor of the Linux CryptoAPI, which provides these ciphers as well. 3DES will always come from the KLIPS code if present. If you really wish to use the CryptoAPI version, disable 3DES in KLIPS. In the future this will change, when proper synchronous and asynchronous CryptoAPI support is added to KLIPS, and KLIPS is able to pick either its own 3DES or the CryptoAPI 3DES routines.

73