NAT功能的配置与实现

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

计算机网络课程设计报告书
课题名称NAT功能的配置与实现姓名
学号
院系
专业班级
指导教师
2013年 12月 25日
NAT功能的配置与实现
一、设计目的及意义
1.计算机网络课程对于通信工程专业的重要性。

通信工程专业是信息科学技术发展迅速并极具活力的一个领域,尤其是数字移动通信、光纤通信、Internet网络通信使人们在传递信息和获得信息方面达到了前所未有的便捷程度。

计算机网络是计算机发展和通信技术紧密结合并不断发展的一门学科。

它的理论发展和应用水平直接反映了一个国家高新技术的发展水平,并是其现代化程度和综合国力的重要标志。

在以信息化带动工业化和工业化促进信息化的进程中,计算机网络扮演了越来越重要的角色。

计算机网络这门课程是通信工程专业中的一门重要课程,学习计算机网络这门课程里面的各项知识理论,关系着通信工程专业其他课程的学习。

计算机网络课程贯穿于整个通信工程专业知识。

2.此课程设计内容,对于计算机网络课程的意义。

通过此课程设计,能够将在计算机网络课程中所学的理论知识更好的用于实践。

将所学关于交换机的基本配置,路由器的基本配置包括静态路由、RIP配置、OSPF配置、NAT 配置等等,通过课程设计这样的平台更好的理解、运用和掌握。

二、实践内容
1.计算机网络设备的基本功能配置
按照要求,使用Boson Netsim软件完成对交换机及路由器等设备的配置,使其实现特定的功能。

内容如下:
(1)交换机的基本配置
(2)路由器的基本配置
2.综合设计
在掌握设备基本配置方法的基础上,按照要求,设计一个综合的网络,画出网络拓扑图,对其中的设备进行配置,在不断调试的基础上,对网络进行反复测试,检查网络的连通性,使网络能够完成所要求的功能。

三、交换机的基本配置
1.交换机的工作原理:交换机按每一个包中的MAC地址相对简单地决策信息转发。

而这种转发决策一般不考虑包中隐藏的更深的其他信息。

与桥接器不同的是交换机转发延迟很小,操作接近单个局域网性能,远远超过了普通桥接互联网络之间的转发性能。

交换技术允许共享型和专用型的局域网段进行带宽调整,以减轻局域网之间信息流通出现的瓶颈问题。

现在已有以太网、快速以太网、FDDI和ATM技术的交换产品。

类似传统的桥接器,交换机提供了许多网络互联功能。

交换机能经济地将网络分成小的冲突网域,为每个工作站提供更高的带宽。

协议的透明性使得交换机在软件配置简单的情况下直接安装在多协议网络中;交换机使用现有的电缆、中继器、集线器和工作站的网卡,不必作高层的硬件升级;交换机对工作站是透明的,这样管理开销低廉。

2.虚拟局域网VLAN 的原理及功能
VLAN的工作原理:交换机工作原理与传统网桥类似。

在交换机中配置的每个VLAN都实现了地址获悉机制、转发和过滤决策机制、环路避免机制,就像每个VLAN都是一个物理网桥一样。

交换机是这样实现VLAN的:只将数据流转发到与始发端口位于同一个VLAN中的端口。

因此,当帧到达交换机端口后,交换机必须将其重传到属于相同VLAN的端口。

从本质上说,运行在单台交换机上的VLAN将限制单播、组播和广播的传播。

来自特定VLAN的数据流只泛洪到属于该VLAN的端口。

端口通常只传输其所属VLAN的数据流。

当VLAN跨越多台交换机时,必须使用中继线将这些交换机连接起来。

中继线可传输多个VLAN的数据流。

VLAN 的功能:VLAN(Virtual Local Area Network)即虚拟局域网,是一种通过将局域网内的设备逻辑地而不是物理地划分成一个个网段从而实现虚拟工作组的新兴技术。

于交换式以太网的虚拟局域网在交换式以太网中,利用VLAN技术,可以将由交换机连接成的物理网络划分成多个逻辑子网。

也就是说,一个虚拟局域网中的站点所发送的广播数据包将仅转发至属于同一VLAN的站点。

虚拟局域网技术使得网络的拓扑结构变得非常灵活,例如位于不同楼层的用户或者不同部门的用户可以根据需要加入不同的虚拟局域网。

交换机的基本配置举例:单个交换机的VLAN配置
1、按图1所示连接网络;Catalyst 2950交换机 1台;PC机 4台。

图1
PC1连接在交换机的1#端口,PC2连接在3#端口,PC3连接在5#端口,PC4连接在7#端口。

2.配置PC机:PC1的IP地址:;PC2的IP地址:;PC3的IP地址:;PC4的IP地址:;
子网掩码均为。

PC1与PC2连接结果
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
PC1与PC3连接结果
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
PC1与PC4连接结果
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
3. 配置交换机:设置交换机名为S1,管理IP为,子网掩码为。

用ping命令检查交换机与各PC机的通讯情况。

PC1与交换机连接结果
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
PC2与交换机连接结果
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
PC3与交换机连接结果
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
PC4与交换机连接结果
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
4. 在交换机上创建并划分VLAN:按图2所示划分VLAN。

图2
代码:
S1#vlan database
S1(vlan)#vlan 2 name vlan2
VLAN 2 added:
Name:vlan2
S1(vlan)#vlan 3 name vlan3
VLAN 3 added:
Name:vlan3
S1(vlan)#exit
APPL Y completed.
Exiting....
S1#config
% Incomplete command.
S1#config t
Enter configuration commands, one per line. End with CNTL/Z.
S1(config)#interface fa0/1
% Ambiguous command: "interface fa0/1"
S1(config)#interface fa0/1
S1(config-if)#switchport access vlan 2
S1(config-if)#interface fa0/2
S1(config-if)#switchport access vlan 2
S1(config-if)#interface fa0/3
S1(config-if)#switchport access vlan 2
S1(config-if)#interface fa0/4
S1(config-if)#switchport access vlan 2
S1(config-if)#interface fa0/5
S1(config-if)#switchport access vlan 3
S1(config-if)#interface fa0/6
S1(config-if)#switchport access vlan 3
5检查配置结果:
用ping命令检查PC机间的通讯情况,以及各PC机与交换机的通讯情况理解其中的原因。

PC1与PC2连接结果
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
PC1与PC3连接结果
C:>ping with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for Packets: Sent = 5, Received = 0, Lost = 5 (100% loss), Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
PC1与PC4连接结果
C:>ping with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for Packets: Sent = 5, Received = 0, Lost = 5 (100% loss), Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
PC1只能与PC2通讯,而与PC3、PC4都不能通讯。

原因:PC1与PC2属于同一VLAN,PC1与PC3、PC4属于不同的VLAN
四. 路由器的基本配置
1.默认路由的配置方法。

默认路由:默认路由是一种特殊的,指的是当路由表中与包的目的地址之间没有匹配的表项时路由器能够做出的选择。

如果没有默认路由器,那么目的地址在
路由表中没有匹配表项的包将被丢弃. 默认路由在某些时候非常有效,当
存在末梢网络时默认路由会大大简化路由器的配置,减轻的工作负担,提高
网络性能。

图3
(2) 先完成路由器的基本配置,包括路由器的名字、各接口的IP地址等;
路由器R1配置:
Route>enable /进入特权模式/
Route#config t /进入全局模式/
Route(config) #hostname R1 /给路由器命名/
R1(config) #interface e0 /进入路由器1以太网端口e0/
R1(config-if) #no shutdown /激活路由器1以太网端口e0/
R1(config-if)#ip address /配置以太网端口e0 IP地址/
R1(config-if)#exit /返回上一级模式/
R1(config) #interface s0 /进入串行端口s0/
R1(config-if) #no shutdown /激活串行端口s0/
R1(config-if) #clock rate 64000 /在DCE端配置时钟频率/
R1(config-if)#ip address /配置串口s0 IP地址/
R1(config-if)#end /返回上一级模式/
路由器R2配置:
Route>enable /进入特权模式/
Route#config t /进入全局模式/
Route(config) #hostname R2 /给路由器命名/
R2 (config) #interface e0 /进入路由器2以太网端口e0/
R2(config-if) #no shutdown /激活路由器2以太网端口e0/
R2(config-if)#ip address /配置串口s0 IP地址/
R2(config-if)#exit /返回上一级模式/
R2(config) #interface s0 /进入串行端口s0/
R2(config-if) #no shutdown /激活串行端口s0/
R2(config-if) #clock rate 64000
R2(config-if)#ip address /配置串口s0 IP地址/
R2(config-if)#exit /返回上一级模式/ R2(config) #interface s1 /进入串行端口1/
R2(config-if) #no shutdown /激活串行端口s1/
R2(config-if) #clock rate 64000 /在DCE端配置时钟频率/
R2(config-if)#ip address /配置串口s1 IP地址/
R2(config-if)#end /返回上一级模式/ 路由器R3配置:
Route>enable /进入特权模式/
Route#config t /进入全局模式/
Route(config) #hostname R3 /给路由器命名/
R3(config) #interface e0 /进入路由器1以太网端口e0/
R3(config-if) #no shutdown /激活路由器1以太网端口e0/
R3(config-if)#ip address /配置以太网端口e0 IP地址/
R3(config-if)#exit /返回上一级模式/
R3(config) #interface e1 /进入路由器1以太网端口e0/
R3(config-if) #no shutdown /激活路由器1以太网端口e0/
R3(config-if)#ip address /配置以太网端口e0 IP地址/
R3(config-if)#exit /返回上一级模式/
R3(config) #interface s1 /进入串行端口s0/
R3(config-if) #no shutdown /激活串行端口s0/
R3(config-if) #clock rate 64000 /在DCE端配置时钟频率/
R3(config-if)#ip address /配置串口s0 IP地址/
R3(config-if)#end /返回上一级模式/
(3) 配置各PC机,包括IP地址和默认网关;
PC1:IP地址子网掩码默认网关:IP地址子网掩码默认网关:IP地址子网掩码默认网关:IP地址子网掩码默认网关在各路由器上用“show ip interface brief”命令查看路由器接口状态,要求各已使用的接口状态均为UP
路由器1接口状态
R1#show ip interface brief
Interface IP-Address OK? Method Status Protocol Serial0 YES unset up down
Serial1 unassigned YES unset administratively down down Ethernet0 YES unset up up
Ethernet1 unassigned YES unset administratively down down
路由器2接口状态
R2#show ip interface brief
Interface IP-Address OK? Method Status Protocol Serial0 YES unset up down
Serial1 YES unset up up
Ethernet0 YES unset up up
Ethernet1 unassigned YES unset administratively down down
路由器3接口状态
R3#show ip interface brief
Interface IP-Address OK? Method Status Protocol Serial0 unassigned YES unset administratively down down
Serial1 YES unset up up
Ethernet0 YES unset up up
Ethernet1 YES unset up up
(5) 在R2路由器上配置静态路由,使它可以识别所有网络;
R2#con t /进入全局模式/
R2 (config)#ip route /配置R2到R1的静态路由,为目标网络地址,为目标网络子网掩码,为下一跳地址/
R2 (config)#ip route /配置R2到R3的静态路由为目标网络地址,为目标网络子网掩码,为下一跳地址/
R2 (config)#ip route /配置R2到R3的静态路由为目标网络地址,为目标网络子网掩码,为下一跳地址/
R2 (config) #end /返回上一级模式/
R2路由器路由表
R2#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default
U - per-user static route
Gateway of last resort is not set
C is directly connected, Ethernet0
C is directly connected, Serial1
S [1/0] via [1/0] via [1/0] via Interface Serial0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to up
(6) 在R1和R3路由器上分别配置默认路由,默认方向均为R2;
路由器R1配置:
R1#con t /进入全局模式/
R1(config)#ip route /配置R1的静态路由,为目标网络地址,为目标网络子网掩码,为下一跳地址/
R1(config)#ip route /配置R1的静态路由,为目标网络地址,为目标网络子网掩码,为下一跳地址/
R1(config)#ip route /配置R1的静态路由,为目标网络地址,为目标网络子网掩码,为下一跳地址/
R1(config)#ip route /配置R1的静态路由,为目标网络地址,为目标网络子网掩码,为下一跳地址/
R1(config)#ip route 0.0.0.0 /配置R1的默认路由,为下一跳地址/
R1(config) #end /返回上一级模式/
R1路由器路由表
R1#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default
U - per-user static route
Gateway of last resort is to network 0.0.0.0
C is directly connected, Ethernet0
S [1/0] via [1/0] via [1/0] via [1/0] via 0.0.0.0/0 [1/0] via Interface Serial0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to up
路由器R3配置:
R3#con t /进入全局模式/
R3 (config)#ip route /配置R3的静态路由,为目标网络地址,为目标网络子网掩码,为下一跳地址/
R3 (config)#ip route /配置R3的静态路由为目标网络地址,为目标网络子网掩码,为下一跳地址/
R3 (config)#ip route /配置R3的静态路由为目标网络地址,为目标网络子网掩码,为下一跳地址/
R3 (config)#ip route 0.0.0.0 /配置R3的默认路由,为下一跳地址/
R3 (config) #end /返回上一级模式/
R3路由器路由表
R3#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default
U - per-user static route
Gateway of last resort is to network 0.0.0.0
C is directly connected, Ethernet0
C is directly connected, Ethernet1
C is directly connected, Serial1
S [1/0] via [1/0] via [1/0] via 0.0.0.0/0 [1/0] via Interface Serial0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to up
(7)ping命令测试PC间连通性
1、用PC1 ping PC2
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
2、用PC1 ping PC3
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
3、用PC1 ping PC4
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
2. RIP协议的配置
RIP协议的原理和特点
原理:路由信息协议 RIP 是内部网关协议 IGP中最先得到广泛使用的协议。

RIP 是一种分布式的基于距离向量的路由选择协议,是英特网的标准协议,其最大特点就是简单。

RIP 协议要求网络中的每一个路由器都要维护从它自己到其他每一个目的网络的距离记录.RIP协议将“距离”定义为从一路由器到直接连接的网络的距离定义为 1,从一个路由器到非直接
连接的网络的距离定义为所经过的路由器数加 1。

RIP 协议中的“距离”也称为“跳数”(hop count),因为每经过一个路由器,跳数就加 1。

这里的“距离”实际上指的是“最短距离”,RIP允许一条路径最多只能包含15个路由器。

因此 RIP 允许一条路径最多只能包含 15 个路由器,“距离”的等于16 时即相当于不可达。

可见 RIP 只适用于小型互联网。

RIP 不能在两个网络之间同时使用多条路由。

RIP 选择一个具有最少路由器的路由(即最短路由),哪怕还存在另一条高速(低时延)但路由器较多的路由。

特点:(1)仅和相邻路由器交换信息。

如果两个路由器之间的通信不需要经过另一个路由器,那么这两个路由器就是相连的。

(2)路由器交换的信息是当前本路由器所知道的全部信息,即自己的路由表。

也就是说,交换的信息:“我到本自治系统中所有网络的(最短距离),以及到每个网络应经过的下一跳路由器”。

(3)按固定的时间间隔交换路由信息,例如,每隔 30 秒。

然后路由器根据收到的路由信息更新路由表。

在图3所示的拓扑图上,进行 RIP协议的配置,理解RIP协议的原理和特点。

在正确完成路由器的基本配置(包括路由器的名字、各接口的IP地址)和各PC机的基本配置(包括IP地址和默认网关)后,在三台路由器上分别配置RIP协议:
路由器R1配置:
R1#con t /进入全局模式/
R1 (config)#router rip OSPF, IA0.0.0
C is directly connected, Ethernet0
C is directly connected, Serial0
1、S [1/0] via [1/0] via [1/0] via [1/0] via 0.0.0.0/0
[1/0] via 查看R2的路由表
R2#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default
U - per-user static route
Gateway of last resort is not set
C is directly connected, Ethernet0
C is directly connected, Serial1
C is directly connected, Serial0
2、S [1/0] via [1/0] via [1/0] via 查看R3的路由表
R3#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default
U - per-user static route
Gateway of last resort is to network 0.0.0.0
C is directly connected, Ethernet0
C is directly connected, Ethernet1
C is directly connected, Serial1
S [1/0] via [1/0] via [1/0] via 0.0.0.0/0 [1/0] via (7) 用Ping 命令测试各PC机,如果都能ping通,说明配置成功。

测试连通性
1.用PC2 ping PC1
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
1、用PC2 ping PC3
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
2、用PC2 ping PC4
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
3. OSPF协议的配置
OSPF协议的原理和特点
原理:OSPF路由协议是一种典型的链路状态(Link-state)的路由协议,一般用于同一个路由域内。

路由域是指一个自治系统(Autonomous System),即AS,它是指一组通过统一的路由政策或路由协议互相交换路由信息的网络。

在这个AS中,所有的OSPF路由器都维护一个相同的描述这个AS结构的数据库,该数据库中存放的是路由域中相应链路的状态信息,OSPF路由器是通过这个数据库计算出其OSPF路由表的。

作为一种链路状态的路由协议,OSPF 将链路状态广播数据包LSA(Link State Advertisement)传送给在某一区域内的所有路由器,这一点与距离矢量路由协议不同。

运行距离矢量路由协议的路由器是将部分或全部的路由表传递给与其相邻的路由器。

特点:(1)OSPF最主要的特点就是采用分布式的链路状态协议。

(2)通过洪泛法向本自治系统中所有路由器发送信息。

(3)发送的信息就是与本路由器相邻的所有路由器的链路状态,但这只是路由器所知道的部分信息。

(4)只有当链路状态发生变化时,路由器才向所有路由器用洪泛法发送此信息。

(5)OSPF 的链路状态数据库能较快地进行更新,使各个路由器能及时更新其路由表,OSPF 的更新过程收敛得快是其重要优点。

(1)按图4所示连接网络:Cisco路由器 4台;PC机 2台。

图4
按照前边实验的方法,正确完成路由器的基本配置(包括路由器的名字、各接口的IP地址)和各PC机的基本配置(包括IP地址和默认网关)后,在四台路由器上分别配置OSPF协议
(2) 在四台路由器上分别配置OSPF协议;
路由器R1配置:
R1#con t /进入全局模式/
R1 (config)#router ospf 100 0.0.055 area 1 0.0.055 area 0 0.0.055 area 1 0.0.055 area 2
R1#
R1#show ip router
% Invalid input detected at '^' marker.
R1#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default
U - per-user static route
Gateway of last resort is not set
C is directly connected, Serial0
C is directly connected, Serial1
O [110/65] via 00:00:42, Serial1
O [110/193] via 00:00:35, Serial0
R1#
R2#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default
U - per-user static route
Gateway of last resort is not set
C is directly connected, Serial1
C is directly connected, Serial0
O [110/193] via 00:00:43, Serial1
O [110/65] via 00:00:20, Serial0
R2#
R3#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default
U - per-user static route
Gateway of last resort is not set
C is directly connected, Serial0
C is directly connected, Ethernet0
O [110/321] via 00:00:25, Serial0
R3#
R4#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default
U - per-user static route
Gateway of last resort is not set
C is directly connected, Serial1
C is directly connected, Ethernet0
O [110/321] via 00:00:33, Serial1
(4) 用Ping命令测试各PC机,如果都能ping通,说明配置成功。

PC1与PC2ping
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>PC2与PC1ping
C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>
4、NAT的配置
NAT的作用:NAT英文全称是“Network Address Translation”,中文意思是“网络地址转换”,它是一个IETF(Internet Engineering Task Force, Internet工程任务组)标准,允许一个整体机构以一个公用IP(Internet Protocol)地址出现在Internet上。

NAT就是在局域网内部网络中使用内部地址,而当内部节点要与外部网络进行通讯时,就在网关处,将内部地址替换成公用地址,从而在外部公网(internet)上正常使用,NAT可以使多台计算机共享Internet连接,这一功能很好地解决了公共IP地址紧缺的问题。

通过这种方法,可以只申请一个合法IP地址,就把整个局域网中的计算机接入Internet中。

这时,NAT屏蔽了内部网络,所有内部网计算机对于公共网络来说是不可见的,而内部网计算机用户通常不会意识到NAT的存在。

这里的内部地址,是指在内部网络中分配给节点的私有IP地址,这个地址只能在内部网络中使用,不能被路由(一种网络技术,可以实现不同路径转发)。

配置实例
(1)按图5所示连接网络:Cisco路由器 2台;Catalyst 2950交换机 1台;PC机 2台。

图5
(2) 配置路由器的基本信息,包括路由器的名字、各接口的IP地址等;(外网为R2,内网R1为具有NAT转换功能的路由器。

)在内网路由器上配置静态NAT,将内网的IP地址翻译为,将翻译为;
路由器R1配置:
Route>enable /进入特权模式/
Route#con t /进入全局模式/
Route(config) #hostname R1 /给路由器命名/
R1(config)#interface e0
R1(config-if)#ip address
R1(config-if)#ip nat inside /表明为内部端口/
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#interface s0
R1(config-if)#ip address
R1(config-if)#ip nat outside /表明为外部端口/
R1(config-if)#clock rate 64000
R1(config-if)#no shut
R1(config-if)#router rip
R1(config-router)#network
R1(config-router)#network
R1(config-router)#exit
R1(config)#ip nat inside source static /以下两行为静态NAT的设置
R1(config)#ip nat inside source static
R1(config)#exit
路由器R2配置:
Route>enable /进入特权模式/
Route#con t /进入全局模式/
Route(config) #hostname R2 /给路由器命名/
R2(config) #interface s0 /进入串行端口s0/
R2(config-if) #no shutdown /激活串行端口s0/
R2(config-if)#clock rate 64000
R2(config-if)#ip address /配置串口s0 IP地址/
R2(config-if)#ip nat outside
R2 (config-if)#router rip
R2 (config-router)#network (config-router)#exit
R2(config-if)#exit /返回上一级模式 /
配置交换机
Switch>enable /进入特权模式/
Switch #config t /进入全局模式/
Switch (config)#hostname S /给交换机命名/
S(config)#ip default-gateway /配置交换机的默认网关/
S(config)#interface vlan 1 /交换机的端口默认为VLAN1/
S(config-if)#ip address /配置交换机的管理IP/
S(config-if)#no shutdown /激活端口/
S(config-if)#end /返回上一级/
(4) 配置PC机,包括IP地址和默认网关;
PC1:IP地址子网掩码默认网关:IP地址子网掩码默认网关测试结果:在内网的PC机上ping外网的路由器,在路由器r1上用“show ip nat translation”命令可以查看ping命令执行时的NAT翻译情况。

C:>ping with 32 bytes of data:
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Reply from bytes=32 time=60ms TTL=241
Ping statistics for Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
R1#show ip nat translation
Pro Inside global Inside local Outside local Outside global
--- --- ---
--- --- ---
五、综合网络配置
掌握较复杂网络的交换机和路由器的配置问题。

1.按图5所示连接网络:Cisco路由器 3台;Catalyst 2950交换机 2台;PC机 3台。

图6
说明:路由器R2将内网划分为两个子网、;路由器R1负责内网与外网的连接,并实现NAT 功能;R1与R3之间通过路由协议识别各个网络,由于内网采用了私有IP地址进行编址,它对外网应该是不可见的,所以启用路由协议时不要启用内部网络。

2. 配置路由器R1:
路由器的名字为R1;
E0口的IP地址:,设置E0口为NAT输入端;
S0口的IP地址:,设置S0口为NAT输出端;
配置PAT,将内网中格式为 .*.* 的IP地址转换为S0口的IP地址;
配置静态路由,将目的为网络的数据报发往;
配置RIP路由协议,在它的外网地址上启用协议。

程序如下:
Router>enable /进入特权模式/
Router#config /进入全局模式/
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R1 /给路由器命名/
R1(config)#interface e0 /进入路由器2以太网端口e0/ R1(config-if)#no shutdown /激活路由器2以太网端口e0/ %LINK-3-UPDOWN: Interface Ethernet0, changed state to up
R1(config-if)#ip nat inside /表明为内部端口/
R1(config-if)#ip address /返回上一级模式/ R1(config)#interface s0 /进入串行端口s0/
R1(config-if)#no shutdown /激活路由器2以太网端口e1/ R1(config-if)#clock rate 64000 /设计时钟频率/
R1(config-if)#ip nat outside /表明为外部端口/
R1(config-if)#ip address /返回上一级模式/ R1(config)#ip route rip
R1(config-router)#network running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
3. 配置路由器R2:
路由器的名字为R2;
E0口的IP地址:;
E1口的IP地址:;
配置默认路由,方向为R1路由器。

Route>enable /进入特权模式/
Route#con t /进入全局模式/
Route(config) #hostname R2 /给路由器命名/
R2(config)#interface e0 /进入路由器2以太网端口e0/
R2(config-if) #no shutdown /激活路由器2以太网端口e0/ R2(config-if)#ip address
R2(config-if)#exit /返回上一级模式 /
R2(config)#interface e1 /进入路由器2以太网端口e1/ R2(config-if) #no shutdown /激活路由器2以太网端口e1/ R2(config-if)#ip address /返回上一级模式 / R2 (config)#ip route 0.0.0.0
/配置R2的默认路由,为下一跳地址 /
R1(config) #end /返回上一级模式 /
4. 配置路由器R3:
路由器的名字为R3;
E0口的IP地址:;
S0口的IP地址:;
配置RIP路由协议,在它所有的直连网络上启用协议。

程序如下:
Route>enable /进入特权模式/
Route#con t /进入全局模式/
Route(config) #hostname R3 /给路由器命名/
R3(config)#interface e0 /进入路由器3以太网端口e0/ R3(config-if) #no shutdown /激活路由器3以太网端口e0/ R3(config-if)#ip address
R3(config-if)#exit /返回上一级模式/
R3(config) #interface s0 /进入串行端口s0/
R3(config-if) #no shutdown /激活串行端口s0/
R3(config-if)#ip address /配置串口s0 IP地址/
R3(config-if)#ip nat outside
R3(config-if)#router rip。

相关文档
最新文档