IPsec-Tools配置之racoon

 

 


IPsec-Tools中的racoon工具实现了IKE的功能,既实现了双向认证,又能建立和维护IPsec SA。下面使用psk的认证方法配置racooon

 

一、网络拓扑

 

 网络拓扑

二、配置网络

 

子网1: 192.168.1.0/24,网关GW1

子网2: 192.168.0.0/24,网关GW2

GW1GW2已添加到子网21的路由。

AB现在可正常ping

 

三、IPsec配置

 

1. 客户端A


(1) setkey.conf


[root@localhost ~]# cat /etc/setkey.conf

 

#flush SAD entries

flush;

 

#flush SPD entries

spdflush;

 

#add SA entries

 

#add SP entries

spdadd 192.168.0.0/24 192.168.1.0/24 any -P in  ipsec esp/transport//require esp/transport//require;

spdadd 192.168.1.0/24 192.168.0.0/24 any -P out ipsec esp/transport//require esp/transport//require;

 

 

(2) psk.txt


[root@localhost ~]# cat /etc/racoon/psk.txt

192.168.0.2             0x123456

 

(3)racoon.conf


[root@localhost ~]# cat /etc/racoon/racoon.conf

 # Racoon IKE daemon configuration file.

# See 'man racoon.conf' for a description of the format and entries.

 

path include "/etc/racoon";

path pre_shared_key "/etc/racoon/psk.txt";

path certificate "/etc/racoon/certs";

 

 

remote anonymous

{

       exchange_mode main;

       lifetime time 2 hour;

       proposal {

                  encryption_algorithm 3des;

                  hash_algorithm sha1;

                  authentication_method pre_shared_key;

                  dh_group 2;

                }

       proposal {

                   encryption_algorithm aes;

                   hash_algorithm sha512;

                   authentication_method pre_shared_key;

                   dh_group modp2048;

                }

}

 

sainfo anonymous

{

        pfs_group 2;

        lifetime time 1 hour ;

        encryption_algorithm 3des, blowfish 448, rijndael ;

        authentication_algorithm hmac_sha1, hmac_md5 ;

        compression_algorithm deflate ;

}

 

 

2. 客户端B


(1)setkey.conf

 

[root@localhost ~]# cat /etc/setkey.conf

 

#flush SAD entries

flush;

 

#flush SPD entries

spdflush;

 

#add SA entries

 

#add SP entries

spdadd 192.168.1.0/24 192.168.0.0/24 any -P in  ipsec esp/transport//require esp/transport//require;

spdadd 192.168.0.0/24 192.168.1.0/24 any -P out ipsec esp/transport//require esp/transport//require;

 


(2) psk.txt


[root@localhost ~]# cat /etc/racoon/psk.txt

192.168.1.2             0x123456

 

(3) racoon.conf

 

[root@localhost ~]# cat /etc/racoon/racoon.conf

# Racoon IKE daemon configuration file.

# See 'man racoon.conf' for a description of the format and entries.


path include "/etc/racoon";

path pre_shared_key "/etc/racoon/psk.txt";

path certificate "/etc/racoon/certs";



remote anonymous

{

       exchange_mode main;

       lifetime time 2 hour;

       proposal {

                  encryption_algorithm 3des;

                  hash_algorithm sha1;

                  authentication_method pre_shared_key;

                  dh_group 2;

                }

       proposal {

                  encryption_algorithm aes;

                  hash_algorithm sha512;

                  authentication_method pre_shared_key;

                  dh_group modp2048;

                }

}


sainfo anonymous

{

        pfs_group 2;

        lifetime time 1 hour ;

        encryption_algorithm 3des, blowfish 448, rijndael ;

        authentication_algorithm hmac_sha1, hmac_md5 ;

        compression_algorithm deflate ;

}

 

 

四、测试

 

1.在客户AB上分别激活setkey.confracoon.conf

#setkey –f /etc/setkey.conf

#setkey –f /etc/raccoon/racoon.conf

 

2. iptables设置

由于iptables会丢弃ESP数据包,ESP在经过GW1GW2路由时会被丢弃,所以应配置iptables允许ESP数据包通过或简单disableiptables.

#service iptables stop

 

3.Bping A,抓包如下:


 racoon抓包

 racoon使用psk认证方法配置成功!

 

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值