来源:https://blog.csdn.net/zt698/article/details/4811604

1       介绍
从Linux 2.6内核开始,内核就自身带有IPSec模块,配合IPSec-Tools,能很好的实现Linux的IPSec功能。

IPSec-Tools主要包含libipsec、setkey、racoon和racoonctl这4个模块,setkey主要用于配置SAD(安全关联数据库)和SPD(安全策略数据库),racoon用于IKE协商。

本文采用最简单的网络配置(2台PC互联,操作系统均为:Linux 2.6.27)介绍IPSec-Tools的IKE配置和手工配置实现传输模式的IPSec。

默认情况下,IPSec-Tools的配置文件均放在/etc/racoon目录下,setkey.conf文件保存着sad和spd的配置信息,racoon.conf文件保存着IKE各个协商阶段各采用什么方式进行协商。

2       拓扑图

3       IKE配置
1)        采用预共享密钥的方式,在/etc/racoon目录下产生psk.txt的文件;

在A机的psk.txt里填入:192.168.59.133  mekmitasdigoat。

在B机的psk.txt里填入:192.168.59.132  mekmitasdigoat。

产生psk.txt文件后,执行:chmod 600 psk.txt.

2)        打开setkey.conf文件:

A机填入:

flush;

spdflush;

spdadd 192.168.59.132 192.168.59.133 any -P out ipsec esp/transport//require;

spdadd 192.168.59.133 192.168.59.132 any -P in ipsec esp/transport//require;

B机填入:

flush;

spdflush;

spdadd 192.168.59.132 192.168.59.133 any -P in ipsec esp/transport//require;

spdadd 192.168.59.133 192.168.59.132 any -P out ipsec esp/transport//require;

3)        打开A、B两机的racoon.conf文件,均填写以下内容:

path include "/etc/racoon";                                     #配置文件位置

path pre_shared_key "/etc/racoon/psk.txt";                  #共享密钥文件

path certificate "/etc/racoon/cert";                                 #证书文件目录

log notify;

# "padding" defines some parameter of padding.  You should not touch these.

padding

{

maximum_length 20;    # maximum padding length.

randomize off;              # enable randomize length.

strict_check off;    # enable strict check.

exclusive_tail off;  # extract last one octet.

}

# if no listen directive is specified, racoon will listen to all

# available interface addresses.

listen

{

#isakmp ::1 [7000];

#isakmp 202.249.11.124 [500];

#admin [7002];            # administrative's port by kmpstat.

#strict_address;   # required all addresses must be bound.

adminsock "/var/run/racoon/racoon.sock" "root" "users" 660;

}

# Specification of default various timer.

timer

{

# These value can be changed per remote node.

counter 5;             # maximum trying count to send.

interval 20 sec;     # maximum interval to resend.

persend 1;            # the number of packets per a send.

# timer for waiting to complete each phase.

phase1 30 sec;

phase2 15 sec;

}

remote anonymous                   #阶段一协商

{

exchange_mode main;    #main:主模式,aggressive:野蛮模式

lifetime time 24 hour;

proposal {

encryption_algorithm 3des;

hash_algorithm sha1;

authentication_method pre_shared_key;

dh_group 1;

}

proposal {

encryption_algorithm 3des;

hash_algorithm md5;

authentication_method pre_shared_key;

dh_group 1;

}

proposal {

encryption_algorithm 3des;

hash_algorithm sha1;

authentication_method pre_shared_key;

dh_group 1;

}

proposal {

encryption_algorithm 3des;

hash_algorithm md5;

authentication_method pre_shared_key;

dh_group 1;

}

proposal {

encryption_algorithm 3des;

hash_algorithm sha1;

authentication_method pre_shared_key;

dh_group 1;

}

}

sainfo anonymous                                                 #阶段二协商

{

pfs_group 2;

lifetime time 12 hour ;

encryption_algorithm 3des;

authentication_algorithm hmac_sha1;

compression_algorithm deflate ;

}

4)        执行/usr/sbin/racoon -f /etc/racoon/racoon.conf,运行IKE协商程序;

5)        A机执行ping B机,在中间转包可以看到IKE协商包,协商完成以后会出现ESP包,并且能够ping通。

4 手工配置
1)        Setkey.conf设置:

在A机的setkey.conf中填入:

flush;

spdflush;

add 192.168.59.132 192.168.59.133 esp 24501 -E 3des-cbc "123456789012123456789012";

add 192.168.59.133 192.168.59.132 esp 24502 -E 3des-cbc "123456789012123456789012";

spdadd 192.168.59.132 192.168.59.133 any -P out ipsec esp/transport//require;

spdadd 192.168.59.133 192.168.59.132 any -P in ipsec esp/transport//require;

在B机的setkey.conf中填入:

flush;

spdflush;

add 192.168.59.132 192.168.59.133 esp 24501 -E 3des-cbc "123456789012123456789012";

add 192.168.59.133 192.168.59.132 esp 24502 -E 3des-cbc "123456789012123456789012";

spdadd 192.168.59.132 192.168.59.133 any -P in ipsec esp/transport//require;

spdadd 192.168.59.133 192.168.59.132 any -P out ipsec esp/transport//require;

2)        执行setkey –f /etc/raccoon/setkey.conf;

3)        A机执行ping B机,在中间转包可以看到ESP包,并且能够ping通。

5 其它
Setkey –D:查看SAD信息;

Setkey –DP:查看SPD信息。
---------------------
作者:zt698
来源:CSDN
原文:https://blog.csdn.net/zt698/article/details/4811604
版权声明:本文为博主原创文章,转载请附上博文链接!

【转载】IPSec-Tools配置的更多相关文章

  1. IPSEC VPN配置实例

    TL-R400VPN应用——IPSEC VPN配置实例 TL-ER6120是TP-LINK专为企业应用而开发的VPN路由器,具备强大的数据处理能力,并且支持丰富的软件功能,包括VPN.IP/MAC 地 ...

  2. Siebel Tools配置

    默认安装的Siebel+Tools,Tools登陆时有3个选项:Local.Sample.Server,具体涵义如下: Local:指本地数据库.按照Siebel开发建议,开发人员需要从Siebel ...

  3. 转载:Vim 配置入门

    转载:Vim 配置入门 原文地址:http://www.ruanyifeng.com/blog/2018/09/vimrc.html 作者: 阮一峰 Vim 是最重要的编辑器之一,主要有下面几个优点. ...

  4. 转载-centos网络配置(手动设置,自动获取)的2种方法

    转载地址:http://blog.51yip.com/linux/1120.html 重新启动网络配置 # service network restart 或 # /etc/init.d/networ ...

  5. [转载]TFS安装配置教程

    最近公司新开发一个项目要用微软的TFS2013进行项目的源代码管理,以前只是用过SVN,从来没有用过TFS,所以在网上百度.谷歌了好一阵子来查看怎么安装和配置,还好花了一天时间总算是初步的搞定了,下面 ...

  6. ASA IPSEC VPN配置

    ASA-1配置 : Saved:ASA Version 8.0(2) !hostname ASA-1enable password 8Ry2YjIyt7RRXU24 encryptednames!in ...

  7. cisco路由器IPSEC VPN配置(隧道模式)

    拓扑如下: R1配置hostname R1enable password cisco  crypto isakmp policy 1        #创建IKE协商策略,编号为1 encr 3des  ...

  8. [dev][ipsec][dpdk] strongswan/dpdk源码分析之ipsec算法配置过程

    1 简述 storngswan的配置里用一种固定格式的字符串设置了用于协商的预定义算法.在包协商过程中strongswan将字符串转换为固定的枚举值封在数据包里用于传输. 协商成功之后,这组被协商选中 ...

  9. 【转载】uWSGI配置翻译

    英文原版: http://uwsgi-docs.readthedocs.io/en/latest/Options.html 转载地址: http://www.cnblogs.com/zhouej/ar ...

随机推荐

  1. scrapy selector选择器

    这部分内容属于补充内容 1.xpath() 2.css() 3.正则表达式 # 多个值,列表 response.xpath('//a/text()').re('(.*?):\s(.*)') # 取第一 ...

  2. python3三元运算

    条件:简单的条件判断语句并且有返回值 作用:简化代码和装X 格式:为True执行的语句 if 判断条件 else 为False执行的语句 例子 def f(a, b): ""&qu ...

  3. 遗传编程GP-地图路径寻路

    本文介绍的是基于GP,并非A*算法,算是另类实现吧. 先看看地图定义,在文本文件中定义如下字符串,代表30列11行大小的地图 初始位置在左上角(0,0) ,值为1的是允许走的通的路,目标位置为右下角( ...

  4. [bzoj4417] [洛谷P3990] [Shoi2013] 超级跳马

    Description 现有一个n行m列的棋盘,一只马欲从棋盘的左上角跳到右下角.每一步它向右跳奇数列,且跳到本行或相邻行.跳越期间,马不能离开棋盘.例如,当n = 3, m = 10时,下图是一种可 ...

  5. 「 从0到1学习微服务SpringCloud 」13 断路器Hystrix

    背景与功能 在微服务架构中,很多情况下,各个服务之间是相互依赖,一个服务可能会调用了好几个其他服务,假设其中有一个服务故障,便会产生级联故障,最终导致整个系统崩溃无法使用(这称为雪崩效应),Sprin ...

  6. openjudge 拯救公主

    点击打开题目 看到这道题,第一感觉是我有一句m2p不知当讲不当讲 传送门就算了,你提莫还来宝石,还不给我每种最多有几个~~ 在一般的迷宫问题里,无论已经走了多少步,只要到达同一个点,状态便是等价的,但 ...

  7. winform dataGridView 点击列标题排序

    winform手动绑定数据后,点击列标题不能实现自动排序,苦苦寻找方法,发现下面的是可行的. //建立DataTable将当前dataGridView中的数据读进DataTable中 public D ...

  8. Hyper-V 搭建独臂路由器(单网卡也可以)

    2020年原本难得清闲的春节,由于疫情的原因只能在家里看视频打发时间.打开某奇艺,全是某某公寓的推荐真的是受不了.一群人在那里叽叽喳喳,超前点播更是吃像难看,实在是没意思,所以决定搞一个独臂路由器玩一 ...

  9. idea搭建springmvc(maven版)

    一.创建maven项目 (1)选择 file > new > project (2)填写对应信息,一路点击next 配置自己本地的maven,继续next 命名项目名(随意写,但要易懂), ...

  10. 解决apt-get安装软件包的时候遇到E: Sub-process /usr/bin/dpkg returned an error code (1)问题

    在用apt-get安装软件包的时候遇到E: Sub-process /usr/bin/dpkg returned an error code (1)问题,解决方法如下:   cd /var/lib/d ...