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. 設(shè)置ARP表老化時(shí)間
<Huawei>sys //設(shè)置arp老化時(shí)間為200秒 [Huawei]mac-address aging-time 200C. 配置端口的速率和工作模式
[Huawei]int e0/0/1 //關(guān)閉端口自動(dòng)協(xié)商 [Huawei-Ethernet0/0/1]undo negotiation auto //設(shè)定端口速率為10M [Huawei-Ethernet0/0/1]speed 10 //設(shè)定端口速率為100M [Huawei-Ethernet0/0/1]speed 100 //設(shè)置端口工作模式為全雙工 [Huawei-Ethernet0/0/1]duplex full //設(shè)置端口工作模式為半雙工 [Huawei-Ethernet0/0/1]duplex halfD. 設(shè)置端口描述
[Huawei]int eth0/0/1 //描述的內(nèi)容為“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. 配置單個(gè)VLAN
<Huawei>sys Enter system view, return user view with Ctrl+Z. //創(chuàng)建vlan 10 [Huawei]vlan 10 //設(shè)置描述為“財(cái)務(wù)” [Huawei-vlan10]description caiwu //創(chuàng)建vlan 20 [Huawei-vlan10]vlan 20 //設(shè)置描述為“銷售” [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:接入模式。主要時(shí)交換機(jī)連接終端設(shè)備的接口。只能允許唯一的vlan ID通過本接口。
access端口收發(fā)數(shù)據(jù)幀的原則:
收——如果該端口收到對(duì)端發(fā)送的不帶標(biāo)簽的幀,交換機(jī)會(huì)加上端口所處的PVID。如果該端口收到對(duì)端發(fā)送的帶標(biāo)簽的幀,則會(huì)檢查該標(biāo)簽的VLAN ID,當(dāng)該VLAN ID與該端口的PVID相同,則接收該幀;否則丟棄該幀。
發(fā)——判斷是否和自己的VLAN ID相同,若相同則剝離VLAN ID標(biāo)簽,再重新發(fā)送。
access端口發(fā)往對(duì)端的以太網(wǎng)幀,永遠(yuǎn)是不帶標(biāo)簽的幀。
B. Trunk:干道鏈路。交換機(jī)與交換機(jī)之間連接的接口。允許多個(gè)vlan(帶tag幀)通過本接口。
Trunk端口收發(fā)數(shù)據(jù)幀的原則:
收——當(dāng)接收到對(duì)端設(shè)備發(fā)送的不帶標(biāo)簽的數(shù)據(jù)幀,交換機(jī)會(huì)加上該端口所處的PVID,如果該P(yáng)VID在端口允許通過的VLAN ID列表中,則接收該報(bào)文,否則丟棄該報(bào)文。當(dāng)接收到對(duì)端設(shè)備發(fā)送的帶標(biāo)簽的數(shù)據(jù)幀,檢查VLAN ID是否在允許通過的VLAN ID列表中,若在則接收該幀,否則丟棄該幀。
發(fā)——當(dāng)VLAN ID與端口的PVID相同,且在允許通過的VLAN ID列表中,則剝離去掉VLAN ID。當(dāng)VLAN ID 與端口的PVID不同,但在允許通過的VLAN ID列表中,則保持原有的VLAN ID,發(fā)送該幀。
本征VLAN——本征VLAN在Trunk鏈路上不帶標(biāo)記,交換機(jī)收到不帶標(biāo)記的幀的時(shí)候,將會(huì)發(fā)到本幀VLAN
//先要?jiǎng)?chuàng)建vlan [Huawei]vlan batch 90 to 100 [Huawei]int e0/0/3 //設(shè)置Trunk端口的本征vlan [Huawei-Ethernet0/0/3]port trunk pvid vlan 100推薦:把Trunk的本征VLAN設(shè)置不常用的VLAN;把交換機(jī)上不常用的端口設(shè)置不常用的VLAN且把端口shutdown。Trunk鏈路最好只允許相對(duì)應(yīng)的vlan。
C. Hybrid:既可以連接終端又可以連接交換機(jī)。
Hybrid端口收發(fā)規(guī)則:
收——當(dāng)接收到對(duì)端設(shè)備發(fā)送的不帶標(biāo)簽的數(shù)據(jù)幀時(shí),會(huì)添加端口的PVID,如果PVID在允許通過的列表中,則接收該報(bào)文,否則丟棄該報(bào)文。當(dāng)接收到對(duì)端設(shè)備發(fā)送的帶標(biāo)簽的數(shù)據(jù)幀時(shí),檢查VLAN ID是否在允許通過的列表中,若在接收該報(bào)文,否則丟棄該報(bào)文。
發(fā)——Hybrid端口發(fā)送數(shù)據(jù)幀時(shí),檢查該端口是否允許該VLAN通過,如果允許通過則通過命令設(shè)置是否攜帶標(biāo)簽。
a. 配置port hybrid tagged vlan vlan_id 命令后,接口發(fā)送該vlan_id數(shù)據(jù)幀后,不剝離幀中的vlan標(biāo)簽,直接發(fā)送。該命令一般配置在連接交換機(jī)的端口上。
b. 配置port hybrid untagged vlan vlan_id 命令后,接口發(fā)送該vlan_id數(shù)據(jù)幀后,會(huì)將vlan標(biāo)簽剝離后再發(fā)送。該命令一般配置在連接終端的端口上。
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測(cè)試:
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總結(jié)
以上是生活随笔為你收集整理的HCNP-路由交换:交换机基础的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: AutoCAD 2009建筑设计实战从入
- 下一篇: 1.Moveit 创建六轴机械臂模型