計算機網絡實踐(四):交換機基本配置及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#
    


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM