会计考友 发表于 2012-8-3 20:28:11

CCNA指导:NAT和PAT的配置

下面是尝试拓扑图:

相关声名:NAT用于供给几乎无限的地址空间并遮蔽内部收集寻址方案,地址打点加倍轻易,它许可严酷节制进入和分开收集的流量;可是静态或动态NAT都存在一个问题,它只能供给一对一的地址转换。使用端口地址转换PAT可以实现地址改暌姑的功能,使用PAT后,所有经由过程地址转换设备的机械都拥有了分配给它们不异IP地址,是以源端口号用来区分分歧的毗连。尝试过程:
I:设置装备摆设各路由器的IP地址,确保直毗连口能Ping通。
II:KC-R1模拟企业网关路由器。

KC-R1(config)#ip route 0.0.0.0 0.0.0.0 173.16.1.128
IV:设置装备摆设NAT。
体例一:静态NAT

KC-R1(config)#int f0/0
KC-R1(config-if)#ip nat inside *Mar 1 00:05:49.875: %LINEPROTO-5-UPDOWN: Line protocol align=left>KC-R1(config-if)#exit
KC-R1(config)#int s1/0
KC-R1(config-if)#ip nat outside #将s1/0设置为外网口
KC-R1(config-if)#exit
KC-R1(config)#ip nat inside source static 10.1.1.1 173.16.1.56 #静态NAT
KC-R1(config)#exit
Ping测试:
PC-1#ping 202.101.1.149 #测试证实能通
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 202.101.1.149, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 120/122/132 ms
此时PC-1能通,PC-2不能通。
KC-R2#debug ip packet #查看数据包
*Mar 1 00:09:59.487: IP: tableid=0, s=10.1.1.2 (Serial1/0), d=173.16.1.128 (Serial1/0), routed via RIB
*Mar 1 00:09:59.491: IP: s=10.1.1.2 (Serial1/0), d=173.16.1.128 (Serial1/0), len 100, rcvd 3
*Mar 1 00:09:59.495: IP: s=173.16.1.128 (local), d=10.1.1.2, len 100, unroutable
………………….
*Mar 1 00:23:51.243: IP: s=202.101.1.149 (local), d=173.16.1.56 (Serial1/0), len 100, sending
*Mar 1 00:23:51.447: IP: tableid=0, s=173.16.1.56 (Serial1/0), d=202.101.1.149 (Loopback0), routed via RIB

KC-R1(config)# ip nat pool kachy 173.16.1.58 173.16.1.126 netmask 255.255.255.0 #建树地址池
KC-R1(config)#access-list 1 permit 10.1.1.0 0.0.0.255 #建树ACL
KC-R1(config)#ip nat inside source list 1 pool kachy #二者联系关系

KC-R1(config)#exit

会计考友 发表于 2012-8-3 20:28:12

CCNA指导:NAT和PAT的配置

</p>Ping测试
PC-1#ping 202.101.1.149 #测试证实能通
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 202.101.1.149, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 96/125/148 ms
PC-1#telnet 202.101.1.149 #测试证实能远程毗连
Trying 202.101.1.149 … Open
Password required, but none set

此时PC-2也可以ping通,telnet上。
查看当前KC-R1的NAT表。
KC-R1#sh ip nat translations #查看NAT表
Pro Inside global Inside local Outside local Outside global
— 173.16.1.58 10.1.1.1 — —
— 173.16.1.59 10.1.1.2 — —
KC-R1#
体例三:设置装备摆设PAT

KC-R1(config)#access-list 100 permit ip 10.1.1.0 0.0.0.255 any #建树访谒列表
KC-R1(config)#ip nat inside source list 100 interface s1/0 overload #二者联系关系,地址重载

KC-R1(config)#exit

会计考友 发表于 2012-8-3 20:28:13

CCNA指导:NAT和PAT的配置

</p>测试
PC-1#ping 202.101.1.149
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 202.101.1.149, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 84/97/116 ms
PC-1#
PC-1#telnet 202.101.1.149
Trying 202.101.1.149 … Open
Password required, but none set

同样,PC-2也能达到。
在路由器KC-R1上
KC-R1#debug ip nat #查看翻译过程
*Mar 1 00:19:32.843: NAT*: s=10.1.1.1->173.16.1.56, d=202.101.1.149
*Mar 1 00:19:32.847: NAT*: s=10.1.1.1->173.16.1.56, d=202.101.1.149
*Mar 1 00:19:33.083: NAT*: s=202.101.1.149, d=173.16.1.56->10.1.1.1
在路由器KC-R2上
KC-R2#debug ip packet
*Mar 1 00:23:34.931: IP: tableid=0, s=173.16.1.56 (Serial1/0), d=202.101.1.149 (Loopback0), routed via RIB
*Mar 1 00:23:34.935: IP: s=173.16.1.56 (Serial1/0), d=202.101.1.149, len 100, rcvd 4
*Mar 1 00:23:34.939: IP: tableid=0, s=202.101.1.149 (local), d=173.16.1.56 (Serial1/0), routed via FIB
OK,尝试完成。
页: [1]
查看完整版本: CCNA指导:NAT和PAT的配置