电脑技术学习

BSCI第一章实验2之任务3(人邮自学指南BSCI)

dn001

本次实验是任务2基础上进行的,主要目的是为了说明普通的ACL不带OVERLOAD的NAT是有缺陷的,由于这种情况下的NAT条目里只有 内部本地和内部全局映射关系,路由器一旦之前已经存在某条映射,那么下次即使是目的地不同,路由器也还会使用上一次的映射条目,这将导致严重的问题.

本次实验只是在路由器P1R1上新增了一个NAT转换条件,其他配置不变.
关于实验路由器命名以及与书上IP地址不同的变动请参看任务2的说明

P1R1的配置(红色部分为新增配置):
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service passWord-encryption
!
hostname r1-2514
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
ip subnet-zero
!
!
!
!
interface Loopback0
ip address 1.1.1.1 255.0.0.0
!
interface Ethernet0
ip address 10.1.1.1 255.255.255.0
ip nat inside
!
interface Ethernet1
no ip address
shutdown
!
interface Serial0
ip address 172.31.1.1 255.255.255.0
ip nat outside
encapsulation frame-relay
no arp frame-relay
frame-relay map ip 172.31.1.2 102 broadcast
frame-relay map ip 172.31.1.5 105 broadcast
no frame-relay inverse-arp
!
interface Serial1
ip address 10.1.0.1 255.255.255.0
ip nat outside
clock rate 125000
!
ip nat pool bbr 192.168.1.1 192.168.1.254 prefix-length 24
ip nat pool pod 10.1.0.64 10.1.0.95 netmask 255.255.255.0
ip nat inside source list 100 pool bbr
ip nat inside source list 101 pool pod
ip http server
ip classless
ip route 10.0.0.0 255.0.0.0 172.31.1.5
!
!
Access-list 100 permit ip 10.1.1.0 0.0.0.255 10.254.0.0 0.0.0.255
access-list 101 permit ip 10.1.1.0 0.0.0.255 any
!
!
line con 0
logging synchronous
line aux 0
line vty 0 4
login;
!
end

P1R2的配置:

===================

分析:首先根据任务2我们知道,ping 10.254.0.254之后,P1R1路由器将产生一条NAT条目:
r1-2514#show ip nat trans
Pro Inside global;;;Inside local;;;;Outside local;;;Outside global
--- 192.168.1.1;;;;;10.1.1.3---;;;;;---


接着我们在P1R3路由器上ping P1R2的ip
r3-2514#ping 10.1.0.2
我们发现是不通的,为什么呢?根据上面我们知道NAT表里已经存在了内部本地为10.1.1.3这个条目,所以路由器将继续认为这个条目也适用于ping 10.1.0.2的,来看路由器调试的结果:
r1-2514#
*Mar; 1 00:26:09.215: NAT*: s=10.1.1.3->192.168.1.1, d=10.1.0.2 [11]
r1-2514#
*Mar; 1 00:26:11.215: NAT*: s=10.1.1.3->192.168.1.1, d=10.1.0.2 [12]
r1-2514#
*Mar; 1 00:26:13.299: NAT*: s=10.1.1.3->192.168.1.1, d=10.1.0.2 [13]
r1-2514#
*Mar; 1 00:26:15.299: NAT*: s=10.1.1.3->192.168.1.1, d=10.1.0.2 [14]
从上面我看到到目标10.1.0.2这个过程 源IP 10.1.1.3继续被转为192.168.1.1了,而我们知道P1R2上是没有到192.168.1.0/24这个网络的路由的,所以不可能PING通.看P1R2上调试结果:
*Mar; 1 00:27:20.127: ICMP: echo reply sent, src 10.1.0.2, dst 192.168.1.1
r2-2514(config)#
*Mar; 1 00:27:22.059: ICMP: echo reply sent, src 10.1.0.2, dst 192.168.1.1
回显消息从10.1.0.2发向了192.168.1.1,而R2这个路由器又没有到这个网络的路由条目,数据包必然被丢弃.

此时,假如我们之前清除掉已经存在的这个NAT条目,让NAT表是空的,这个时候我们直接来PING; 10.1.0.2来看看是否通:
r1-2514#clear ip nat trans *
r1-2514#show ip nat trans

r1-2514#
r3-2514#ping 10.1.0.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.0.2, timeout is 2 seconds:
!!!!!
SUCcess rate is 100 percent (5/5), round-trip min/avg/max = 32/32/36 ms
r3-2514#
我们看到.这个时候ping通了,为什么?因为路由器这次正确的将10.1.1.3转换成了10.1.0.64.看调试结果:
*Mar; 1 00:28:57.727: NAT: s=10.1.1.3->10.1.0.64, d=10.1.0.2 [20]
*Mar; 1 00:28:57.751: NAT*: s=10.1.0.2, d=10.1.0.64->10.1.1.3 [20]
*Mar; 1 00:28:57.763: NAT*: s=10.1.1.3->10.1.0.64, d=10.1.0.2 [21]
*Mar; 1 00:28:57.787: NAT*: s=10.1.0.2, d=10.1.0.64->10.1.1.3 [21]
*Mar; 1 00:28:57.795: NAT*: s=10.1.1.3->10.1.0.64, d=10.1.0.2 [22]
*Mar; 1 00:28:57.819: NAT*: s=10.1.0.2, d=10.1.0.64->10.1.1.3 [22]
*Mar; 1 00:28:57.827: NAT*: s=10.1.1.3->10.1.0.64, d=10.1.0.2 [23]
*Mar; 1 00:28:57.851: NAT*: s=10.1.0.2, d=10.1.0.64->10.1.1.3 [23]
*Mar; 1 00:28:57.859: NAT*: s=10.1.1.3->10.1.0.64, d=10.1.0.2 [24]
*Mar; 1 00:28:57.883: NAT*: s=10.1.0.2, d=10.1.0.64->10.1.1.3 [24]

r1-2514#show ip nat trans
Pro Inside global;;;Inside local;;;;Outside local;;;Outside global
--- 10.1.0.64; 10.1.1.3---;;;;;---


标签: