ipsec-vpn高可用性链路冗余备份实例
标题:ipsec vpn的高可用性
目的:实现vpn链路的冗余备份
拓扑:
步骤:
1.按照拓扑给路由器的接口分配地址
Ip地址规划
Branch上
branch(config)#int f0/0
branch(config-if)#ip add 202.100.1.1 255.255.255.0
branch(config-if)#no sh
branch(config-if)#int lo 0
branch(config-if)#ip add 1.1.1.1
255.255.255.0
isp上
isp(config)#int f0/1
isp(config-if)#ip add 202.100.1.10 255.255.255.0
isp(config-if)#no sh
isp(config-if)#int f0/0
isp(config-if)#ip add 61.128.1.10 255.255.255.0
isp(config-if)#no sh
isp(config-if)#int f1/0
isp(config-if)#ip add 137.78.5.10 255.255.255.0
isp(config-if)#no sh
active上
active(config)#int f0/1
active(config-if)#ip add 61.128.1.1 255.255.255.0
active(config-if)#int f0/0
active(config-if)#ip add 10.1.1.10 255.255.255.0
active(config-if)#no sh
standby上
standby(config)#int f0/1
standby(config-if)#ip add 137.78.5.1 255.255.255.0
standby(config-if)#no sh
standby(config-if)#int f0/0
standby(config-if)#ip add 10.1.1.20 255.255.255.0
standby(config-if)#no sh
inside上
inside(config)#int f0/1
inside(config-if)#ip add 10.1.1.1 255.255.255.0
inside(config-if)#int lo 0
inside(config-if)#ip add 2.2.2.2 255.255.255.0
测试直连路由是否可达
2.Center中运行动态路由
企业内部网络都会运行一种动态路由协议,保障内网用户底层可达
Active上
active(config)#router ospf 1
active(config-router)#network 10.1.1.0
0.0.0.255 area 0
standby上
standby(config)#router ospf 1
standby(config-router)#network 10.1.1.0 0.0.0.255 area 0
inside上
inside(config)#router ospf 1
inside(config-router)#network 10.1.1.0 0.0.0.255 area 0
inside(config-router)#network 2.2.2.0 0.0.0.255 a 0
3.建立vpn
企业网络的边界路由一般使用缺省路由指向互联网
首先解决路由问题
Branch上
Active上
Standby上
测试连通性
然后定义第一阶段的协商策略和认证
定义协商策略和认证:认证方式为预共享密钥;配置预共享的key,vpn两端必须一致;为了实现vpn链路的冗余备份,因此需要分支指向中心不同的边界网关,预共享key可以相同,也可以不同
Branch上
branch(config)#crypto isakmp policy 10
branch(config-isakmp)#authentication pre-share
branch(config)#crypto isakmp key 0 cisco address 61.128.1.1
branch(config)#crypto isakmp key 0 h3c address 137.78.5.1
定义协商策略和认证:认证方式为预共享密钥;配置预共享的key,vpn两端必须一致
active上
active(config)#crypto isakmp policy 10
active(config-isakmp)#authentication pre-share
active(config)#crypto isakmp key 0 cisco address 202.100.1.1
standby上
standby(config)#crypto isakmp policy 10
standby(config-isakmp)#authentication pre-share
standby(config)#crypto isakmp key 0 h3c address 202.100.1.1
在branch、active和standby上开启DPD
开启DPD,即死亡邻居检测。以周期性(每10秒)的发送keepalive 报文探测vpn链路或者vpn设备是否工作正常,以实现一个快速的切换
定义第二阶段的加密策略
定义加密策略:配置感兴趣流,配置转换集(des 加密,MD5认证,隧道模式)
Branch上
branch(config)#ip access-list extended vpn
branch(config-ext-nacl)#permit ip 1.1.1.0
0.0.0.255 2.2.2.0 0.0.0.255
branch(config)#crypto ipsec transform-set trans esp-des esp-md5-hmac
branch(cfg-crypto-trans)#mode tunnel active上
active(config)#ip access-list extended vpn
active(config-ext-nacl)#permit ip 2.2.2.0
0.0.0.255 1.1.1.0 0.0.0.255
active(config)#crypto ipsec transform-set trans esp-des esp-md5-hmac
active(cfg-crypto-trans)#mode tunnel standby上
standby(config)#ip access-list extended vpn
standby(config-ext-nacl)#permit ip 2.2.2.0
0.0.0.255 1.1.1.0 0.0.0.255
standby(config)#crypto ipsec transform-set trans esp-des esp-md5-hmac
standby(cfg-crypto-trans)#mode tunnel 定义加密图
定义加密图:匹配感兴趣流,转换集,配置peer (为实现冗余备份,分支需要与中心的多个边界建立vpn,先匹配的先建立vpn,然后依次建立【default:不加时,当活动链路down掉后,从首到尾依次检查;加上时,以“圆”的形式检查)
Branch上
branch(config)#crypto map cisco 10 ipsec-isakmp branch(config-crypto-map)#match address vpn
branch(config-crypto-map)#set transform-set trans
branch(config-crypto-map)#set peer 61.128.1.1 default
branch(config-crypto-map)#set peer 137.78.5.1
定义加密图:匹配感兴趣流,转换集,配置peer,启用反向路由注入,并给RRI动态产生的路由打上tag 10,解决链路备份的回包问题。
active上
active(config)#crypto map cisco 10 ipsec-isakmp active(config-crypto-map)#match address vpn
active(config-crypto-map)#set transform-set trans
active(config-crypto-map)#set peer 202.100.1.1 active(config-crypto-map)#reverse-route
active(config-crypto-map)#set reverse-route tag 10
standby上
standby(config)#crypto map cisco 10 ipsec-isakmp
standby(config-crypto-map)#match address vpn
standby(config-crypto-map)#set transform-set trans
standby(config-crypto-map)#set peer 202.100.1.1
standby(config-crypto-map)#reverse-route standby(config-crypto-map)#set
reverse-route tag 10
接口调用
接口调用加密图,当内网的通信点与vpn对端的通信点进行通信,会触发连接internet的接口(加密点),对数据加密,以保障数据在internet网络中传输时的安全,vpn对端接口则会解密、验证,如果认证通过,数据传输;
不通过,直接丢弃
Branch上
branch(config)#int f0/0
branch(config-if)#crypto map cisco active上
active(config)#int f0/1
active(config-if)#crypto map cisco standby上
standby(config)#int f0/1
standby(config-if)#crypto map cisco 在active和standby上配置route-map
利用route-map来匹配上tag 10的路由
active(config)#route-map s2o permit 10 active(config-route-map)#match tag 10
standby(config)#route-map s2o permit 10 standby(config-route-map)#match tag 10
在active和standby上将route-map在OSPF中通告
将route-map重发布进ospf,通告所有内网用户
active(config)#router ospf 1
active(config-router)#redistribute static route-map s2o subnets
standby(config)#router ospf 1
standby(config-router)#redistribute static route-map s2o subnets
4.测试链路是否建立成功
首先在active上查看加解密包的个数
再查看静态路由
RRI,反向路由注入,即指那一台路由器上有ipsec sa,做了启用的反向路由注入,就会在本地路由器上自动产生一条目标是对端通信点,下一跳为对端加密
点的静态路由。只有有ipsec sa才会产生,因为没有触发,所以没有加解密的包和产生路由
在branch上发起ping命令
发起ping命名,触发vpn策略
在active上查看加解密包的个数和静态路由
加解密包产生,触发了ipsec sa,产生静态路由
在inside上查看路由
内部网络收到静态路由,且下一跳为10.1.1.10,即说明分支与中心的active建立vpn
在standby上查看加解密包的个数和静态路由
Standby设备上没有加解密的包和产生路由,也说明分支与中心的active建立vpn
再在branch上发起ping命令
在isp上将f0/0接口shutdown
isp(config)#int f0/0
isp(config-if)#shutdown
将isp的f0/0口down掉,模拟vpn链路发生问题
然后再branch上查看
发现路由器上开始丢包,每10S发送一次DPD,5次尝试keepalive没有得到回应,则自动清掉相应的sa,和正常工作的peer建立ipsec隧道
在active上查看加解密包的个数和静态路由
DPD清除掉有问题的ipsec sa
再在standby上查看加解密包的个数和静态路由
加解密包产生,触发了ipsec sa,产生静态路由;DPD将vpn隧道切换
最后在inside上查看路由
内部收到静态路由,下一跳为10.1.1.20