一、概要
使用软件:cisco packet tracer
使用设备:PC机、cisco2960交换机、cisco3560三层交换机
目的:利用RIP协议去搭建一个小型的局域网,以此理解和利用RIP协议
二、拓扑搭建
1、所有的设备连线与vlan划分
把设备按照下图所示连接好线路
共16台PC机、4台cisco-2960交换机、3台cisco-3560三层交换机
连接好线路后,去对16台PC机进行一下vlan划分
将共16台PC机划分为4个vlan域
这里不再对命令进行详解,专栏第一篇文章有基础的介绍
划分vlan实现跨交换机vlan内通信_Re1_zf的博客-CSDN博客
这里以switch0为例,进行一下vlan划分,其余三个switch修改一下端口和vlan就可以,不再进行过多的赘述
switch0
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 10
Switch(config-vlan)#vlan 20
Switch(config-vlan)#int range f0/1-2
Switch(config-if-range)#switchport access vlan 10
Switch(config-if-range)#int range f0/3-4
Switch(config-if-range)#switchport access vlan 20
2、配置所有PC机的IP地址和网关
vlan10:PC0、PC1、PC4、PC5(192.168.1.100/24)
vlan20:PC2、PC3、PC6、PC7(192.168.2.100/24)
vlan30:PC8、PC9、PC12、PC13(192.168.3.100/24)
vlan40:PC10、PC11、PC14、PC15(192.168.4.100/24)
PC0:192.168.1.1
PC1:192.168.1.2
PC2:192.168.2.1
PC3:192.168.2.2
PC4:192.168.1.3
PC5:192.168.1.4
PC6:192.168.2.3
PC7:192.168.2.4
PC8:192.168.3.1
PC9:192.168.3.2
PC10:192.168.4.1
PC11:192.168.4.2
PC12:192.168.3.3
PC13:192.168.3.4
PC14:192.168.4.3
PC15:192.168.4.4
这里以PC0为例配置一下
3、利用2960和3560配置跨vlan通信
先把所有的2960都开启trunk模式
以switch0为例,其他三台交换机也要开启trunk模式
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int f0/5
Switch(config-if)#switchport mode trunk
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to up
启动3560的路由功能
以switch0(3560)为例
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 10
Switch(config-vlan)#vlan 20
Switch(config-vlan)#ip routing
Switch(config)#int vlan 10
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
Switch(config-if)#ip address 192.168.1.100 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#int vlan 20
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
Switch(config-if)#ip address 192.168.2.100 255.255.255.0
Switch(config-if)#no shutdown
这时3560下的PC机都是互通的
配置一下3560的RIP协议
以switch0为例
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int f0/3
Switch(config-if)#no switchport
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up
Switch(config-if)#ip address 192.168.5.1 255.255.255.252
Switch(config-if)#do 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
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
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, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.1.0/24 is directly connected, Vlan10
C 192.168.2.0/24 is directly connected, Vlan20
192.168.5.0/30 is subnetted, 1 subnets
C 192.168.5.0 is directly connected, FastEthernet0/3
Switch(config-if)#router rip
Switch(config-router)#version 2
Switch(config-router)#network 192.168.1.0
Switch(config-router)#network 192.168.2.0
Switch(config-router)#network 192.168.5.0
Switch(config-router)#no auto-summary
为三台3560划分两个vlan域
左边为vlan50,右边为vlan60
为端口分配ip并将其划分到对应的vlan域中
以switch0为例
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 50
Switch(config-vlan)#int f0/3
Switch(config-if)#switchport
Switch(config-if)#switchport access vlan 50
Switch(config-if)#int vlan 50
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan50, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan50, changed state to up
Switch(config-if)#ip address 192.168.5.1 255.255.255.252
Switch(config-if)#no shutdown
4、switch2的配置
switch2划分vlan域
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#ip routing
Switch(config)#vlan 50
Switch(config-vlan)#vlan 60
Switch(config-vlan)#int f0/1
Switch(config-if)#switchport access vlan 50
Switch(config-if)#int f0/2
Switch(config-if)#switchport access vlan 60
为switch2的vlan分配ip地址
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int vlan 50
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan50, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan50, changed state to up
Switch(config-if)#ip address 192.168.5.2 255.255.255.252
Switch(config-if)#no shutdown
Switch(config-if)#int vlan 60
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan60, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan60, changed state to up
Switch(config-if)#ip address 192.168.6.2 255.255.255.252
Switch(config-if)#no shutdown
为switch2进行RIP协议配置
Switch(config-if)#do 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
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
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, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
192.168.5.0/30 is subnetted, 1 subnets
C 192.168.5.0 is directly connected, Vlan50
192.168.6.0/30 is subnetted, 1 subnets
C 192.168.6.0 is directly connected, Vlan60
Switch(config-if)#router rip
Switch(config-router)#version 2
Switch(config-router)#network 192.168.5.0
Switch(config-router)#network 192.168.6.0
Switch(config-router)#no auto-summary
Switch(config-router)#do 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
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
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, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
R 192.168.3.0/24 [120/1] via 192.168.6.1, 00:00:08, Vlan60
R 192.168.4.0/24 [120/1] via 192.168.6.1, 00:00:08, Vlan60
192.168.5.0/30 is subnetted, 1 subnets
C 192.168.5.0 is directly connected, Vlan50
192.168.6.0/30 is subnetted, 1 subnets
C 192.168.6.0 is directly connected, Vlan60
结果
看一下其他三层交换机的路由表
switch0
switch1
至此,RIP协议实现的小型局域网配置完成
可以实现跨vlan通信并计算最短路径
最终拓扑图
一些需要注意的点
前面配置的时候使用了no switchport让f0/3端口使用了二层交换机功能
所以后面使用三层交换机功能的时候需要使用一下switchport使用端口的三层交换机功能
其次就是前面的no switchport的使用是因为一开始使用的是全是二层交换机的功能