今天给大家介绍一下IPSEC VXN的配置实例,适合对IPSEC理论有一定了解,但是对IPSEC配置还不清楚的同学,本文介绍的是最简单的IPSEC配置实例。如果想要了解IPSEC基础知识或者想要了解IPSEC更深层次知识的同学,可以关注我的博客,我的博客会不断更新计算机网络相关技术文章。
一、实验拓扑及要求
实验拓扑图如下所示:
要求:配置IPSEC VXN,实现两个私网网址之间互通,同时要求两个私网网址使用费NAT访问公网。
二、配置讲解说明
IPSEG的配置可以分为以下几个小部分:
1、IPSEG proposal的配置
ipsec proposal IPSEG
transform esp
esp authentication-algorithm md5
esp encryption-algorithm 3des
要配置IPSEC VXN,首先要配置IPSEC策略,我们知道,IPSEC有两种形式,esp或者ah,在IPSEC 配置中,要选择其中一种方式,并进一步选择该方式的加密(认证)算法。该配置要求运行IPSEC VXN的路由器配置相同
2、IKE的配置
IKE协议是IPSEC VXN中用于密钥交换的协议,定义IKE协议,要定义其密钥交换算法,加密算法和认证算法。
ike proposal 10
encryption-algorithm 3des-cbc
dh group2
authentication-algorithm md5
authentication-method pre-share
ike peer R3 v1
pre-shared-key simple admin
remote-address 150.1.2.3
3、分化IPSEC流量和公网流量
因为IPSEC的流量和上互联网的流量都要从一个接口出去,因此必须告诉路由器什么样的流量要进行IPSEC VXN封装,什么样的流量不需要进行IPSEC VXN封装。要特别注意:在进行ACL匹配的时候,默认是先进行NAT的匹配,因此在配置NAT的ACL的时候,要把IPSEC VXN的流量踢出去,但是在配置IPSEC VXN的ACL时则不用这样做。
acl number 3000
rule 5 permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
acl number 3001
rule 5 deny ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
rule 10 permit ip source 192.168.1.0 0.0.0.255
4、生成IPSEG策略
IPSEC 策略配置要把以上配置的内容整合在一起,配置如下所示:
ipsec policy IPSEC_POL 10 isakmp
security acl 3000
ike-peer R1
proposal IPSEC
5、IPSEG应用
在接口上,要应用IPSEC 策略和NAT策略。
interface GigabitEthernet0/0/0
ipsec policy IPSEC_POL
nat outbound 3001
三、IPSEC排错——新手配置IPSEC VXN易犯错误
注意,在完成上述配置后,我们还必须添加一条手动的静态路由,如下:
ip route-static 0.0.0.0 0.0.0.0 150.1.1.2
这是新手在配置IPSEC VXN时经常犯的错误。
以R3为例,当PC2发往PC1的数据包送到R3时,此时我们需要让他走IPSEC VXN进行封装。**但是!!!**如果此时R3上没有去往PC1的路由,则路由器会把该数据包直接丢弃,因此,必须加上一条如上的默认路由,或者是去往PC1的静态路由。只有这样,才能把流量送到G0/0/0接口上,让其进行IPSEC VXN封装。
四、附录——配置命令
为了方便大家配置,下面把R1和R3上的相关配置命令粘贴如下:(注:有些命令是默认配置的,因此在二中的一些命令在下面没有显示)
R1:
acl number 3000
rule 5 permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
#
acl number 3001
rule 5 deny ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
rule 10 permit ip source 192.168.1.0 0.0.0.255
#
ipsec proposal IPSEG
esp encryption-algorithm 3des
#
ike proposal 10
encryption-algorithm 3des-cbc
dh group2
authentication-algorithm md5
#
ike peer R3 v1
pre-shared-key simple admin
remote-address 150.1.2.3
#
ipsec policy IPSEC_POL 10 isakmp
security acl 3000
ike-peer R3
proposal IPSEG
#
interface GigabitEthernet0/0/1
ip address 150.1.1.1 255.255.255.0
ipsec policy IPSEC_POL
nat outbound 3001
#
interface GigabitEthernet0/0/2
ip address 192.168.1.1 255.255.255.0
#
ip route-static 0.0.0.0 0.0.0.0 150.1.1.2
R3:
acl number 3000
rule 5 permit ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
#
acl number 3001
rule 5 deny ip source 192.168.2.0 0.0.0.255 destination 192.168.1.0 0.0.0.255
rule 10 permit ip source 192.168.2.0 0.0.0.255
#
ipsec proposal IPSEC
esp encryption-algorithm 3des
#
ike proposal 10
encryption-algorithm 3des-cbc
dh group2
authentication-algorithm md5
#
ike peer R1 v1
pre-shared-key simple admin
ike-proposal 10
remote-address 150.1.1.1
#
ipsec policy IPSEC_POL 10 isakmp
security acl 3000
ike-peer R1
proposal IPSEC
#
interface GigabitEthernet0/0/0
ip address 150.1.2.3 255.255.255.0
ipsec policy IPSEC_POL
nat outbound 3001
#
interface GigabitEthernet0/0/2
ip address 192.168.2.3 255.255.255.0
#
ospf 1
area 0.0.0.0
network 150.1.2.0 0.0.0.255
#
ip route-static 0.0.0.0 0.0.0.0 150.1.2.2
五、实验效果
1、能PING通
2、能查看
在R1上执行命令:
display ipsec sa
3、能上网
原创不易,转载请说明出处:https://blog.csdn.net/weixin_40228200/article/details/118497951