下面是实验拓扑图:

相关说明: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 #将f0/0设置为内网口 *Mar 1 00:05:49.875: %LINEPROTO-5-UPDOWN: Line protocol on Interface NVI0, changed state to up 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 |

