<?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 地址的真实原囚。真的一我不是在开玩笑。
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)#password ccna
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#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
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)#password ccnp
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
r1#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
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#
R1(config)#ip nat inside source static 192.168.1.1 202.96.1.3
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
R1(config)#interface s0/3/0
R1(config-if)#ip nat outside
R1(config-router)#version 2
R1(config-router)#network 192.168.1.0
R1(config-router)#network 202.96.1.0
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 的环回接口),调试结果如下:
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 --- ---
以上输出表明了内部全局地址和内部局部地址的对应关系。
转载于:https://blog.51cto.com/hjtyqs/346965