ipsec-tools安装教程
- ipsec-tools最新版本为0.8.2,此处以0.7.3版本为例说明安装和使用过程。可参考ipsec-howto。
安装步骤
ipsec-tools依赖于linux2.6版本内核,在安装ipsec-tools前需编译安装linux kernel 2.6,此处以2.6.34.1为例。
内核编译步骤
- 下载 linux-2.6.34.1.tar.bz2
- 将文件移动到
/usr/src/kernels/
mv linux-2.6.34.1.tar.bz2 /usr/src/kernels/ - 解压
tar -jxvf linux-2.6.34.1.tar.bz2 make menuconfig导入加解密模块。
- 报错:
'make menuconfig' requires the ncurses libraries.原因:在终端连接主机的情况下进行GUI菜单配置,缺失必要的包ncurses。
解决方法:安装ncurses包,yum install ncurses-devel。
需加载或引入的模块如下:Networking support (NET) [Y/n/?] y
*- Networking options
PF_KEY sockets (NET_KEY) [Y/n/m/?] y
IP: AH transformation (INET_AH) [Y/n/m/?] y
IP: ESP transformation (INET_ESP) [Y/n/m/?] y
IP: IPsec user configuration interface (XFRM_USER) [Y/n/m/?] y
Cryptographic API (CRYPTO) [Y/n/?] y
HMAC support (CRYPTO_HMAC) [Y/n/?] y
Null algorithms (CRYPTO_NULL) [Y/n/m/?] y
MD5 digest algorithm (CRYPTO_MD5) [Y/n/m/?] y
SHA1 digest algorithm (CRYPTO_SHA1) [Y/n/m/?] y
DES and Triple DES EDE cipher algorithms (CRYPTO_DES) [Y/n/m/?] y
AES cipher algorithms (CRYPTO_AES) [Y/n/m/?] y - Networking options
make
- 报错:
gcc: error: elf_i386: No such file or directory
原因:gcc 4.8不再支持linker-style架构。
解决方法:im arch/x86/vdso/Makefile,找到DSO_LDFLAGS_vdso.lds = -m elf_x86_64,将-m elf_x86_64改为-m64,找到VDSO_LDFLAGS_vdso32.lds = -m elf_i386,将-m elf_i386改为-m32即可。 - 报错:
drivers/net/igbvf/igbvf.h:129:15: error: duplicate member ‘page’
原因:gcc版本与内核版本冲突导致,gcc版本4.8不支持内核linux 2.6.34中在结构体和结构体外重复定义的方式。
解决方法:更改内核源码vim drivers/net/igbvf/igbvf.h,将129行的struct page *page改为struct page *pagep,重新编译。 - 报错:
Documentation/video4linux/v4lgrab.c:34:28: fatal error: linux/videodev.h: No such file or directory
原因:缺失libv4l-devel包。
解决方法:安装libv4l-devel包,yum install libv4l-devel,修改内核源码vim Documentation/video4linux/v4lgrab.c,将#include <linux/videodev.h>改为#include <libv4l1-videodev.h>,重新编译。
make modules_installmake install
检查是否安装成功:awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg0 : CentOS Linux (2.6.34.1) 7 (Core)
1 : CentOS Linux (3.10.0-693.21.1.el7.x86_64) 7 (Core)
2 : CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core)
3 : CentOS Linux (0-rescue-6c250481a09c4f48a0b2432ad5b4c8b8) 7 (Core)
出现CentOS Linux (2.6.34.1) 7 (Core)表明内核安装成功。
ipsec-tools安装步骤
- 下载
ipsec-tools-0.7.3.tar.gz并解压。 configure
指定内核版本为2.6
./configure --with-kernel-headers=/lib/modules/2.6.34.1/build/include/
- 报错:
configure: error: OpenSSL version must be 0.9.6 or higher. Aborting.
解决方法:yum install openssl-devel
make
- 报错:
token.c:(.text+0xc6d): undefined reference to 'yywrap'
解决方法:yum install flex flex-devel bison,然后重新configure,make。 - 报错:
ipsec_doi.c:1321:24: error: argument to ‘sizeof’ in ‘memset’ call is the same expression as the destination
解决方法:vim src/racoon/ipsec_doi.c,将1321行memset(pair, 0, sizeof(pair));中的sizeof(pair)改为sizeof(*pair),重新make。 - 报错:
/usr/include/selinux/flask.h:5:2: error: #warning "Please remove any #include's of this header in your source code." [-Werror=cpp]
解决方法:删除第5行的#warning注释,sed -i '5d' /usr/include/selinux/flask.h,后面的warning错误,解决方法相同。
make install
检查是否安装成功
which setkey/usr/local/sbin/setkey
which racoon
/usr/local/sbin/racoon
出现以上信息表示ipsec-tools安装成功
配置步骤
- 假设主机A的IP为1.1.1.1,主机B的IP为2.2.2.1,且主机A、B可互相通信。
配置文件:在root目录下创建3个文件
1、psk.txt (两个主机配置相同)
1.1.1.1 testkey
2.2.2.2 testkey
2、setkey.conf
主机A:
#!/usr/sbin/setkey -f
flush;
spdflush;
spdadd 1.1.1.1/32[any] 2.2.2.1/32[any] any -P out ipsec
esp/tunnel/1.1.1.1-2.2.2.1/require;
spdadd 2.2.2.1/32[any] 1.1.1.1/32[any] any -P in ipsec
esp/tunnel/2.2.2.1-1.1.1.1/require;
主机B:
#!/usr/sbin/setkey -f
flush;
spdflush;
spdadd 2.2.2.1/32[any] 1.1.1.1/32[any] any -P out ipsec
esp/tunnel/2.2.2.1-1.1.1.1/require;
spdadd 1.1.1.1/32[any] 2.2.2.1/32[any] any -P in ipsec
esp/tunnel/1.1.1.1-2.2.2.1/require;
3、racoon.conf
主机A:
#!/usr/local/bin/racoon
path pre_shared_key "/root/psk.txt";
listen {
isakmp 1.1.1.1 [500];
}
remote 2.2.2.1 {
exchange_mode main, aggressive;
my_identifier address 1.1.1.1;
peers_identifier address 2.2.2.1;
initial_contact on;
proposal_check obey;
proposal {
encryption_algorithm aes 256;
hash_algorithm md5;
authentication_method pre_shared_key;
dh_group 2;
}
}
sainfo address 1.1.1.1 any address 2.2.2.1 any{
encryption_algorithm des;
authentication_algorithm hmac_md5;
compression_algorithm deflate;
}
sainfo address 2.2.2.1 any address 1.1.1.1 any{
encryption_algorithm des;
authentication_algorithm hmac_md5;
compression_algorithm deflate;
}
主机B:
#!/usr/local/bin/racoon
path pre_shared_key "/root/psk.txt";
listen {
isakmp 2.2.2.1 [500];
}
remote 1.1.1.1 {
exchange_mode main, aggressive;
my_identifier address 2.2.2.1;
peers_identifier address 1.1.1.1;
initial_contact on;
proposal_check obey;
proposal {
encryption_algorithm aes 256;
hash_algorithm md5;
authentication_method pre_shared_key;
dh_group 2;
}
}
sainfo address 2.2.2.1 any address 1.1.1.1 any{
encryption_algorithm des;
authentication_algorithm hmac_md5;
compression_algorithm deflate;
}
sainfo address 1.1.1.1 any address 2.2.2.1 any{
encryption_algorithm des;
authentication_algorithm hmac_md5;
compression_algorithm deflate;
}
启动IPsec:
1、setkey setk.conf
此时使用setkey -DP命令可以看到SPD数据
2、/usr/local/sbin/racoon -f racoon.conf -ddddddd -l /tmp/ipsec-log.txt -v
可以在/tmp/ipsec-log.txt中查看日志,方便调试
测试:
在主机A上 ping 主机B,并在主机B上抓取esp报文
主机B:tcpdump -i eth0 -n src 1.1.1.1 and esp
主机A能ping通主机B,且在主机B上抓取到来自主机A的esp报文,说明隧道成功建立。
ipsec-tools安装教程的更多相关文章
- VMware Tools安装教程
安装依赖: sudo yum install eject 步骤: 确保 Linux 虚拟机已打开电源. 如果正在运行 GUI 界面,请打开命令 shell. 注意:以 root 用户身份登录,或使用 ...
- FreeBSD虚拟机 VMware Tools 安装教程
对于 FreeBSD 虚拟机,您可以使用命令行工具手动安装或升级 VMware Tools 前提条件 开启虚拟机. 确认客户机操作系统正在运行. 因为 VMware Tools 安装程序是使用 Per ...
- [最直白版]一步一步教你用VMware Workstation12安装Ubuntu 16.04和VMware Tools的教程
[最直白版]Win10下一步一步教你用 VMware Workstation12安装Ubuntu 16.04和VMware Tools的教程 安装过程中使用的软件(要保证电脑里面有下列三个东西): 1 ...
- Pro Tools安装图文教程
Pro Tools安装图文教程 Avid Pro Tools是Digidesign公司出品的一款音质最佳.音频制作强大的软件,能够在Mac或PC上为影片编曲.录制.编辑和混制高品质音乐或声音,生成 ...
- Android Studio的下载和安装教程(从ADT到AS)
之前一直使用的是Android development tools(简称ADT),后来说是google对ADT不再提供支持,然后一直在考虑是否把自己电脑换成Android Studio(简称AS),从 ...
- Windows环境下Android Studio v1.0安装教程
Windows环境下Android Studio v1.0安装教程 准备工具 JDK安装包. 要求:JDK 7以及以上版本. Android Studio安装文件. Windows: exe(包含SD ...
- Android笔记——Windows环境下Android Studio v1.0安装教程
本文主要讲解Windows环境下Android Studio的安装教程,Mac的Android Studio安装与此类似不在赘述,另外友情提示Windows下的SDK与Mac的SDK是通用的,可以直接 ...
- .NET Reflector 7.6.1.824 Edition .NET程序反编译神器(附插件安装教程2012-10-13更新) 完全破解+使用教程
原文来自VAllen cnblogs 一.使用教程1.解压后,双击Reflector.exe,如果有选择默认版本的.Net Framework,根据需要选择即可.你选择的版本不同则出现的默认程序集也不 ...
- 【转】Windows环境下Android Studio v1.0安装教程
原文网址:http://ask.android-studio.org/?/article/9 http://android-studio.org/index.php/docs/experience/1 ...
- Red Gate系列之五 .NET Reflector 7.6.1.824 Edition .NET程序反编译神器(附插件安装教程2012-10-13更新) 完全破解+使用教程
原文:Red Gate系列之五 .NET Reflector 7.6.1.824 Edition .NET程序反编译神器(附插件安装教程2012-10-13更新) 完全破解+使用教程 Red Gate ...
随机推荐
- Arduino下读取DHT22温湿度(不使用第三方库)
代码如下: #include <inttypes.h> /* * LED */ unsigned ; /* * DHT22配置程序 */ unsigned ; #define DHT_OK ...
- ElasticSearch搜索实例含高亮显示及搜索的特殊字符过滤
应用说明见代码注解. 1.简单搜索实例展示: public void search() throws IOException { // 自定义集群结点名称 String clusterName = & ...
- 『编程题全队』Alpha 阶段冲刺博客Day6
1.每日站立式会议 1.会议照片 2.昨天已完成的工作统计 孙志威: 1.添加JSON处理模块 2.添加了团队看板中的添加团队任务功能 3.添加了团队看板中的添加按钮 孙慧君: 1.个人任务框UI的设 ...
- PAT 甲级 1085 Perfect Sequence
https://pintia.cn/problem-sets/994805342720868352/problems/994805381845336064 Given a sequence of po ...
- python 如何写CMD命令工具
#-*- coding: UTF- -*- import argparse import sys: sys.argv.append('--help') parser = argparse.Argume ...
- 4种PHP回调函数风格
4种PHP回调函数风格 匿名函数 $server->on('Request', function ($req, $resp) use ($a, $b, $c) { echo "hell ...
- iptables之四表五链
iptables可谓是SA的看家本领,需要着重掌握.随着云计算的发展和普及,很多云厂商都提供类似安全组产品来修改机器防火墙. iptables概念 iptables只是Linux防火墙的管理工具而已. ...
- 题解 P1030 【求先序排列】
题解 P1030 [求先序排列] 旧题新解~ 今天做这个题,发现还是没有AC,于是滚回来用了一大堆数据结构A了这个题目,好像复杂度还挺高...... #include <iostream> ...
- GCD - Extreme (II) UVA - 11426(欧拉函数!!)
G(i) = (gcd(1, i) + gcd(2, i) + gcd(3, i) + .....+ gcd(i-1, i)) ret = G(1) + G(2) + G(3) +.....+ G(n ...
- 自学Zabbix3.5.1-监控项item-key介绍
点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 自学Zabbix3.5.1-监控项item-key介绍 个人觉得艰难理解,故附上原文档:https ...