NAT有三种类型,分别是:静态NAT、动态NAT、NAT重载、

NAT重载又叫做PAT---端口地址解析

下面,我给大家介绍一下PAT的具体的一个配置实例:

拓扑图如下:

173730814.png

具体路由器配置如下

DHCP池配置:

Left#conf ter

Left(config)#ip dhcp pool adam

Left(dhcp-config)#network 11.11.11.0 255.255.255.0

Left(dhcp-config)#default-router 11.11.11.1

Left(dhcp-config)#dns-server 11.11.11.53

Left(config)#ip dhcp excluded-address 11.11.11.2

PAT配置:

Left(config)#ip nat pool adam 1.1.1.1 1.1.1.1 netmask 255.255.255.0

Left(config)#ip nat inside source list 1 pool adam overload

Left(config)#access-list 1 permit 11.11.11.0 0.0.0.255

端口配置:

Left(config)#interface FastEthernet0/0

Left(config-if)#ip address 11.11.11.1 255.255.255.0

Left(config-if)#ip nat inside

Left(config)#interface FastEthernet0/1

Left(config-if)#ip address 1.1.1.1 255.255.255.0

Left(config-if)#ip nat outside

PC机的IP配置:

175029185.png

对端的路由器+PC的配置跟上面一样,只是路由器的出站地址改为:1.1.1.2,

还有内部全局地址是:1.1.1.2

接下来就是验证的过程:

Router#debug ip nat            //开启ip nat调试

IP NAT debugging is on

接下来就是要产生数据包来验证我们配置的PAT,否则路由器NAT表是没有数据的!这就是为什么有的人明明配置好了NAT,打命令:debug ip nat和show ip nat tranlations 输出是空白的缘故!

我们简单地使用PC机ping一下外部全局地址

PC>ping 1.1.1.2


Pinging 1.1.1.2 with 32 bytes of data:


Reply from 1.1.1.2: bytes=32 time=9ms TTL=254

Reply from 1.1.1.2: bytes=32 time=12ms TTL=254

Reply from 1.1.1.2: bytes=32 time=7ms TTL=254

Reply from 1.1.1.2: bytes=32 time=9ms TTL=254


Ping statistics for 1.1.1.2:

   Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

   Minimum = 7ms, Maximum = 12ms, Average = 9ms

对应的路由器CLI界面也会有NAT输出!

Router#

NAT: s=11.11.11.3->1.1.1.1, d=1.1.1.2 [11]


NAT*: s=1.1.1.2, d=1.1.1.1->11.11.11.3 [22]


NAT: s=11.11.11.3->1.1.1.1, d=1.1.1.2 [12]


NAT*: s=1.1.1.2, d=1.1.1.1->11.11.11.3 [23]


NAT: s=11.11.11.3->1.1.1.1, d=1.1.1.2 [13]


NAT*: s=1.1.1.2, d=1.1.1.1->11.11.11.3 [24]


NAT: s=11.11.11.3->1.1.1.1, d=1.1.1.2 [14]


NAT*: s=1.1.1.2, d=1.1.1.1->11.11.11.3 [25]

利用show ip nat translations来查看NAT表

Router#show ip nat translations

Pro  Inside global     Inside local       Outside local      Outside global

icmp 1.1.1.1:13        11.11.11.3:13      1.1.1.2:13         1.1.1.2:13

icmp 1.1.1.1:14        11.11.11.3:14      1.1.1.2:14         1.1.1.2:14

icmp 1.1.1.1:15        11.11.11.3:15      1.1.1.2:15         1.1.1.2:15

icmp 1.1.1.1:16        11.11.11.3:16      1.1.1.2:16         1.1.1.2:16


那么以上就是我“苦心钻研”的成果啦,有什么错误的地方,还请大侠们高抬贵手,指出来!乐意接受大家的批评,喷子手下留情!!广交网络爱好学习友友QQ:290217375!!