1、实验:组建局域网1、局域网技术局域网(LAN)是指在某一区域内由多台计算机互联成的计算机组。一般是方圆几千米以内。局域网可以实现文件管理、软件共享、打印机共享、工作组内的日程安排、电子邮件和传真通信服务等功能。局域网是封闭型的,可以由办公室观众的两台计算机组成,也可以由一个公司的上千台计算组成。2、所用到的硬件及知识点:该实验用到 4 台路由器、3 台交换机、5台 PC 机。VLAN 划分,TRUNK,RIPV2.3、拓扑图:(1) PC 地址表:设备(主机名)IP 地址 子网掩码 默认网关PC1 200.30.40.2 255.255.255.0 200.30.40.1PC2 200.30.
2、50.2 255.255.255.0 200.30.50.1PC3 201.30.60.2 255.255.255.0 201.30.60.1PC4 202.30.61.3 255.255.255.0 202.30.61.1PC5 202.30.70.2 255.255.255.0 202.30.70.1PC6 202.30.70.3 255.255.255.0 202.30.70.1PC7 202.30.71.3 255.255.255.0 202.30.71.1(2)端口分配交换机交换机号 端口 所连 PC 分配 VLANS1 Fa0/1 PC1 VLAN 40S1 Fa0/2 PC2 V
3、LAN 50S2 Fa0/1 PC3 VLAN 60S3 Fa0/1 PC4 VLAN 61S4 Fa0/1 PC5 VLAN 70S5 Fa0/2 PC6 VLAN 70S5 Fa0/3 PC7 VLAN 71(3)接口分配表路由器路由器 接口 地址R1 S0/3/0 200.0.0.2R2 S0/3/0 200.0.0.3R2 S0/3/1 210.0.0.2R3 S0/3/0 210.0.0.3R3 S0/3/1 220.0.0.3R4 S0/3/0 220.0.0.24、局域网具体配置(1)PC 机的配置注:PC2、PC3、PC4 、PC5、PC6、PC7 配置相同(2)设交换机主机名
4、例:Switch1:SwitchenableSwitch#configure terminalSwitch(config)#hostname s1 /s1 为所设置的交换机名称S1(config)#exitRouter 1:RouterenableRouter#configure terminalRouter (config)#hostname R1 /s1 为所设置的交换机名称R1(config)#exit注:路由器 R2,R3,R4 与 R1 设置相同。交换机 S2,S3,S4,S5 与 S1 的设置相同(3)VLAN 设置例: S2S2(config)#interface FastEth
5、ernet0/2 S2(config-if)#switchport mode trunk /将 f0/2 转换成 trunks2(config-if)#no shutdowns2(config-if)#exits2(config)# interface FastEthernet0/1s2(config-if)#no shutdowns2(config-if)#exits2(config)#vlan 60 /创建 VLAN 60S2(config-vlan)#inter vlan 60s2(config-if)# interface FastEthernet0/1s2(config-if)#sw
6、itchport access vlan 60 /加入 VLAN 60s2(config-if)#no shutdown注:如果交换机与交换机,交换机与路由器相连要强制转换为 trunk。若交换机与 PC 则不需要。S1 ,S3,S4 如 s2 配置。(4)路由器设置R1:R1(config)# interface FastEthernet0/0R1(config-if)#no shutdownR1(config-if)#exitR1(config)# interface serial0/3/0R1(config)#ip address 200.0.0.2 255.255.255.0 /写入
7、IPR1(config-if)#no shutdownR1(config-if)#exitR1(config)#interface FastEthernet0/0.40R1(config-subif)#encapsulation dot1q 40 /封装子接口到 VLAN 40R1(config-subif)#ip address 200.30.40.1 255.255.255.0R1(config-subif)#exitR1(config)#interface FastEthernet0/0.50R1(config-subif)#encapsulation dot1q 50 R1(confi
8、g-subif)#ip address 200.30.50.1 255.255.255.0R1(config-subif)#exitR2(config)#interface FastEthernet0/0.60R2(config-subif)#encapsulation dot1q 60 R2(config-subif)#ip address 201.30.60.1 255.255.255.0R2(config-subif)#exit R3(config)#interface FastEthernet0/0.60R3(config-subif)#encapsulation dot1q 61 R
9、3(config-subif)#ip address 202.30.61.1 255.255.255.0R3(config-subif)#exitR3(config)#interface FastEthernet0/0.70R3(config-subif)#encapsulation dot1q 70 R3(config-subif)#ip address 202.30.70.1 255.255.255.0R3(config-subif)#exitR3(config)#interface FastEthernet0/0.71R3(config-subif)#encapsulation dot1
10、q 71 R3(config-subif)#ip address 202.30.71.1 255.255.255.0R3(config-subif)#exitR1(config)#router ripR1(config-router)#version 2 /版本R1(config-router)#network 200.0.0.0 /转发的网络R1(config-router)#network 200.30.40.0 R1(config-router)#network 200.30.50.0R1(config-router)#exit注:R2 转发的网络R2(config-router)#ne
11、twork 200.0.0.0R2(config-router)#network 210.0.0.0R2(config-router)#network 201.30.60.0R3 转发的网络R3(config-router)#network 210.0.0.0R3(config-router)#network 220.0.0.0R3(config-router)#network 202.30.61.0R3(config-router)#network 202.30.70.0R3(config-router)#network 202.30.71.0R4 转发的网络R4(config-router
12、)#network 220. 0. 0.0(5)时钟设置比如 R2 中的 s0/3/0R2(config)# interface serial0/3/0R2(config-if)#ip address 200.0.0.3 255.255.255.0R2(config-if)#clock rate 64000R2(config-if)#no shutdown5、测试PC1 为 VLAN 40,PC2 为 VLAN 50,PC3 为 VLAN 60,PC4 为 VLAN 61,PC5 和 PC6同属于 VLAN 70,PC7 为 VLAN 71(1)同一 VLAN 之间的测试PC5(200.30.
13、70.2)和 PC6(200.30.70.3)之间的测试(2)不同网段之间的测试1、PC1(200.30.40.2)和 PC2(200.30.50.2)先到相应的网段 200.30.50.0,再根据路由表进行转发。2、PC1(200.30.40.2)和 PC3(201.30.60.2)先到相应的网段 201.30.60.0,再根据路由表进行转发。3、PC6(202.30.70.3)和 PC7(202.30.71.3)先到相应的网段 202.30.71.0,再根据路由表进行转发。注:其它的测试如上图所示,均可 Ping 通。5、举例 R3 中的配置R3enableR3#show runBuild
14、ing configuration.Current configuration : 1081 bytes!version 12.4no service timestamps log datetime msecno service timestamps debug datetime msecno service password-encryption!hostname R3!ip name-server 0.0.0.0!interface FastEthernet0/0no ip addressduplex autospeed auto!interface FastEthernet0/0.61e
15、ncapsulation dot1Q 61ip address 202.30.61.1 255.255.255.0!interface FastEthernet0/0.70encapsulation dot1Q 70ip address 202.30.70.1 255.255.255.0!interface FastEthernet0/0.71encapsulation dot1Q 71ip address 202.30.71.1 255.255.255.0!interface FastEthernet0/1no ip addressduplex autospeed autoshutdown!
16、interface Serial0/2/0no ip addressshutdown!interface Serial0/2/1no ip addressshutdown!interface Serial0/3/0ip address 210.0.0.3 255.255.255.0!interface Serial0/3/1ip address 220.0.0.3 255.255.255.0!interface Vlan1no ip addressshutdown!router ripversion 2network 202.30.61.0network 202.30.70.0network
17、202.30.71.0network 210.0.0.0network 220.0.0.0!ip classless!line con 0line vty 0 4login!endS1#show running-configBuilding configuration.Current configuration : 1088 bytes!version 12.1no service timestamps log datetime msecno service timestamps debug datetime msecno service password-encryption!hostnam
18、e S1!interface FastEthernet0/1switchport access vlan 40!interface FastEthernet0/2switchport access vlan 50!interface FastEthernet0/3switchport mode trunk!interface Vlan1no ip addressshutdown!interface Vlan40no ip address!interface Vlan50no ip addressline con 0!line vty 0 4loginline vty 5 15login!end6、总结与心得本次所做的实验,所运用到的知识均为我们上几个星期所配置过的实验。如 RIP、VLAN、子网的划分等等。通过各种路由和交换技术,我们可以组建更为复杂的局域网,本次的实验只是一个简化局域网,但从这次的实验中,我们可以充分的了解到,VLAN 技术可以使网段的分配和管理变得更加方便,灵活。本次实验,让我知道,每做一件事要细心,细心再细心,程序要时时检查,因为一个小细节就有可能会使你的程序发生错误,最后严重的还要重新来过。最重要的是,一定要明白程序中的所以代码,并且发生问题,一定尽量自行解决,以加深自己的印象,依赖别人是不能提高自己的。