交换机配置MSTP与VLAN间通信

2025-10-10 15:07:06

1、一、搭建本次实验的拓扑结构

两台核心交换机、两台接入交换机(由于设备的性能,只能模拟四台,条件好的请自行添加设备数量)

交换机配置MSTP与VLAN间通信

2、二、配置交换机的VLAN信息

[SW1]vlan ba 2 3Info: This operation may take a few seconds. Please wait for a moment...done.[SW1]dis vlan The total number of vlans is : 3--------------------------------------------------------------------------------U: Up;         D: Down;         TG: Tagged;         UT: Untagged;MP: Vlan-mapping;               ST: Vlan-stacking;#: ProtocolTransparent-vlan;    *: Management-vlan;--------------------------------------------------------------------------------

VID  Type    Ports                                                          --------------------------------------------------------------------------------1    common  UT:GE0/0/1(U)      GE0/0/2(U)      GE0/0/3(D)      GE0/0/4(D)                      GE0/0/5(D)      GE0/0/6(D)      GE0/0/7(D)      GE0/0/8(D)                      GE0/0/9(U)      GE0/0/10(U)     GE0/0/11(D)     GE0/0/12(D)                     GE0/0/13(D)     GE0/0/14(D)     GE0/0/15(D)     GE0/0/16(D)                     GE0/0/17(D)     GE0/0/18(D)     GE0/0/19(D)     GE0/0/20(D)                     GE0/0/21(D)     GE0/0/22(D)     GE0/0/23(D)     GE0/0/24(D)     2    common  TG:GE0/0/1(U)      GE0/0/2(U)      GE0/0/9(U)      GE0/0/10(U)     3    common  TG:GE0/0/1(U)      GE0/0/2(U)      GE0/0/9(U)      GE0/0/10(U)    

VID  Status  Property      MAC-LRN Statistics Description      --------------------------------------------------------------------------------1    enable  default       enable  disable    VLAN 0001                         2    enable  default       enable  disable    VLAN 0002                         3    enable  default       enable  disable    VLAN 0003

在四台交换机配置同样的内容

交换机配置MSTP与VLAN间通信

3、三、配置VLAN的接口信息,配置VLANif的地址(只在SW1上配置)

[SW1]int vlanif 2[SW1-Vlanif2] ip address 10.0.20.1 255.255.255.0[SW1-Vlanif2]q[SW1]int vlanif 3[SW1-Vlanif3]ip address 10.0.30.1 255.255.255.0[SW1-Vlanif3]

交换机配置MSTP与VLAN间通信

4、四、将交换机的接口加入VLAN中

SW1上的G0/0/1、G0/0/2、G0/0/9、G0/0/10配置trunk端口,允许VLAN 2、3通过

SW2上的G0/0/1、G0/0/2、G0/0/9、G0/0/10配置trunk端口,允许VLAN 2、3通过

SW3上的E0/0/1、E0/0/3配置trunk端口,允许VLAN 2、3通过,E0/0/2、E0/0/4配置成access端口,允许VLAN 2或VLAN 3通过

SW4上的E0/0/1、E0/0/3配置trunk端口,允许VLAN 2、3通过,E0/0/2配置成access端口,允许VLAN 2或VLAN 3通过

[SW1]int g0/0/1[SW1-GigabitEthernet0/0/1]dis th#interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 to 3#return[SW1-GigabitEthernet0/0/1]int g0/0/2[SW1-GigabitEthernet0/0/2]dis th#interface GigabitEthernet0/0/2 port link-type trunk port trunk allow-pass vlan 2 to 3#return[SW1-GigabitEthernet0/0/2]

这里没有具体配置,请参考其他的文章,怎么添加VLAN信息到接口上

交换机配置MSTP与VLAN间通信

5、五、配置电脑和路由器的信息

此处的路由器充当电脑使用,由于没有网关,需配静态路由充当网关

如果电脑上配置成10.0.20.2网关10.0.20.1,请在SW3对于的接口加入到VLAN2,反之加入VLAN3

路由器配置

interface GigabitEthernet0/0/1 ip address 10.0.20.2 255.255.255.0 #interface NULL0                           #ip route-static 0.0.0.0 0.0.0.0 10.0.20.1

交换机配置MSTP与VLAN间通信

6、六、从路由器上ping到PC的网络是否通畅

[R1]ping 10.0.30.10  PING 10.0.30.10: 56  data bytes, press CTRL_C to break    Request time out    Reply from 10.0.30.10: bytes=56 Sequence=2 ttl=127 time=110 ms    Reply from 10.0.30.10: bytes=56 Sequence=3 ttl=127 time=130 ms    Reply from 10.0.30.10: bytes=56 Sequence=4 ttl=127 time=170 ms    Reply from 10.0.30.10: bytes=56 Sequence=5 ttl=127 time=130 ms

  --- 10.0.30.10 ping statistics ---    5 packet(s) transmitted    4 packet(s) received    20.00% packet loss    round-trip min/avg/max = 110/135/170 ms

交换机配置MSTP与VLAN间通信

7、七、配置MSTP信息并检查网络

[SW1]stp region-configuration

[SW1-mst-region] region-name RG1[SW1-mst-region]  revision-level 1

[SW1-mst-region]  instance 1 vlan 2 to 3[SW1-mst-region] active region-configuration

四台交换机配置相同

在SW1上配置实例1的优先级

[S1]stp instance 1 priority 4096

交换机配置MSTP与VLAN间通信

交换机配置MSTP与VLAN间通信

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢