NAT 和两个互联网提供商,如何配置故障转移

网络工程 思科 网络 故障转移
2021-07-09 14:02:26

请您帮我将 ISP2 设置为故障转移 Internet 提供商。配置如下:

ip source-route
!
ip cef
!
no ip domain lookup
no ipv6 cef
!
multilink bundle-name authenticated
!
voice-card 0
!
crypto pki token default removal timeout 0
redundancy
!
!
ip ssh rsa keypair-name SSH_KEYS
ip ssh version 2
!
interface Loopback10
 ip address 10.10.10.10 255.255.255.0
 ip nat inside
 ip virtual-reassembly in
!
interface Tunnel1
 description INT1
 ip address 10.7.1.1 255.255.255.252
 ip mtu 1400
 ip nat inside
 ip nat enable
 ip virtual-reassembly in
 tunnel source GigabitEthernet0/0.2
 tunnel destination 18.1.1.15
!
interface Tunnel99
 description INT2
 ip address 10.7.2.1 255.255.255.252
 ip nat inside
 ip virtual-reassembly in
 tunnel source GigabitEthernet0/0.2
 tunnel destination 8.2.1.201
!
interface GigabitEthernet0/0
 no ip address
 duplex auto
 speed auto
 media-type rj45
!
interface GigabitEthernet0/0.2
 description ISP1
 encapsulation dot1Q 2
 ip address 7.2.2.127 255.255.255.0
 ip nat outside
 ip virtual-reassembly in
!
interface GigabitEthernet0/0.3
 description ISP2
 encapsulation dot1Q 3
 ip address 7.1.0.46 255.255.255.252
 ip nat outside
 ip virtual-reassembly in
!
interface GigabitEthernet0/1
 no ip address
 duplex auto
 speed auto
 media-type rj45
!
interface GigabitEthernet0/1.10
 description LAN_TO_3750
 encapsulation dot1Q 10
 ip address 10.5.7.2 255.255.255.192
 ip nat inside
 ip virtual-reassembly in
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
!
ip nat inside source list 20 interface GigabitEthernet0/0.2 overload
ip nat inside source static udp 10.5.7.9 17566 7.2.2.127 17566 extendable
ip route 0.0.0.0 0.0.0.0 7.2.2.1 170
ip route 10.1.7.0 255.255.255.0 10.7.2.2 name INT2
ip route 10.1.2.0 255.255.255.128 10.7.1.2 name INT1
ip route 10.5.7.64 255.255.255.192 10.5.7.1
!
logging esm config
access-list 20 permit 10.5.7.0 0.0.0.255
access-list 20 permit 10.5.7.0 0.0.0.63
access-list 20 permit 10.1.2.0 0.0.0.128
access-list 20 permit 10.1.7.0 0.0.0.255
access-list 20 permit 10.1.2.0 0.0.0.255
access-list 30 permit 10.5.7.0 0.0.0.255
access-list 30 permit 10.1.2.0 0.0.0.255
access-list 69 permit 10.5.7.20
access-list 69 permit 10.5.7.9
!
route-map INT1 permit 10
!
1个回答

你是一个很好的方式离开这里。为了提供简单的故障转移,它绝对取决于您使用的硬件,一些 Cisco 路由器实现 NAT 的方式略有不同,这意味着在两个不同的设备上使用相同的配置,您的结果会有所不同。

例如;

在1941系列路由器上匹配NAT ACL时;不要在您的 ACL 中使用 permit any ,它不会起作用。

为了避免在这里解释网络的基本原理,我将假设您有一个主要和次要互联网电路,并且仅当主要遇到问题时才希望从主要到次要失败,同样我也将只对相同的网络进行 NAT。

首先,这是正确的;您已确定 NAT 的内部和外部接口:

!
interface GigabitEthernet0/1.10
description LAN
ip address 10.5.7.2 255.255.255.192
ip nat inside                     <----
!
interface GigabitEthernet0/0.2
 description ISP1
 ip address 7.2.2.127 255.255.255.0
 ip nat outside                    <----
!
interface GigabitEthernet0/0.3
description ISP2
ip address 7.1.0.46 255.255.255.252
ip nat outside                     <----
!

其次,您应该确定所有应该进行 NATTED 的网络;示例为 10 个空格;

!
ip access-list extended LAN
 permit ip 10.0.0.0 0.255.255.255 any
!

创建两个路由映射,将它们绑定到您的 nat 语句而不是列表,这允许您绑定故障转移。调用此路由映射中的列表并匹配 WAN 接口。这些路由映射说的是,如果源 ip 与 ACL 'LAN' 匹配并且 OUTBOUND 接口与映射中配置的内容匹配,请对其进行处理,我们正在执行 NAT。例子;

!
route-map PRIMARY permit 10
 match ip address LAN
 match interface GigabitEthernet0/0.2
!
route-map SECONDARY permit 10
 match ip address LAN
 match interface GigabitEthernet0/0.3
!

创建 SLA/跟踪以用作故障转移检测机制来故障转移您的路由。这才是真正的故障转移,之前配置的东西只是允许 NAT 从两个链接中发生。通过你的主电路 Ping google(或任何其他持续可访问的 IP)。

!
ip sla 1
icmp-echo 8.8.8.8 source-interface g0/0.2
ip sla schedule 1 life forever start-time now
track 1 ip sla 1 reachability
!

将您的曲目与您的路线联系起来。

!
ip route 8.8.8.8 255.255.255.255 g0/0.2 
ip route 0.0.0.0 0.0.0.0 7.2.2.1 track 1
ip route 0.0.0.0 0.0.0.0 g0/0.3 10
!

将您的路由映射绑定到您的 NAT,即配置您的 nat 规则,基本上就像您通常所做的那样。

!
ip nat inside source route-map PRIMARY interface g0/0.2 overload
ip nat inside source route-map SECONDARY interface g0/0.3 overload
!

有些路由器不需要这么多工程;在许多情况下,以下方法可以正常工作;请记住,硬件很重要!

!
interface GigabitEthernet0/1.10
description LAN
ip address 10.5.7.2 255.255.255.192
ip nat inside                     
!
interface GigabitEthernet0/0.2
 description ISP1
 ip address 7.2.2.127 255.255.255.0
 ip nat outside                    
!
interface GigabitEthernet0/0.3
description ISP2
ip address 7.1.0.46 255.255.255.252
ip nat outside                     
!
ip access-list extended LAN
 permit ip 10.0.0.0 0.255.255.255 any
!
ip sla 1
icmp-echo 8.8.8.8 source-interface g0/0.2
ip sla schedule 1 life forever start-time now
track 1 ip sla 1 reachability
!
ip route 8.8.8.8 255.255.255.255 g0/0.2 
ip route 0.0.0.0 0.0.0.0 7.2.2.1 track 1
ip route 0.0.0.0 0.0.0.0 g0/0.3 10
!
ip nat inside source list LAN interface g0/0.2 overload
ip nat inside source list LAN interface g0/0.3 overload
!

Cisco 路由器之间 NAT 的实现可能会有所不同,但 SLA 和增强的对象跟踪应该是相同的,“故障转移”是上述示例中首选出站路由的函数;ISP 1 将始终是首选,除非路由器在从该接口获取 ping 时无法访问 google。