Chinaunix首页 | 论坛 | 博客
  • 博客访问: 594322
  • 博文数量: 841
  • 博客积分: 5000
  • 博客等级: 大校
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-28 10:08
文章分类

全部博文(841)

文章存档

2011年(1)

2008年(840)

我的朋友

分类:

2008-10-28 10:23:31


  本节进行静态内部源地址转换的实验,这是NAT技术中最简单的一种形式,通过此实验可以理解NAT中重要的概念和机制。
  
  1.实验目的
  
  通过本实验。读者可以掌握以下技能:
  ●配置静态内部源地址转换NAT;
  ●查看NAT相关信息;
  ●监测IP的转换;
  ●监测内网和外网间的双向连通性。
  
  2.设备需求
  
  本实验需要以下设备:
  ●器3台,分别命名为R1.R2和R3,其申R1要求具有1个串行接口和1个以太网接口;R2要求具有1个串行接口;R3要求具有1个以太网接口,R3也可以使用1台带网卡的PC机代替;
  ●DCE和DTE电缆各1条 (或1条DCE转DTE电缆);
  ●1条交叉线序双绞线;
  ●1台终端,如 2509路由器,及用于反问Telnet的相应电缆;
  ●1台带有超级终端程序的PC机。以及Console电缆及转接器。
  
  3. 拓扑结构及配置说明
  
  本实验的拓扑结构如图12-1所示。
  

  R1路由器负责NAT转换;R2作为外网节点;R3代替内网中的主机使用。
  准备实验时,用DCE和DTE电缆把R1和R2路由器连接起来;使用交叉双绞线把R2和R3路由器连接起来。
  各路由器使用的接口及其IP地址如图12-1中的标注。
  本实验要求通过使用静态NAT实现没有路由可达性的IP节点172.16.1.3和202.1.1.2之间的双向连通。
  
  4.实验配置及监测结果
  
  首先进行NAT的配置,然后使用有关命令对配置结果进行查看和监测。
  
  第1部分:配置静态内部源地址转换
  
  静态NAT要求实现内网IP地址(Inside Local Address)对外网IP地址 (Inside Global Address)之间的一一映射。在实验中以一对地址的映射为例进行配置。
  配置清单12-1列出了各路由器配置完成后的结果。
  
  配置清单12-1 配置静态内部源地址转换
  
  第1段:路由器R1的配置
  version 12.1
  service timestamps debug uptime
  service timestamps log uptime
  no service password-encryption
  !
  hostname R1
  !
  ip subnet-zero
  !
  interface Ethemet0
   ip address 172.16.1.1255.255.255.0
   ip nat inside
  !
  interface Serial0
   ip address 200.1.1.1255.255.255.0
   ip nat outside
  !
  ip nat inside source static 172.16.1.3 200.1.1.5
  ip classless
  ip route 0.0.0.0 0.0.0.0 200.1.1.2
  ip http server
  !
  line con 0
  line aux 0
  line vty 0 4
  !
  end
  第2段:路由器R2的配置
  version 12.1
  service timestamps debug uptime
  service timestamps log uptime
  no service password-encryption
  hostname R2
  !
  ip subnet-zero
  !
  interface Loopback0
   ip address 202.1.1.2 255.255.255.0
  !
  interface Serial0
   ip address 200.1.1.2 255.255.255.0
   clockrate 64000
  !
  ip classless
  ip http server
  !
  line con 0
   transport input none
  line aux 0
  Sine vty 0 4
   password cisco
   login
  !
  end
  第3段:路由器R3的配置
  version 12.1
  service timestamps debug uptime
  service timestamps log uptime
  no service password-encryption
  hostname R3
  !
  ip subnet-zero
  no ip routing
  no ip finger
  !
  interface Ethemet0
   ip address 172.16.1.3 255.255.255.0
   no ip route-cache
  ip default-gateway 172.16.1.1
  ip classless
  ip http server
  !
  line con 0
   transport input none
  line aux 0
  line vty 0 4
   password cisco
   login
  
  (1)本实验的重点是对R1路由器的配置。配置R1时,除了对接口进行了通常的配置之外,在E0接口配置了ip nat inside语句,在S0接口配置了ip nat outside语句,指定了路由器的内部接口和外部接口。
  (2)为了实现从R1到202.1.1.2的可达性,加入了一条缺省路由。当然也可使用指定目的网段(202.1.1.0/24)的静态路由实现。使用缺省路由是机构用户对Internet接入时的通常做法。
  (3)R1路由器配置中最核心的配置语句是:
  ip nat inside source static 172.16.1.3 200.1.1.5
  它建立了172.16.1.3和200.1.1.5两个IP地址之间的静态映射。
  其中内部本地址是172.16.1.3;内部全局地址是200.1.1.5。
  需要特别注意的是,200.1.1.5不是任何接口上的IP地址,它属于网段200.1.1.0/24(S0接口所在网段)。
  可以在一台路由器上定义多对IP地址的静态映射。
  (4)在R2路由器上是常规的配置。需要说明的是其上没有任何路由设置,这样保证了从R2到内部网172.16.1.0/24之间在路由上是不能连通的。
  为了监测的方便,在R2上配置了VTY口令。
  (5)R3路由器作为一台纯粹的主机来使用。在配置上,首先用no ip routing命令关闭了该路由器的路由功能;然后用ip default-gateway命令指定了它的缺省网关为172.16.1.1,即R1路由器的E0接口,这一点和在PC机上指定缺省网关具有相同的作用。
  在R3路由器上同样也配置了VTY口令。
  
  第2部分:查看和监测静态内部源地址转换
  
  接下来将使用一系列命令来查看和监测静态NAT的相关信息和转换过程。
  在监测清单12-1中记录了命令的使用及相应结果。
  
  监测清单12-1查看和监测静态内部源地址转换
  
  第1段:监测和查看NAT操作
  R3#ping
  Protocol [ip]:
  Target IP address: 202.1.1.2
  Repeat count [5]: 5000
  Datagram size [100]:
  Timeout in seconds [2]:
  Extended commands [n]:
  Sweep range of sizes [n]:
  Type escape sequence to abort.
  Sending 5000, 100-byte ICMP Echos to 202.1.1.2, timeout is 2 seconds:
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  !!!!!!!!!!!!!!!!!!!
  Term_Server> 1
  [Resuming connection 1 to r1 ...]
  
  R1#debug ip siat
  IP NAT debagging is on
  
  R1#
  01:57:35: NAT*:s=172.16.1.3->200.1.1.5,d=201.1.1.2[1068]
  01:57:35: NAT*:s=202.1.1.2,d=200.1.1.5->172.16.1.3[1068]
  01:57:36: HAT*:s=172.16.1.3->200.1.1.5,d=202.1.1.2[1069]
  01:57:36: NAT*:s=202.1.1.3,d=200.1.1.5->172.16.1.3[1069]
  01:57:36: NAT*:s=172.16.1.3->200.1.1.5,d=202.1.1.2[1070]
  01:57:36: HAT*:s=202.1.1.2,d=200.1.1.5->172.16.1.3[1070]
  01:57:36: NAT*:s=172.16.1.3->200.1.1.5,d=202.1.1.2[1072]
  O1:57:36: NAT*:s=202.16.1.3->200.1.1.5->172.16.1.3[1072]
  01:57:3@:
  ... (此处删节)
  01:57:36: NAT*:s=202.1.1.2,d=200.1.1.5->172.16.1.3[1079]
  01:57:36: HAT*:s=172.16.1.3->200.1.1.5,d=202.1.1.2[1080]
  
  R1#undeb all
  R1#show ip nat statistics
  Total active.translations:1(1 static,0 dynamic;0 extended)
  Outside interfaces:
   Serial0
  Inside interfaces:
   Ettherent0
  hits:  Misses.: 0
  Expired translations: 0
  Dynamic mappings:
  
  R1#sh ip nat translations
  Pro Inside global  Indide local  Outside local   Outside global
  ---200.1.1.5     172.16.1.3    ---           ---
  
  第2段:测试双向连通性
  R1#
  Term_Server>3
  [Resuming connection 3 to r3 ...]
  R3#telnet 202J.1.2
  Trying 202.1.1.2...Open
  
  User Access Verilcation
  
  Password: (键入 cisco )
  R2>
  R2>exit
  [Connection to 202.1.1.2 closed by foreign host]
  R3#
  Term_Server>2
  [Resuming connection 2 to r2 ... ]
  
  R2#telnet 200J.1.5
  Trymg;200.1.1.5...Open
  
  
【责编:admin】

--------------------next---------------------

阅读(354) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~