本次實驗是任務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 --- ---
新聞熱點
疑難解答