HCNP-路由交换:交换机基础
1. 基本配置
A. 查看MAC表
<Huawei>dis mac-address MAC address table of slot 0: ------------------------------------------------------------------------------- MAC Address VLAN/ PEVLAN CEVLAN Port Type LSP/LSR-ID VSI/SI MAC-Tunnel ------------------------------------------------------------------------------- 5489-982e-0171 1 - - Eth0/0/2 dynamic 0/- 5489-986c-4022 1 - - Eth0/0/1 dynamic 0/- ------------------------------------------------------------------------------- Total matching items on slot 0 displayed = 2B. 設置ARP表老化時間
<Huawei>sys //設置arp老化時間為200秒 [Huawei]mac-address aging-time 200C. 配置端口的速率和工作模式
[Huawei]int e0/0/1 //關閉端口自動協商 [Huawei-Ethernet0/0/1]undo negotiation auto //設定端口速率為10M [Huawei-Ethernet0/0/1]speed 10 //設定端口速率為100M [Huawei-Ethernet0/0/1]speed 100 //設置端口工作模式為全雙工 [Huawei-Ethernet0/0/1]duplex full //設置端口工作模式為半雙工 [Huawei-Ethernet0/0/1]duplex halfD. 設置端口描述
[Huawei]int eth0/0/1 //描述的內容為“TO-SW2-E0/0/1” [Huawei-Ethernet0/0/1]description TO-SW2-E0/0/1E. 清空端口配置
[Huawei]clear configuration int eth0/0/1 Warning: All configurations of the interface will be cleared, and its state willbe shutdown. Continue? [Y/N] :y Info: Total execute 2 command(s), 2 successful, 0 failed.2. VLAN
A. 配置單個VLAN
<Huawei>sys Enter system view, return user view with Ctrl+Z. //創建vlan 10 [Huawei]vlan 10 //設置描述為“財務” [Huawei-vlan10]description caiwu //創建vlan 20 [Huawei-vlan10]vlan 20 //設置描述為“銷售” [Huawei-vlan20]description xiaoshouB. 批量配置vlan
[Huawei]vlan batch 30 to 35 40 to 43 Info: This operation may take a few seconds. Please wait for a moment...done. //查看vlan [Huawei]dis vlan The total number of vlans is : 13 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; --------------------------------------------------------------------------------VID Type Ports -------------------------------------------------------------------------------- 1 common UT:Eth0/0/1(U) Eth0/0/2(U) Eth0/0/3(U) Eth0/0/4(D) Eth0/0/5(D) Eth0/0/6(D) Eth0/0/7(D) Eth0/0/8(D) Eth0/0/9(D) Eth0/0/10(D) Eth0/0/11(D) Eth0/0/12(D) Eth0/0/13(D) Eth0/0/14(D) Eth0/0/15(D) Eth0/0/16(D) Eth0/0/17(D) Eth0/0/18(D) Eth0/0/19(D) Eth0/0/20(D) Eth0/0/21(D) Eth0/0/22(D) GE0/0/1(D) GE0/0/2(D) 10 common 20 common 30 common 31 common 32 common 33 common 34 common 35 common 40 common 41 common 42 common 43 common VID Status Property MAC-LRN Statistics Description --------------------------------------------------------------------------------1 enable default enable disable VLAN 0001 10 enable default enable disable caiwu 20 enable default enable disable xiaoshou 30 enable default enable disable VLAN 0030 31 enable default enable disable VLAN 0031 32 enable default enable disable VLAN 0032 33 enable default enable disable VLAN 0033 34 enable default enable disable VLAN 0034 35 enable default enable disable VLAN 0035 40 enable default enable disable VLAN 0040 41 enable default enable disable VLAN 0041 42 enable default enable disable VLAN 0042 43 enable default enable disable VLAN 0043 //刪除vlan [Huawei]undo vlan batch 40 to 43 Warning: The configurations of the VLAN will be deleted. Continue?[Y/N]:Y Info: This operation may take a few seconds. Please wait for a moment...done.3. 鏈路類型
A. acess:接入模式。主要時交換機連接終端設備的接口。只能允許唯一的vlan ID通過本接口。
access端口收發數據幀的原則:
收——如果該端口收到對端發送的不帶標簽的幀,交換機會加上端口所處的PVID。如果該端口收到對端發送的帶標簽的幀,則會檢查該標簽的VLAN ID,當該VLAN ID與該端口的PVID相同,則接收該幀;否則丟棄該幀。
發——判斷是否和自己的VLAN ID相同,若相同則剝離VLAN ID標簽,再重新發送。
access端口發往對端的以太網幀,永遠是不帶標簽的幀。
B. Trunk:干道鏈路。交換機與交換機之間連接的接口。允許多個vlan(帶tag幀)通過本接口。
Trunk端口收發數據幀的原則:
收——當接收到對端設備發送的不帶標簽的數據幀,交換機會加上該端口所處的PVID,如果該PVID在端口允許通過的VLAN ID列表中,則接收該報文,否則丟棄該報文。當接收到對端設備發送的帶標簽的數據幀,檢查VLAN ID是否在允許通過的VLAN ID列表中,若在則接收該幀,否則丟棄該幀。
發——當VLAN ID與端口的PVID相同,且在允許通過的VLAN ID列表中,則剝離去掉VLAN ID。當VLAN ID 與端口的PVID不同,但在允許通過的VLAN ID列表中,則保持原有的VLAN ID,發送該幀。
本征VLAN——本征VLAN在Trunk鏈路上不帶標記,交換機收到不帶標記的幀的時候,將會發到本幀VLAN
//先要創建vlan [Huawei]vlan batch 90 to 100 [Huawei]int e0/0/3 //設置Trunk端口的本征vlan [Huawei-Ethernet0/0/3]port trunk pvid vlan 100推薦:把Trunk的本征VLAN設置不常用的VLAN;把交換機上不常用的端口設置不常用的VLAN且把端口shutdown。Trunk鏈路最好只允許相對應的vlan。
C. Hybrid:既可以連接終端又可以連接交換機。
Hybrid端口收發規則:
收——當接收到對端設備發送的不帶標簽的數據幀時,會添加端口的PVID,如果PVID在允許通過的列表中,則接收該報文,否則丟棄該報文。當接收到對端設備發送的帶標簽的數據幀時,檢查VLAN ID是否在允許通過的列表中,若在接收該報文,否則丟棄該報文。
發——Hybrid端口發送數據幀時,檢查該端口是否允許該VLAN通過,如果允許通過則通過命令設置是否攜帶標簽。
a. 配置port hybrid tagged vlan vlan_id 命令后,接口發送該vlan_id數據幀后,不剝離幀中的vlan標簽,直接發送。該命令一般配置在連接交換機的端口上。
b. 配置port hybrid untagged vlan vlan_id 命令后,接口發送該vlan_id數據幀后,會將vlan標簽剝離后再發送。該命令一般配置在連接終端的端口上。
SW1的配置:
SW2配置:
<Huawei>sys [Huawei]clear configuration int e0/0/1 [Huawei]clear configuration int e0/0/2 [Huawei]clear configuration int e0/0/3 [Huawei]sysname sw2 [sw2]vlan batch 2 to 3 //配置端口e0/0/1 [sw2]int e0/0/1 [sw2-Ethernet0/0/1]undo shutdown [sw2-Ethernet0/0/1]port link-type hybrid [sw2-Ethernet0/0/1]port hybrid pvid vlan 2 [sw2-Ethernet0/0/1]port hybrid untagged vlan 2 //配置端口e0/0/2 [sw2-Ethernet0/0/1]int e0/0/2 [sw2-Ethernet0/0/2]undo shutdown [sw2-Ethernet0/0/2]port link-type hybrid [sw2-Ethernet0/0/2]port hybrid pvid vlan 3 [sw2-Ethernet0/0/2]port hybrid untagged vlan 3 //配置端口e0/0/3 [sw2-Ethernet0/0/2]int e0/0/3 [sw2-Ethernet0/0/2]undo shutdown [sw2-Ethernet0/0/3]port link-type hybrid [sw2-Ethernet0/0/3]port hybrid tagged vlan 2 [sw2-Ethernet0/0/3]port hybrid tagged vlan 3用PC1測試:
PC>ping 192.168.1.2Ping 192.168.1.2: 32 data bytes, Press Ctrl_C to break From 192.168.1.1: Destination host unreachable From 192.168.1.1: Destination host unreachable From 192.168.1.1: Destination host unreachable From 192.168.1.1: Destination host unreachable From 192.168.1.1: Destination host unreachable--- 192.168.1.2 ping statistics ---5 packet(s) transmitted0 packet(s) received100.00% packet lossPC>ping 192.168.1.3Ping 192.168.1.3: 32 data bytes, Press Ctrl_C to break From 192.168.1.3: bytes=32 seq=1 ttl=128 time=62 ms From 192.168.1.3: bytes=32 seq=2 ttl=128 time=78 ms From 192.168.1.3: bytes=32 seq=3 ttl=128 time=94 ms From 192.168.1.3: bytes=32 seq=4 ttl=128 time=94 ms From 192.168.1.3: bytes=32 seq=5 ttl=128 time=62 ms--- 192.168.1.3 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 62/78/94 msPC>ping 192.168.1.4Ping 192.168.1.4: 32 data bytes, Press Ctrl_C to break From 192.168.1.1: Destination host unreachable From 192.168.1.1: Destination host unreachable From 192.168.1.1: Destination host unreachable From 192.168.1.1: Destination host unreachable From 192.168.1.1: Destination host unreachable--- 192.168.1.4 ping statistics ---5 packet(s) transmitted0 packet(s) received100.00% packet loss總結
以上是生活随笔為你收集整理的HCNP-路由交换:交换机基础的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: AutoCAD 2009建筑设计实战从入
- 下一篇: 1.Moveit 创建六轴机械臂模型