NAT应用于HSRP环境

本文涉及的产品
公网NAT网关,每月750个小时 15CU
简介:
一、HSRP中应用NAT的情况
当有两个运行HSRP的路由器时,如果活动的路由器出现故障,备用路由器会接管。然而,如果使用NAT的时候出现这种情况,它会切断通过使用动态NAT的活动路由器的所有连接,而且用户将需要重新建立这些连接。该如何使用HSRP和SNAT以保持这些NAT转换呢?
二、什么是SNAT?
  • 对于SNAT到底代表什么会产生一些混淆,Google搜索将返回各种不同的定义。根据微软的说法,SNAT代表Secure NAT(安全NAT)而且在ISA Server上可用。除此之外,SNAT可以代表Source NAT(源NAT)。然而,按照Cisco的说法,SNAT代表Stateful NAT(状态NAT)。
  • SNAT包括两个或更多作为一个组执行NAT功能的路由器。这些NAT路由器在它们的NAT转换数据库中相互交换信息。可以使用show ip nat translations命令查看这些信息,该命令的输出列出了协议,内部全局IP,内部本地IP,外部本地IP以及外部全局IP。
  • 无论何时一个新的NAT连接通过某个NAT路由器时,路由器将该信息中继给SNAT组中的其它路由器。但是这些路由器并非只是交换NAT IP流的IP 地址;它们还交换这些流的TCP状态。备用路由器已经创建了NAT转换表并且等待活动路由器出现故障。
  • 换句话说,这个NAT流信息交换的目的是保证,如果活动NAT路由器出现故障,某个备用NAT能够接管。尽管可以配置SNAT为主/备份模式,但是它在用HSRP配置的时候工作得很好。
三、Cisco分阶段发布的SNAT
  • 第一个阶段,在Cisco in IOS 12.2(13)T的发布中,它只对在应用层中不包含IP地址的协议有效。但是对于Cisco IOS 12.3(7)T,SNAT支持在应用层中嵌入IP信息的应用,例如FTP。除此之外,Cisco在IOS 12.4(4)T中为SNAT发布了一些可伸缩的增强。
四、如何配置SNAT?
  要配置带HSRP的SNAT,首先在HSRP接口使用常规的HSRP standby命令。还需要以组名 SNATHSRP配置一个HSRP路由器以使用SNAT HSRP API。
  你的standby命令应该类似于:
standby name SNATHSRP
standby ip 10.10.10.1
    在退出接口配置模式之后,输入ip nat stateful命令;确保它包括相同的 SNATHSRP 组名。Mapping ID 命令用于指定本地SNAT路由器是否分发本地被创建的nat条目到对端 SNAT router,这里是一个例子:
ip nat stateful id 1
redundancy SNATHSRP
mapping-id 10
  现在可以输入你的标准NAT命令以建立你的转换池。这里是一个例子:
access-list 100 permit ip 192.168.1.0 0.0.0.255 any
ip nat pool snatpool1 155.1.45.1 155.1.45.254 prefix-length 24
ip nat inside source list 100 pool snatpool1 mapping-id 10 overload
  最后,配置SNAT和HSRP池中的其它路由器以进行通信。之后,可以使用show ip nat translations,show ip nat statistics以及show ip snat这样的附加NAT命令。
  在发生故障的时候结合使用SNAT和HSRP以保持NAT转换。备用路由器可以加入并接管活动的任务,用户不会发现出现了故障。


 

四、实验配置
 
【实验拓扑】

 

【实验要求】

1、按照上图配置好网络以及HSRP
2、设置HSRP的NAT
3、验证时通过R6 telnet R1,保证在R4的s0/0接口中断的情况下,telnet依然可以进行而无需重新连接

 
【实验配置】
R1:
interface Serial 0/0
encapsulation frame-relay
no frame-relay inverse-arp
ip address 155.1.0.1 255.255.255.0
frame-relay map ip 155.1.0.5 105 broadcast
frame-relay map ip 155.1.0.4 104 broadcast
ip ospf network broadcast
no shutdown
!
router ospf 1
router-id 150.1.1.1
network 155.1.0.1 0.0.0.0 area 0
R4:
interface E 0/1
ip address 155.1.100.4 255.255.255.0
standby 1 name GROUP1
standby 1 ip 155.1.100.254
standby 1 preempt
standby 1 priority 110
standby 1 track Serial 0/0 20
no shutdown
!
interface Serial 0/0
encapsulation frame-relay
no frame-relay inverse-arp
ip address 155.1.0.4 255.255.255.0
frame-relay map ip 155.1.0.5 401 broadcast
frame-relay map ip 155.1.0.1 401
ip ospf priority 0
ip ospf network broadcast
no shutdown
!
interface Loopback0
ip address 150.1.45.4 255.255.255.0
!
router ospf 1
router-id 150.1.4.4
redistribute connected subnets metric 400
network 155.1.0.4 0.0.0.0 area 0
R5:
interface E 0/0
ip address 155.1.100.5 255.255.255.0
standby 1 name GROUP1
standby 1 ip 155.1.100.254
standby 1 preempt
standby 1 priority 100
no shut
!
interface Serial 0/0
encapsulation frame-relay
no frame-relay inverse-arp
ip address 155.1.0.5 255.255.255.0
frame-relay map ip 155.1.0.1 501 broadcast
frame-relay map ip 155.1.0.4 501
ip ospf network broadcast
ip ospf priority 0
no shutdown
!
interface Loopback0
ip address 150.1.45.5 255.255.255.0
!
router ospf 1
router-id 150.1.5.5
network 155.1.0.5 0.0.0.0 area 0
redistribute connected subnets metric 500
R6:
interface G 0/0
ip address 155.1.100.6 255.255.255.0
no shutdown
!
ip route 0.0.0.0 0.0.0.0 155.1.100.254
NAT 配置
----------------------------------------------------------------------------------
R5:
interface Eth 0/0
ip nat inside
!
interface Serial 0/0
ip nat outside
!
access-list 100 permit ip 155.1.100.0 0.0.0.255 any
定义允许内部的地址
!
ip nat pool POOL 150.1.45.1 150.1.45.254 prefix 24
定义被转换的地址池
!

 
ip nat stateful id 1
redundancy GROUP1
mapping-id 10
定义状态NAT,指定standby name,并且允许本地SNAT路由器分发nat条目到对端NAT
!
ip nat inside source list 100 pool POOL mapping-id 10
做NAT配置,并设置mapping-id
R4:
interface Ethernet 0/1
ip nat inside
!
interface Serial 0/0
ip nat outside
!
access-list 100 permit ip 155.1.100.0 0.0.0.255 any
!
ip nat pool POOL 150.1.45.1 150.1.45.254 prefix 24
!
ip nat stateful id 1
redundancy GROUP1
mapping-id 10
!
ip nat inside source list 100 pool POOL mapping-id 10

 
【实验验证】
R4#show ip snat distributed
Stateful NAT Connected Peers
SNAT: Mode IP-REDUNDANCY :: ACTIVE
: State READY
: Local Address 155.1.100.4
: Local NAT id 1
: Peer Address 155.1.100.5
: Peer NAT id 1
: Mapping List 100
R5#show ip snat distributed
Stateful NAT Connected Peers
SNAT: Mode IP-REDUNDANCY :: STANDBY
: State READY
: Local Address 155.1.100.5
: Local NAT id 1
: Peer Address 155.1.100.4
: Peer NAT id 1
: Mapping List 100
R6#telnet 155.1.0.1
Trying 155.1.0.1 ... Open
R1>

 
通过R4与R5能够看到相同的条目
R4#show ip nat translations
Pro Inside global Inside local Outside local Outside global
tcp 150.1.45.1:24986 155.1.100.6:24986 155.1.0.1:23 155.1.0.1:23
--- 150.1.45.1 155.1.100.6 --- ---

 
R5#show ip nat translations
Pro Inside global Inside local Outside local Outside global
tcp 150.1.45.1:24986 155.1.100.6:24986 155.1.0.1:23 155.1.0.1:23
--- 150.1.45.1 155.1.100.6 --- -

 
R4# conf t
Enter configuration commands, one per line. End with CNTL/Z.
R4(config)# interface serial 0/0
R4(config-if)# shutdown
R5# show standby
Ethernet0/0 - Group 1
State is Active
R5变成了active
2 state changes, last state change 00:00:26
Virtual IP address is 155.1.100.254
Active virtual MAC address is 0000.0c07.ac01
Local virtual MAC address is 0000.0c07.ac01 (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 0.024 secs
Preemption enabled
Active router is local
Standby router is 155.1.100.4, priority 90 (expires in 8.020 sec)
Priority 100 (default 100)
IP redundancy name is "GROUP1" (cfgd)
R5# show ip nat translations
Pro Inside global Inside local Outside local Outside global
tcp 150.1.45.1:33932 155.1.100.6:33932 155.1.0.1:23 155.1.0.1:23
--- 150.1.45.1 155.1.100.6 --- ---
R5#
R6# telnet 155.1.0.1
Trying 155.1.0.1 ... Open
User Access Verification

 
Password:
R1>
R1>
R1>
R1>
连接的telnet一直没有断开

【下面测试普通NAT带来的效果】
NAT 配置
----------------------------------------------------------------------------------
R5:
interface Eth 0/0
ip nat inside
!
interface Serial 0/0
ip nat outside
!
access-list 100 permit ip 155.1.100.0 0.0.0.255 any
定义允许内部的地址
!
ip nat pool POOL 150.1.45.1 150.1.45.254 prefix 24
定义被转换的地址池
!

 
ip nat stateful id 1
redundancy GROUP1
mapping-id 10
定义状态NAT,指定standby name,并且允许本地SNAT路由器分发nat条目到对端NAT
!
ip nat inside source list 100 pool POOL mapping-id 10
R4:
interface Ethernet 0/1
ip nat inside
!
interface Serial 0/0
ip nat outside
!
access-list 100 permit ip 155.1.100.0 0.0.0.255 any
!
ip nat pool POOL 150.1.45.1 150.1.45.254 prefix 24
!
ip nat stateful id 1
redundancy GROUP1
mapping-id 10
!
ip nat inside source list 100 pool POOL mapping-id 10

 
验证:

 
R6#telnet 155.1.0.1
先tenet到R1上
Trying 155.1.0.1 ... Open
User Access Verification
Password:
R1>
R1>
R1>
R1>
R1>exit

 
[Connection to 155.1.0.1 closed by foreign host]

 
然后再R4上手动shutdown s0/0接口
看上面的高亮显示,连接被重置,此时nat也将失效


本文转自zcm8483 51CTO博客,原文链接:http://blog.51cto.com/haolun/993034
相关文章
|
安全 网络协议 网络安全
思科防火墙应用NAT
思科防火墙应用NAT
113 0
思科防火墙应用NAT
|
弹性计算 容灾 网络安全
VPC+NAT 网络实现多应用共享公网带宽|学习笔记
快速学习 VPC+NAT 网络实现多应用共享公网带宽
164 0
VPC+NAT 网络实现多应用共享公网带宽|学习笔记
|
机器学习/深度学习 缓存 负载均衡
LVS 的 NAT 模型实战应用(二)|学习笔记
快速学习 LVS 的 NAT 模型实战应用
96 0
LVS 的 NAT 模型实战应用(二)|学习笔记
|
负载均衡 网络架构 开发者
LVS 的 NAT 模型实战应用(三)|学习笔记
快速学习 LVS 的 NAT 模型实战应用
54 0
LVS 的 NAT 模型实战应用(三)|学习笔记
|
机器学习/深度学习 缓存 负载均衡
LVS的NAT模型实战应用|学习笔记
快速学习LVS的NAT模型实战应用
112 0
LVS的NAT模型实战应用|学习笔记
|
负载均衡 网络协议 算法
LVS的NAT模型实战应用(一)|学习笔记
快速学习LVS的NAT模型实战应用
86 0
LVS的NAT模型实战应用(一)|学习笔记
|
机器学习/深度学习 缓存 负载均衡
LVS的NAT模型实战应用
一、具体来实现LVS 二、实现图 三、作业
LVS的NAT模型实战应用
|
机器学习/深度学习 算法 大数据
Nat. Commun. | 机器学习在化学发现中的应用
Nat. Commun. | 机器学习在化学发现中的应用
244 0
Nat. Commun. | 机器学习在化学发现中的应用
|
机器学习/深度学习 人工智能 算法
Nat. Rev. Neurol. | 机器学习在神经退行性疾病诊断和治疗中的应用
Nat. Rev. Neurol. | 机器学习在神经退行性疾病诊断和治疗中的应用
137 0
Nat. Rev. Neurol. | 机器学习在神经退行性疾病诊断和治疗中的应用
|
机器学习/深度学习 编解码 算法
Nat. Light | 深度学习在全息和相干成像中的应用
Nat. Light | 深度学习在全息和相干成像中的应用
264 0
Nat. Light | 深度学习在全息和相干成像中的应用