计算机网络实践(四):交换机基本配置及Vlan

实验环境:Packet Tracer,由于课下没有机架设备,于是采用Packet Tracer进行仿真复现,命令是一样的,因此作为教程也没什么大碍。

笔记

以太网交换机实质上就是一个多接口的网桥,通常都有十几个或更多的接口,和工作在物理层的转发器、集线器有很大差别,对收到的帧根据其MAC帧的目的地址进行转发和过滤,而不是向所有的接口转发此帧,期内不得帧交换表是通过子学习算法自动地逐渐建立起来的。

交换机上链接主机的端口配置为Access接口,access接口手法的数据帧都为标准以太网帧,即非802.1Q帧,从access接口接收的标准以太网帧,会从同一VLAN的其他access接口转发出去,同时也会从Trunk接口转换为802.1Q帧转发出去。

交换机互联接口要配置成Trunk接口,Trunk接口接收到了802.1Q帧,会从相应的Access接口转发出去,同时剥离了TAG标记转变成标准以太网帧;如果交换机上没有配置access接口,只配置了Trunk接口,那么也会将接收到的802.1Q数据帧从其他Trunk接口转发出去,但前提是该交换机已经创建了所接收到802.1Q帧中包含的VLAN ID对应的VLAN,否则会丢弃接收到的802.1Q帧。

实验

网络拓扑图如下

  1. 配置主机IP地址和子网掩码

  2. 配置左侧交换机

    Switch>enable
    Switch#configure terminal 
    Enter configuration commands, one per line.  End with CNTL/Z.
    Switch(config)#vlan 10
    Switch(config-vlan)#exit
    Switch(config)#vlan 30
    Switch(config-vlan)#exit
    Switch(config)#interface fastEthernet 0/1
    Switch(config-if)#switchport mode access
    Switch(config-if)#switchport access vlan 10
    Switch(config-if)#exit
    Switch(config)#interface fastEthernet 0/2
    Switch(config-if)#switchport access vlan 30
    Switch(config-if)#exit
    Switch(config)#interface fastEthernet 0/3
    Switch(config-if)#switchport mode trunk
    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)#exit
    Switch(config)#
    
  3. 配置中间交换机

    Switch#conf
    Switch#configure terminal 
    Enter configuration commands, one per line.  End with CNTL/Z.
    Switch(config)#vlan 30
    Switch(config-vlan)#vlan 20
    Switch(config-vlan)#vlan 10				//记得声明vlan10,不然vlan10的主机无法通信,原因参考笔记
    Switch(config-vlan)#exit
    Switch(config)#interface fastEthernet 0/1
    Switch(config-if)#switchport mode trunk
    Switch(config-if)#exit
    Switch(config)#interface fastEthernet 0/4
    Switch(config-if)#switchport mode trunk
    Switch(config-if)#exit
    Switch(config)#interface fastEthernet 0/2
    Switch(config-if)#switchport access vlan 30
    Switch(config-if)#exit
    Switch(config)#interface fastEthernet 0/3
    Switch(config-if)#switchport access vlan 20
    Switch(config-if)#exit
    Switch(config)#exit
    Switch#
    
  4. 配置右侧交换机

    Switch>enable
    Switch#configure terminal 
    Enter configuration commands, one per line.  End with CNTL/Z.
    Switch(config)#vlan 20
    Switch(config-vlan)#vlan 10
    Switch(config-vlan)#exit
    Switch(config)#interface fastEthernet 0/1
    Switch(config-if)#switchport mode trunk
    Switch(config-if)#exit
    Switch(config)#interface fastEthernet 0/2
    Switch(config-if)#switchport access vlan 20
    Switch(config-if)#exit
    Switch(config)#interface fastEthernet 0/3
    Switch(config-if)#switchport access vlan 10
    Switch(config-if)#exit
    Switch(config)#exit
    Switch#
    
posted @ 2021-05-26 17:11  扶磐  阅读(914)  评论(0编辑  收藏  举报