<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

静态NAT 这种类型的NAT是为了在本地和全球地址问允许一对一映射而设计的。需要记住的是,静态NAT需要网络中的每台主机都拥有一个真实的因特网IP地址。

动态NAT 这种类型的NAT可以实现映射一个未注册IP地址到注册lP地址池中的一个注册IP地址。你不必要像使用静态NAT那样,在路由器上静态映射内部到外部的地址,但是你必须保证拥有足够的真实IP,保证每个在因特网中收发包的用户都有真实的IP可用。

复用 这是最流行的NAT配置类型。复用实际上是动态NAT的一种形式,它映射多个未注册的IP地址到单独一个注册的IP地址 —多对一 通过使用不同的端口。现在,这种方式为什么这么特别?好的,因为它也被称为端口地址映射(PAT)。通过使用PAT(NAT复用),可实现上千个用户仅通过一个真实的仝球IP地址连接到因特网———多么聪明,不是吗?认真地讲,使用NAT复用是我们至今在互联网上没有使用完合法IP地址的真实原囚。真的一我不是在开玩笑。

 

静态NAT配置

实验目的

通过本实验可以掌握

1)静态NAT的特征

2)静态NAT基本配置力调试

拓扑结构

实验拓扑如图

 

 

 

实验步骤: 基本配置

 

Router>enable

Router#configure t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#hostname r1

r1(config)#enable secret ccna

r1(config)#interface fastEthernet 0/0

r1(config-if)#ip add 192.168.1.1 255.255.255.0

r1(config-if)#no shutdown

r1(config-if)#line vty 0 4

r1(config-line)#login

r1(config-line)#password ccna

r1(config-line)#exit

r1(config)#interface serial 0/3/0

r1(config-if)#ip add 202.96.1.1 255.255.255.0

r1(config-if)#no shutdown

 

r1(config-if)#clock rate 56000

r1(config-if)#exit

r1#copy running-config startup-config

Destination filename [startup-config]?

Building configuration...

[OK]

r1#

 

Router>enable

Router#configure t

Router(config)#hostname r2

r2(config)#enable secret ccnp

r2(config)#interface fastEthernet 0/0

r2(config-if)#ip add <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />1.0.0.1 255.0.0.0

r2(config-if)#no shutdown

r2(config-if)#line vty 0 4

r2(config-line)#login

r2(config-line)#password ccnp

r2(config-line)#exit

r2(config)#interface serial 0/3/0

r2(config-if)#ip add 202.96.1.2 255.255.255.0

r2(config-if)#no shutdown

r2(config-if)#exit

r2(config)#exit

r1#copy running-config startup-config

Destination filename [startup-config]?

Building configuration...

[OK]

r2#ping 202.96.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 202.96.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 31/31/32 ms

r2#
 
 
静态NAT配置

1)步骤1:配置路由器R1 提供NAT 服务

R1(config)#ip nat inside source static 192.168.1.1 202.96.1.3

//配置静态NAT 映射

R1(config)#ip nat inside source static 192.168.1.2 202.96.1.4

R1(config)#interface f0/0

R1(config-if)#ip nat inside

//配置NAT 内部接口

R1(config)#interface s0/3/0

R1(config-if)#ip nat outside

//配置NAT 外部接口

R1(config)#router rip

R1(config-router)#version 2

R1(config-router)#network 192.168.1.0

R1(config-router)#network 202.96.1.0

2)步骤2:配置路由器R2

R2(config)#router rip

R2(config-router)#version 2

R2(config-router)#network 202.96.1.0

R2(config-router)#network 2.0.0.0
 
实验调试

PC1 上访问1.0.0.1(路由器R2 的环回接口),调试结果如下:

1debug ip nat

NAT: s=192.168.1.2->202.96.1.4, d=1.0.0.1 [5]

 

NAT*: s=1.0.0.1, d=202.96.1.4->192.168.1.2 [200]

 

NAT: s=192.168.1.2->202.96.1.4, d=1.0.0.1 [6]

 

NAT*: s=1.0.0.1, d=202.96.1.4->192.168.1.2 [201]

 

以上输出表明了NAT 的转换过程。首先把私有地址“192.168.1.1”和“192.168.1.2”
分别转换成公网地址“202.96.1.3”和“202.96.1.4”访问地址“1.0.0.1”,然后回来的时
候把公网地址“202.96.1.3”和 “202.96.1.4”分别转换成私有地址“192.168.1.1”和
“192.168.1.2”。

 

(2)show ip nat translations
该命令用来查看NAT 表。静态映射时,NAT 表一直存在。

r1#show ip nat translations
Pro  Inside global     Inside local       Outside local      Outside global
---  202.96.1.3        192.168.1.1        ---                ---
---  202.96.1.4        192.168.1.2        ---                ---


以上输出表明了内部全局地址和内部局部地址的对应关系。