网络互连要求:
- 规划和设计各路由接口的IP地址,并使用动态路由协议OSPF,进程号每人使用自己的序号
- 按照网络拓扑图,配置好三层交换机,创建VLAN,给VLAN配置适当的IP地址,把接口加入相应的VLAN,启用动态路由协议OSPF,使所有VLAN之间的主机能正确路由
- 配置所有计算机和服务器的IP地址
- 在所有交换机上启用PVST生成树模式,并查看此时哪个交换机是树根,有连接线的端口分别是什么模式端口
- 给交换机设置优先级,S2为4096,S1为8192,其余的为默认值;查看此时哪个交换机为根交换机,所有交换机有连接线的端口分别是什么模式端口
- 把交换机S2关电,查看此时哪个交换机为根交换机,三个计算机分别走哪些交换机线路到达FTP服务器的
- 把交换机S2关电,在交换机S3和S4之间的F0/24相连接;把S3和S2之间的线路带宽设置为10Mbps,看看此时PC1走哪些交换机线路到达FTP服务器的
- 把交换机S2恢复供电,在S1的VLAN 2上设置优先级为4096, 在S2的 VLAN 2上设置优先级为8192; 在S1的VLAN 3上设置优先级为8192, 在S2的 VLAN 3上设置优先级为4096;查看此时VLAN 2和VLAN 3的根交换机分别是哪一台
配置代码:
S1:
en
conf t
host s1
no ip domain-lookup
vlan 2
exit
vlan 3
exit
vlan 4
Exit
vlan 5
Exit
Vlan 6
exit
int vlan 2
ip address 192.168.2.254 255.255.255.0
int vlan 3
ip address 192.168.3.254 255.255.255.0
int vlan 4
ip address 192.168.4.254 255.255.255.0
int vlan 5
ip address 192.168.5.254 255.255.255.0
int vlan 6
ip address 192.168.6.254 255.255.255.0
int f0/1
switchport access vlan 2
int f0/2
switchport access vlan 3
int f0/3
switchport access vlan 4
int f0/4
switchport mode access
switchport mode trunk
int f0/5
switchport access vlan 6
int f0/6
switchport access vlan 5
ip routing
Router ospf 22
Network 192.168.2.0 0.0.0.255 area 0
Network 192.168.3.0 0.0.0.255 area 0
Network 192.168.4.0 0.0.0.255 area 0
Network 192.168.5.0 0.0.0.255 area 0
Network 192.168.6.0 0.0.0.255 area 0
spanning-tree mode pvst
!就是启用基于VLAN的生成树模式,这是思科的独有用法,简单说就是一个VLAN
!一棵树,在一个网络里,不同的VLAN可以有不同的根桥,不同的阻塞端口等等,其主要目
!的是为了提高链路利用率(可以想象,如果所有VLAN都是同一棵树,必定有一部分线路
!处于完全的block状态)
exit
show spanning-tree
S2:
en
conf t
host s2
no ip domain-lookup
vlan 2
exit
vlan 3
exit
vlan 4
Exit
vlan 5
Exit
Vlan 6
exit
int vlan 2
ip address 192.168.2.253 255.255.255.0
int vlan 3
ip address 192.168.3.253 255.255.255.0
int vlan 4
ip address 192.168.4.253 255.255.255.0
int vlan 5
ip address 192.168.5.253 255.255.255.0
int vlan 6
ip address 192.168.6.253 255.255.255.0
int f0/1
switchport access vlan 2
int f0/2
switchport access vlan 3
int f0/3
switchport access vlan 4
int f0/4
switchport mode access
switchport mode trunk
int f0/5
switchport access vlan 6
ip routing
Router ospf 22
Network 192.168.2.0 0.0.0.255 area 0
Network 192.168.3.0 0.0.0.255 area 0
Network 192.168.4.0 0.0.0.255 area 0
Network 192.168.6.0 0.0.0.255 area 0
spanning-tree mode pvst
exit
show spanning-tree
S3:
En
Conf t
Host s3
Int range f0/1-3
Switchport access vlan 2
exit
spanning-tree mode pvst
exit
show spanning-tree
S4:
En
Conf t
Host s4
Int range f0/1-3
Switchport access vlan 3
exit
spanning-tree mode pvst
exit
show spanning-tree
S5:
En
Conf t
Host s5
Int range f0/1-3
Switchport access vlan 4
exit
spanning-tree mode pvst
exit
show spanning-tree
S6:
En
Conf t
Host s6
spanning-tree mode pvst
exit
show spanning-tree
R1:
En
Conf t
Host r1
No ip domain-lookup
Int g0/0
Ip address 192.168.6.1 255.255.255.0
No shut
Int g0/1
Ip address 202.120.80.2 255.255.255.0
No shut
Int loopback 0
Ip address 1.1.1.1 255.255.255.255
No shut
Exit
Router ospf 22
Network 192.168.6.0 0.0.0.255 area 0
Network 202.120.80.0 0.0.0.255 area 0
R2:
En
Conf t
Host r2
No ip domain-lookup
Int g0/0
Ip address 192.168.6.2 255.255.255.0
No shut
Int g0/1
Ip address 202.120.80.3 255.255.255.0
No shut
Int loopback 0
Ip address 2.2.2.2 255.255.255.255
No shut
Exit
Router ospf 22
Network 192.168.6.0 0.0.0.255 area 0
Network 202.120.80.0 0.0.0.255 area 0
配置前4步代码之后:
注意:如果端口既做了根端口,又做了指定端口,又做了阻塞端口,那对于模拟器而言,就是优先依次显示了,即显示为绿色
S1:
S2:
S3:
S4:
S5:
S6:
疑问解答:
S1和S6隔着路由器,已经不是一个VLAN了,同一个VLAN的话,要不就线路上都是一个VLAN,要不就是有TRUNK连接,如果被三层以上设备隔离了,就是不同VLAN了,虽然你在自己交换机上是这样叫的,实则不是一个VLAN,因为IP段已经不同了
完成第4步之后,即配置完成
S1:spanning-tree vlan 1-6 priority 8192
S2:spanning-tree vlan 1-6 priority 4096之后
S1:
S2:
S3:
S4:
S5:
S6:
6:把交换机S2关电,查看此时哪个交换机为根交换机,三个计算机分别走哪些交换机线路到达FTP服务器的;
Int range f0/1-5
Shutdown
之后:
S1:
ftp:
7:把交换机S2关电,在交换机S3和S4之间的F0/24相连接;把S3和S2之间的线路带宽设置为10Mbps,看看此时PC1走哪些交换机线路到达FTP服务器的;
S3修改链路带宽:
Int f0/2
speed 10
S3:
Int f0/24
Switchport access vlan 2
S4:
Vlan 2
Exit
Int f0/24
Switchport access vlan 2
Int f0/2
Switchport mode trunk
之后:
S1:
S3:
S4:
S5:
PC1->ftp:
8:把交换机S2恢复供电,在S1的VLAN 2上设置优先级为4096, 在S2的 VLAN 2上设置优先级为8192; 在S1的VLAN 3上设置优先级为8192, 在S2的 VLAN 3上设置优先级为4096;查看此时VLAN 2和VLAN 3的根交换机分别是哪一台
S2:
int range f0/1-5
no shutdown
S1:
spanning-tree vlan 2 priority 4096
spanning-tree vlan 3 priority 8192
S2:
spanning-tree vlan 2 priority 8192
spanning-tree vlan 3 priority 4096
配置之后:
S1:
S2:
S3:
S4:
S5: