• IPSEC VXN 及 NAT BYPASS配置及详解


    实验目的

    1、熟悉NAT的工作原理。

    2、熟悉IPSEC VXN 的工作原理。

    3、利用NAT 帮助内网(即ospf 2区域)设备访问公网(ospf 1),同时利用VXN 保护内网通讯。

    实验拓扑

    接口IP配置

    1. R1(config)#interface loopback 0
    2. R1(config-if)#ip address 1.1.1.1 255.255.255.0
    3. R1(config)#interface e0/1
    4. R1(config-if)#ip address 12.12.12.1 255.255.255.0
    5. R1(config-if)#no shutdown
    6. R1(config-if)#interface e0/0
    7. R1(config-if)#ip address 192.168.15.1 255.255.255.0
    8. R1(config-if)#no shutdown
    9. R2(config)#interface loopback 0
    10. R2(config-if)#ip address 2.2.2.2 255.255.255.0
    11. R2(config)#interface e0/1
    12. R2(config-if)#ip address 12.12.12.2 255.255.255.0
    13. R2(config-if)#no shutdown
    14. R2(config-if)#interface e0/2
    15. R2(config-if)#ip address 23.23.23.2 255.255.255.0
    16. R2(config-if)#no shutdown
    17. R2(config-if)#interface e0/3
    18. R2(config-if)#ip address 24.24.24.2 255.255.255.0
    19. R2(config-if)#no shutdown
    20. R3(config)#interface loopback 0
    21. R3(config-if)#ip address 3.3.3.3 255.255.255.0
    22. R3(config)#interface e0/2
    23. R3(config-if)#ip address 23.23.23.3 255.255.255.0
    24. R3(config-if)#no shutdown
    25. R3(config-if)#interface e0/0
    26. R3(config-if)#ip address 192.168.36.3 255.255.255.0
    27. R3(config-if)#no shutdown
    28. R4(config-if)#interface e0/3
    29. R4(config-if)#ip address 24.24.24.4 255.255.255.0
    30. R4(config-if)#no shutdown
    31. R4(config-if)#interface e0/0
    32. R4(config-if)#ip address 192.168.47.4 255.255.255.0
    33. R4(config-if)#no shutdown
    34. R4(config)#interface loopback 0
    35. R4(config-if)#ip address 4.4.4.4 255.255.255.0
    36. R5(config)#interface loopback 0
    37. R5(config-if)#ip address 10.5.5.5 255.255.255.0
    38. R5(config)#interface e0/0
    39. R5(config-if)#ip address 192.168.15.5 255.255.255.0
    40. R5(config-if)#no shutdown
    41. R6(config)#interface e0/0
    42. R6(config-if)#ip address 192.168.36.6 255.255.255.0
    43. R6(config-if)#no shutdown
    44. R6(config)#interface loopback 0
    45. R6(config-if)#ip address 10.6.6.6 255.255.255.0
    46. R7(config)#interface e0/0
    47. R7(config-if)#ip address 192.168.47.7 255.255.255.0
    48. R7(config-if)#no shutdown
    49. R7(config)#interface loopback 0
    50. R7(config-if)#ip address 10.7.7.7 255.255.255.0

    底层协议配置:

    1. R1(config)#router ospf 2
    2. R1(config-router)#network 192.168.15.0 0.0.0.255 area 0
    3. R1(config-router)#router ospf 1
    4. R1(config-router)#network 12.12.12.0 0.0.0.255 area 0
    5. R2(config)#router ospf 1
    6. R2(config-router)#network 2.2.2.2 0.0.0.0 area 0
    7. R2(config-router)#network 23.23.23.0 0.0.0.255 area 0
    8. R2(config-router)#network 24.24.24.0 0.0.0.255 area 0
    9. R2(config-router)#network 12.12.12.0 0.0.0.255 area 0
    10. R3(config)#router ospf 1
    11. R3(config-router)#net 23.23.23.0 0.0.0.255 area 0
    12. R3(config-router)#router ospf 2
    13. R3(config-router)#network 192.168.36.0 0.0.0.255 area 0
    14. R4(config)#router ospf 1
    15. R4(config-router)#network 24.24.24.0 0.0.0.255 area 0
    16. R4(config-router)#router ospf 2
    17. R4(config-router)#network 192.168.47.0 0.0.0.255 area 0
    18. R5(config)#router ospf 1
    19. R5(config-router)#network 192.168.15.0 0.0.0.255 area 0
    20. R5(config-router)#network 10.5.5.5 0.0.0.0 area 0
    21. R6(config)#router ospf 2
    22. R6(config-router)#network 10.6.6.6 0.0.0.0 area 0
    23. R6(config-router)#network 192.168.36.0 0.0.0.255 area 0
    24. R7(config)#router ospf 1
    25. R7(config-router)#network 10.7.7.7 0.0.0.0 area 0
    26. R7(config-router)#network 192.168.47.0 0.0.0.255 area 0

    检查ospf邻接关系建立情况,确保R1 R3 R4 确保学到各自内网路由。此时R5 R6 R7 是没办法和公网的2.2.2.2通讯的。

    1. R1#show ip os neighbor
    2. Neighbor ID Pri State Dead Time Address Interface
    3. 2.2.2.2 1 FULL/BDR 00:00:36 12.12.12.2 Ethernet0/1
    4. 10.5.5.5 1 FULL/BDR 00:00:35 192.168.15.5 Ethernet0/0
    5. R3#show ip ospf neighbor
    6. Neighbor ID Pri State Dead Time Address Interface
    7. 10.6.6.6 1 FULL/BDR 00:00:35 192.168.36.6 Ethernet0/0
    8. 2.2.2.2 1 FULL/DR 00:00:36 23.23.23.2 Ethernet0/2
    9. R4#show ip ospf neighbor
    10. Neighbor ID Pri State Dead Time Address Interface
    11. 10.7.7.7 1 FULL/BDR 00:00:33 192.168.47.7 Ethernet0/0
    12. 2.2.2.2 1 FULL/DR 00:00:32 24.24.24.2 Ethernet0/3
    1. R1#show ip route ospf
    2. Gateway of last resort is not set
    3. 2.0.0.0/32 is subnetted, 1 subnets
    4. O 2.2.2.2 [110/11] via 12.12.12.2, 00:12:20, Ethernet0/1
    5. 10.0.0.0/32 is subnetted, 1 subnets
    6. O 10.5.5.5 [110/11] via 192.168.15.5, 00:10:20, Ethernet0/0
    7. 23.0.0.0/24 is subnetted, 1 subnets
    8. O 23.23.23.0 [110/20] via 12.12.12.2, 00:12:20, Ethernet0/1
    9. 24.0.0.0/24 is subnetted, 1 subnets
    10. O 24.24.24.0 [110/20] via 12.12.12.2, 00:12:20, Ethernet0/1
    11. R3#show ip route ospf
    12. Gateway of last resort is not set
    13. 2.0.0.0/32 is subnetted, 1 subnets
    14. O 2.2.2.2 [110/11] via 23.23.23.2, 00:12:19, Ethernet0/2
    15. 10.0.0.0/32 is subnetted, 1 subnets
    16. O 10.6.6.6 [110/11] via 192.168.36.6, 00:06:47, Ethernet0/0
    17. 12.0.0.0/24 is subnetted, 1 subnets
    18. O 12.12.12.0 [110/20] via 23.23.23.2, 00:12:19, Ethernet0/2
    19. 24.0.0.0/24 is subnetted, 1 subnets
    20. O 24.24.24.0 [110/20] via 23.23.23.2, 00:12:19, Ethernet0/2
    21. R4#show ip route ospf
    22. Gateway of last resort is not set
    23. 2.0.0.0/32 is subnetted, 1 subnets
    24. O 2.2.2.2 [110/11] via 24.24.24.2, 00:11:38, Ethernet0/3
    25. 10.0.0.0/32 is subnetted, 1 subnets
    26. O 10.7.7.7 [110/11] via 192.168.47.7, 00:06:26, Ethernet0/0
    27. 12.0.0.0/24 is subnetted, 1 subnets
    28. O 12.12.12.0 [110/20] via 24.24.24.2, 00:11:38, Ethernet0/3
    29. 23.0.0.0/24 is subnetted, 1 subnets
    30. O 23.23.23.0 [110/20] via 24.24.24.2, 00:11:38, Ethernet0/3

    R1 R3 R4 配置静态缺省指向ISP,将其通过ospf发送给内网。

    1. R1(config)#ip route 0.0.0.0 0.0.0.0 12.12.12.2
    2. R1(config)#router ospf 2
    3. R1(config-router)#default-information originate
    4. R3(config)#ip route 0.0.0.0 0.0.0.0 23.23.23.2
    5. R3(config)#router ospf 2
    6. R3(config-router)#default-information originate
    7. R4(config)#ip route 0.0.0.0 0.0.0.0 24.24.24.2
    8. R4(config)#router ospf 2
    9. R4(config-router)#default-information originate

    如上配置完成后,请校验R5 R6 R7 是否通过OSPF 获得缺省路由。
     

    1. R5#show ip route ospf
    2. Gateway of last resort is 192.168.15.1 to network 0.0.0.0
    3. O*E2 0.0.0.0/0 [110/1] via 192.168.15.1, 00:02:22, Ethernet0/0
    4. R6#show ip route ospf
    5. Gateway of last resort is 192.168.36.3 to network 0.0.0.0
    6. O*E2 0.0.0.0/0 [110/1] via 192.168.36.3, 00:01:30, Ethernet0/0
    7. R7#show ip route ospf
    8. Gateway of last resort is 192.168.47.4 to network 0.0.0.0
    9. O*E2 0.0.0.0/0 [110/1] via 192.168.47.4, 00:01:57, Ethernet0/0

    同时我们发现R5 R6 R7 依旧无法访问公网,数据包能出去,但是无法返回。

    1. R6#ping 2.2.2.2
    2. Type escape sequence to abort.
    3. Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
    4. .....
    5. Success rate is 0 percent (0/5)

    R1 R3 R4 配置NAT。

    1. R1(config)#interface e0/0
    2. R1(config-if)#ip nat inside
    3. R1(config-if)#interface e0/1
    4. R1(config-if)#ip nat outside
    5. R1(config)#access-list 105 deny ip 10.5.5.0 0.0.0.255 10.6.6.0 0.0.0.255
    6. R1(config)#access-list 105 deny ip 10.5.5.0 0.0.0.255 10.7.7.0 0.0.0.255
    7. R1(config)#access-list 105 permit ip 10.5.5.0 0.0.0.255 any
    8. R1(config)#ip nat inside source list 105 interface e0/1 overload
    9. R3(config)#interface e0/0
    10. R3(config-if)#ip nat inside
    11. R3(config-if)#interface e0/2
    12. R3(config-if)#ip nat outside
    13. R3(config)#access-list 106 deny ip 10.6.6.0 0.0.0.255 10.5.5.0 0.0.0.255
    14. R3(config)#access-list 106 permit ip 10.6.6.0 0.0.0.255 any
    15. R3(config)#ip nat inside source list 106 interface e0/2 overload
    16. R4(config)#interface e0/0
    17. R4(config-if)#ip nat inside
    18. R4(config-if)#interface e0/3
    19. R4(config-if)#ip nat outside
    20. R4(config)#access-list 107 deny ip 10.7.7.0 0.0.0.255 10.5.5.0 0.0.0.255
    21. R4(config)#access-list 107 permit ip 10.7.7.0 0.0.0.255 any
    22. R4(config)#ip nat inside source list 107 interface e0/3 overload

    R1 R3 R4 上创建TUNNEL,完成路由信息的共享。

    1. R1(config)#interface tunnel 13
    2. R1(config-if)#ip address 172.16.13.1 255.255.255.0
    3. R1(config-if)#tunnel source e0/1
    4. R1(config-if)#tunnel destination 23.23.23.3
    5. R1(config-if)#tunnel mode gre ip
    6. R1(config-if)#ip ospf 2 area 0
    7. R1(config)#interface tunnel 14
    8. R1(config-if)#ip address 172.16.14.1 255.255.255.0
    9. R1(config-if)#tunnel source e0/1
    10. R1(config-if)#tunnel destination 24.24.24.4
    11. R1(config-if)#tunnel mode gre ip
    12. R1(config-if)#ip ospf 2 area 2
    13. R3(config)#interface tunnel 13
    14. R3(config-if)#ip address 172.16.13.3 255.255.255.0
    15. R3(config-if)#tunnel source e0/2
    16. R3(config-if)#tunnel destination 12.12.12.1
    17. R3(config-if)#tunnel mode gre ip
    18. R3(config-if)#ip ospf 2 area 0
    19. R4(config)#interface tunnel 14
    20. R4(config-if)#ip address 172.16.14.4 255.255.255.0
    21. R4(config-if)#tunnel source e0/3
    22. R4(config-if)#tunnel destination 12.12.12.1
    23. R4(config-if)#tunnel mode gre ip
    24. R4(config-if)#ip ospf 2 area 0

    确认R5 R6 R7相互学习路由,且能PING 通。

    1. R5#show ip route ospf
    2. Gateway of last resort is 192.168.15.1 to network 0.0.0.0
    3. O*E2 0.0.0.0/0 [110/1] via 192.168.15.1, 00:38:13, Ethernet0/0
    4. 10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
    5. O 10.6.6.6/32 [110/1021] via 192.168.15.1, 00:06:20, Ethernet0/0
    6. O 10.7.7.7/32 [110/1021] via 192.168.15.1, 00:01:59, Ethernet0/0
    7. 172.16.0.0/24 is subnetted, 2 subnets
    8. O 172.16.13.0 [110/1010] via 192.168.15.1, 00:13:26, Ethernet0/0
    9. O 172.16.14.0 [110/1010] via 192.168.15.1, 00:01:59, Ethernet0/0
    10. O 192.168.36.0/24 [110/1020] via 192.168.15.1, 00:06:20, Ethernet0/0
    11. O 192.168.47.0/24 [110/1020] via 192.168.15.1, 00:01:59, Ethernet0/0
    1. R5#ping 10.6.6.6
    2. Type escape sequence to abort.
    3. Sending 5, 100-byte ICMP Echos to 10.6.6.6, timeout is 2 seconds:
    4. !!!!!
    5. Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
    6. R5#ping 10.7.7.7
    7. Type escape sequence to abort.
    8. Sending 5, 100-byte ICMP Echos to 10.7.7.7, timeout is 2 seconds:
    9. !!!!!
    10. Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms

    完成R1 R3 R4 上的IPSEC VPN 通讯。

    1. R1(config)#crypto isakmp enable
    2. R1(config)#crypto isakmp policy 1
    3. R1(config-isakmp)#authentication pre-share
    4. R1(config-isakmp)#encryption des
    5. R1(config-isakmp)#hash md5
    6. R1(config-isakmp)#group 1
    7. R1(config)#crypto isakmp key cisco address 172.16.13.3
    8. R1(config)#crypto isakmp key cisco address 172.16.14.4
    9. R1(config)#ip access-list extended vpn
    10. R1(config-ext-nacl)#permit ip 10.5.5.0 0.0.0.255 10.6.6.0 0.0.0.255
    11. R1(config-ext-nacl)#permit ip 10.5.5.0 0.0.0.255 10.7.7.0 0.0.0.255
    12. R1(config)#crypto ipsec transform-set r1-tr esp-des esp-md5-hmac
    13. R1(cfg-crypto-trans)#mode tunnel
    14. R1(config)#crypto map r1-map 1 ipsec-isakmp
    15. R1(config-crypto-map)#set peer 172.16.13.3
    16. R1(config-crypto-map)#set peer 172.16.14.4
    17. R1(config-crypto-map)#set transform-set r1-tr
    18. R1(config-crypto-map)#match address vpn
    19. R1(config)#interface tunnel 13
    20. R1(config-if)#crypto map r1-map
    21. R1(config-if)#interface tunnel 14
    22. R1(config-if)#crypto map r1-map
    23. R3(config)#crypto isakmp enable
    24. R3(config)#crypto isakmp policy 1
    25. R3(config-isakmp)#authentication pre-share
    26. R3(config-isakmp)#encryption des
    27. R3(config-isakmp)#hash md5
    28. R3(config-isakmp)#group 1
    29. R3(config)#crypto isakmp key cisco address 172.16.13.1
    30. R3(config)#ip access-list extended vpn
    31. R3(config-ext-nacl)#permit ip 10.6.6.0 0.0.0.255 10.5.5.0 0.0.0.255
    32. R3(config)#crypto ipsec transform-set r3-tr esp-des esp-md5-hmac
    33. R3(cfg-crypto-trans)#mode tunnel
    34. R3(config)#crypto map r3-map 1 ipsec-isakmp
    35. R3(config-crypto-map)#set peer 172.16.13.1
    36. R3(config-crypto-map)#set transform-set r3-tr
    37. R3(config-crypto-map)#match address vpn
    38. R3(config)#interface tunnel 13
    39. R3(config-if)#crypto map r3-map
    40. R4(config)#crypto isakmp enable
    41. R4(config)#crypto isakmp policy 1
    42. R4(config-isakmp)#authentication pre-share
    43. R4(config-isakmp)#encryption des
    44. R4(config-isakmp)#hash md5
    45. R4(config-isakmp)#group 1
    46. R4(config)#crypto isakmp key cisco address 172.16.14.1
    47. R4(config)#ip access-list extended vpn
    48. R4(config-ext-nacl)#permit ip 10.7.7.0 0.0.0.255 10.5.5.0 0.0.0.255
    49. R4(config)#crypto ipsec transform-set r4-tr esp-des esp-md5-hmac
    50. R4(cfg-crypto-trans)#mode tunnel
    51. R4(config)#crypto map r4-map 1 ipsec-isakmp
    52. R4(config-crypto-map)#set peer 172.16.14.1
    53. R4(config-crypto-map)#set transform-set r4-tr
    54. R4(config-crypto-map)#match address vpn
    55. R4(config)#interface tunnel 14
    56. R4(config-if)#crypto map r4-map

    完成如上配置后,R5 R6,R5 R7 用PING 做连通性测试。

    1. R5#ping 10.6.6.6 source 10.5.5.5
    2. Type escape sequence to abort.
    3. Sending 5, 100-byte ICMP Echos to 10.6.6.6, timeout is 2 seconds:
    4. Packet sent with a source address of 10.5.5.5
    5. .!!!!
    6. Success rate is 80 percent (4/5), round-trip min/avg/max = 2/2/3 ms
    7. R5#ping 10.7.7.7 source 10.5.5.5
    8. Type escape sequence to abort.
    9. Sending 5, 100-byte ICMP Echos to 10.7.7.7, timeout is 2 seconds:
    10. Packet sent with a source address of 10.5.5.5
    11. !!!!!
    12. Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
    1. R1#show crypto engine connections active
    2. Crypto Engine Connections
    3. ID Type Algorithm Encrypt Decrypt LastSeqN IP-Address
    4. 1 IPsec DES+MD5 0 9 9 172.16.13.1
    5. 2 IPsec DES+MD5 9 0 0 172.16.13.1
    6. 3 IPsec DES+MD5 0 5 5 172.16.14.1
    7. 4 IPsec DES+MD5 5 0 0 172.16.14.1
    8. 1001 IKE MD5+DES 0 0 0 172.16.13.1
    9. 1002 IKE MD5+DES 0 0 0 172.16.14.1

    如上现象表明VXN 已经工作,且对传递数据进行了加密、解密。

  • 相关阅读:
    从一坨代码说起
    不要动 WindowsApps 文件夹的权限以及更新 win10 版本
    南大通用数据库-Gbase-8a-学习-21-Oracle到Gbase8a迁移工具orato8a
    MySQL大表直接复制文件的copy方式
    camtasia 2023怎么导出mp4
    文献综述笔记
    嵌入式图像处理机器视觉库YMCV使用
    【Python深度学习】Python全栈体系(三十一)
    Python压缩解压–tarfile
    Vue组件的八个钩子函数
  • 原文地址:https://blog.csdn.net/qq_43210022/article/details/125858669