如何定义从 LAN 设备通过 IPSec 端点到 Peer 的静态路由

网络工程 思科 路由 bgp cisco催化剂 cisco-isr
2021-07-16 15:26:37

从连接到 Cisco Catalyst 3850 并通过 Portchanneld 连接到 Cisco ISR 的 PC,我对与 BGP 连接的目的地执行 ping 操作。这对我行得通。

跟踪路径如下所示:

1: localhost (10.1.1.22)
2: gateway (10.1.1.18)
3: BGP Neigbhour (10.1.2.101)
4: destination IP (10.1.3.205)

在 ISR 上,我配置了一个用作 IPSec 端点的子设备。第 1 阶段出现,运营商确认第 1 阶段。现在我需要像加密那样更改我的 IP 路由:

1: localhost (10.1.1.22/28)
2: gateway (10.1.1.18/28)
3: IPSec subdevice (10.1.1.37/30)
4: BGP Neigbhour (10.1.2.101/30)
5: destination IP (10.1.3.205/27)

我怎样才能达到这个目标或在我的情况下有什么问题?

我的催化剂的配置:

sh run int gi1/0/7
!
interface GigabitEthernet1/0/7
 description PC1
 switchport access vlan 30
end

sh run int gi1/0/4
!
interface GigabitEthernet1/0/4
 description carrier1
 switchport trunk allowed vlan 331
 switchport mode trunk
end

sh run int gi1/0/1    
!
interface GigabitEthernet1/0/1
 description PortChannel ISR
 switchport trunk native vlan 10
 switchport mode trunk
 channel-group 1 mode on
end

这是 ISR 的配置

sh run int po1.331
!
interface Port-channel1.331
 description carrier1
 encapsulation dot1Q 331
 ip address 10.1.2.102 255.255.255.252
end

sh run int po1.30 
!
interface Port-channel1.30
 encapsulation dot1Q 30
 ip address 10.1.1.18 255.255.255.240
end

sh run int po1.202
!
interface Port-channel1.202
 description IPsec Interconnect
 encapsulation dot1Q 202
 ip address 10.1.1.37 255.255.255.252
 no ip redirects
 no ip proxy-arp
 crypto map test
end

也许我需要一个静态路由,通过 IPSec 子设备表示目标网络,然后到 BGP Neigbhour?我怎样才能做到这一点?

我尝试添加静态路由但不起作用:

ip route 10.1.3.192 255.255.255.224 10.1.1.37 

但是ios告诉我这是无效的,因为它是这个路由器。问题是 PC 连接的端口只接受解密的流量,但一位客户想要使用 IPSec 隧道进行加密。因此 ISR 应该是端点,解密流量并将其解密发送到 PC1 端口。

有关说明,请参阅此 Visio 图表:

在此处输入图片说明

这是来自 ISR 的 Cryptoconfig

crypto isakmp policy 1
 encr 3des
 hash md5
 authentication pre-share
 group 2
crypto isakmp key XXpeterpanXX address 10.1.3.238
crypto ipsec security-association lifetime seconds 86400
crypto ipsec transform-set ipcom esp-3des esp-md5-hmac 
 mode tunnel
crypto map test 10 ipsec-isakmp 
 description IPSec peer 
 set peer 10.1.3.238
 set transform-set ipcom 
 set pfs group2
 match address 120
 crypto map test
access-list 120 permit ip 10.1.1.36 0.0.0.3 10.1.3.192 0.0.0.31
2个回答

你问的对我来说没有意义。为什么要在跟踪中看到该 IP 地址?我唯一能想到的是,你要在每一端设置一个隧道接口?

所以你可以这样做:

您的路由器:

interface tunnel 0
 ip address 10.1.1.37 255.255.255.252
 tunnel source po1.331
 tunnel destination 10.1.2.101
 tunnel mode ipsec ipv4
 tunnel protection ipsec profile ENCRYPTTUNNEL

其他路由器:

interface tunnel 0
 ip address 10.1.1.38 255.255.255.252
 tunnel source g1  !<--or whatever the source interface is on that router
 tunnel destination 10.1.2.102
 tunnel mode ipsec ipv4
 tunnel protection ipsec profile ENCRYPTTUNNEL

然后您可以将 ISR 上的静态路由添加到网络:

ip route 10.1.3.192 255.255.255.224 10.1.1.38

即使有了所有这些,您仍将10.1.1.38在您的跟踪中看到一个跳跃,而不是10.1.1.37.

您可以尝试应用 NAT。

  1. 我认为您想首先从 interface po1.202. 据我所知,你不需要那个。
  2. 接下来创建一个 NAT 池,其中只包含您要使用的一个 IP 地址:

    ip nat pool VPN-Accepted-Address 10.1.1.37 10.1.1.37 netmask 255.255.255.252
    
  3. 现在有一个 ACL 来匹配去往的流量 10.1.3.192/27

    ip access-list extended NAT
     permit ip 10.1.1.16 0.0.0.15 10.1.3.192 0.0.0.31
    
  4. 在外部分配 NAT:

    int po1.331
     ip nat outside
    
  5. 在内部分配 NAT:

    int po1.30
     ip nat inside
    
  6. NAT 使所有匹配 ACL 的流量使用仅包含 10.1.1.37

    ip nat inside source list NAT pool VPN-Accepted-Address overload
    
  7. 将加密映射应用于外部接口:

     int po1.331
      crypto map test
    

显示来自 10.1.1.22 的 ip nat 翻译 ping