》Huawei-R&S-網絡工程師實驗筆記20190608-VLAN劃分基礎(基於端口、MAC地址、子網地址、協議)網絡
》》實驗開始,先上拓撲圖參考:app
1、基於端口劃分VLAN:oop
[SWA]vlan 10 //建立VLAN10,這一步是前提(設備默認只有VLAN 1) [SWA-vlan10] Jun 9 2019 02:11:50-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 2, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-vlan10]q [SWA]int g0/0/1 [SWA-GigabitEthernet0/0/1]port link-type ? //查詢配置端口類型的命令 access Access port dot1q-tunnel QinQ port hybrid Hybrid port trunk Trunk port [SWA-GigabitEthernet0/0/1]port link-type access //配置端口爲Access類型 [SWA-GigabitEthernet0/0/1] Jun 9 2019 02:10:10-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 1, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/1]port default vlan 10 //將端口劃分到VLAN 10 [SWA-GigabitEthernet0/0/1] Jun 9 2019 02:12:40-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 3, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/1]int g0/0/2 [SWA-GigabitEthernet0/0/2]port link-type access [SWA-GigabitEthernet0/0/2] Jun 9 2019 02:13:30-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 4, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/2]port default vlan 10 [SWA-GigabitEthernet0/0/2] Jun 9 2019 02:14:00-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 5, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/2]int g0/0/3 [SWA-GigabitEthernet0/0/3]port link-type access [SWA-GigabitEthernet0/0/3] Jun 9 2019 02:14:50-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 6, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/3]port def [SWA-GigabitEthernet0/0/3]port default vlan 10 [SWA-GigabitEthernet0/0/3] Jun 9 2019 02:15:50-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 7, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/3]q [SWA]dis vlan //查看VLAN端口信息 The total number of vlans is : 2 -------------------------------------------------------------------------------- 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/4(D) GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) //默認VLAN 1的端口 GE0/0/8(D) GE0/0/9(D) GE0/0/10(D) 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) 10 common UT:GE0/0/1(U) GE0/0/2(U) GE0/0/3(U) //3個端口被劃分進了VLAN 10 VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 [SWA]dis port vlan active //查看VLAN端口信息,顯示PVID和VLAN LIST T=TAG U=UNTAG ------------------------------------------------------------------------------- Port Link Type PVID VLAN List ------------------------------------------------------------------------------- GE0/0/1 access 10 U: 10 GE0/0/2 access 10 U: 10 GE0/0/3 access 10 U: 10 GE0/0/4 hybrid 1 U: 1 GE0/0/5 hybrid 1 U: 1 GE0/0/6 hybrid 1 U: 1 GE0/0/7 hybrid 1 U: 1 [SWA]
2、基於MAC地址劃分VLAN:ui
[SWA]dis vlan //檢查VLAN狀態信息 The total number of vlans is : 1 //顯示只有一個默認VLAN 1 -------------------------------------------------------------------------------- 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(U) GE0/0/4(D) GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D) GE0/0/9(D) GE0/0/10(D) 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) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 [SWA]vlan 10 //建立VLAN 10 [SWA-vlan10]int g0/0/1 [SWA-GigabitEthernet0/0/1]port hybrid untagged vlan 10 //在G0/0/1(默認Hybrid)端口下配置Untagged VLAN 10 [SWA-GigabitEthernet0/0/1] Jun 9 2019 10:06:42-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 2, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/1]int g0/0/2 [SWA-GigabitEthernet0/0/2]port hybrid untagged vlan 10 //在G0/0/2(默認Hybrid)端口下配置Untagged VLAN 10 [SWA-GigabitEthernet0/0/2] Jun 9 2019 10:08:12-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 3, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/2]int g0/0/3 [SWA-GigabitEthernet0/0/3]port hybrid untagged vlan 10 //在G0/0/3(默認Hybrid)端口下配置Untagged VLAN 10 [SWA-GigabitEthernet0/0/3] Jun 9 2019 10:08:52-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 4, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/3]q [SWA]dis port vlan active //檢查VLAN端口激活情況(Hybrid端口的Untagged列表中默認只有VLAN 1) T=TAG U=UNTAG ------------------------------------------------------------------------------- Port Link Type PVID VLAN List ------------------------------------------------------------------------------- GE0/0/1 hybrid 1 U: 1 10 //Hybrid端口的Untagged列表中配置增長了VLAN 10 GE0/0/2 hybrid 1 U: 1 10 //Hybrid端口的Untagged列表中配置增長了VLAN 10 GE0/0/3 hybrid 1 U: 1 10 //Hybrid端口的Untagged列表中配置增長了VLAN 10 GE0/0/4 hybrid 1 U: 1 GE0/0/5 hybrid 1 U: 1 GE0/0/6 hybrid 1 U: 1 GE0/0/7 hybrid 1 U: 1 [SWA] [SWA]vlan 10 [SWA-vlan10]mac-vlan ? mac-address MAC address [SWA-vlan10]mac-vlan mac-address ? H-H-H MAC address //指定與vlan10關聯的MAC地址,常見格式xx:xx:xx:xx:xx:xx,此處xxxx-xxxx-xxxx(都是16進制) [SWA-vlan10]mac-vlan mac-address 5400-0000-0001 ? H-H-H Value of MAC address mask //指定MAC地址的掩碼,格式仍是xxxx-xxxx-xxxx(16進制) INTEGER<1-48> Length of MAC address mask //指定MAC地址的掩碼長度,整數型 priority Priority information //指定MAC地址對應vlan的802.1p優先級[0-7](默認爲0,值越大、級越高) <cr> [SWA-vlan10]mac-vlan mac-address 5400-0000-0001 //在vlan10中綁定主機A的MAC地址 Jun 9 2019 10:17:22-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 5, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-vlan10]mac-vlan mac-address 5400-0000-0002 //在vlan10中綁定主機B的MAC地址 Jun 9 2019 10:17:32-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 6, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-vlan10]mac-vlan mac-address 5400-0000-0003 //在vlan10中綁定主機C的MAC地址 Jun 9 2019 10:18:02-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 7, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-vlan10]int g0/0/1 [SWA-GigabitEthernet0/0/1]mac-vlan enable //開啓G0/0/1端口下MAC-VLAN Info: This operation may take a few seconds. Please wait for a moment...done. [SWA-GigabitEthernet0/0/1] Jun 9 2019 10:19:02-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 8, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/1]int g0/0/2 [SWA-GigabitEthernet0/0/2]mac-vlan enable //開啓G0/0/2端口下MAC-VLAN Info: This operation may take a few seconds. Please wait for a moment...done. [SWA-GigabitEthernet0/0/2] Jun 9 2019 10:19:32-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 9, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/2]int g0/0/3 [SWA-GigabitEthernet0/0/3]mac-vlan enable //開啓G0/0/3端口下MAC-VLAN Info: This operation may take a few seconds. Please wait for a moment...done. [SWA-GigabitEthernet0/0/3] Jun 9 2019 10:20:02-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 10, the change loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/3]q [SWA] [SWA]dis mac-vlan mac-address all //檢查vlan10中MAC地址綁定條目 --------------------------------------------------- MAC Address MASK VLAN Priority --------------------------------------------------- 5400-0000-0001 ffff-ffff-ffff 10 0 5400-0000-0002 ffff-ffff-ffff 10 0 5400-0000-0003 ffff-ffff-ffff 10 0 Total MAC VLAN address count: 3 [SWA]
3、基於子網地址劃分VLAN:this
[SWA]display vlan //流程同上,先檢查vlan和建立vlan10 --------- [SWA]vlan 10 --------- [SWA-vlan10]int g0/0/1 //再分別進入G0/0/一、二、3端口配置剝離vlan標籤的功能 [SWA-GigabitEthernet0/0/1]port hybrid untagged vlan 10 --------- [SWA-GigabitEthernet0/0/1]int g0/0/2 [SWA-GigabitEthernet0/0/2]port hybrid untagged vlan 10 --------- [SWA-GigabitEthernet0/0/2]int g0/0/3 [SWA-GigabitEthernet0/0/3]port hybrid untagged vlan 10 --------- [SWA-GigabitEthernet0/0/3]vlan 10 [SWA-vlan10] [SWA-vlan10]ip-subnet-vlan ? //根據子網信息綁定vlan INTEGER<1-12> Ip-subnet index,ranging from integer 1 to 12 ip IP address [SWA-vlan10]ip-subnet-vlan ip ? X.X.X.X IP address [SWA-vlan10]ip-subnet-vlan ip 192.168.0.1 ? INTEGER<0-32> Length of IP address mask X.X.X.X IP address mask [SWA-vlan10]ip-subnet-vlan ip 192.168.0.1 32 //在vlan10中綁定主機A的IP地址 Jun 9 2019 12:09:04-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 5, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-vlan10]ip-subnet-vlan ip 192.168.0.2 32 //在vlan10中綁定主機B的IP地址 Jun 9 2019 12:09:24-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 6, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-vlan10]ip-subnet-vlan ip 192.168.0.3 32 //在vlan10中綁定主機C的IP地址 Jun 9 2019 12:09:34-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 7, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-vlan10]dis this # vlan 10 ip-subnet-vlan 1 ip 192.168.0.1 255.255.255.255 ip-subnet-vlan 2 ip 192.168.0.2 255.255.255.255 ip-subnet-vlan 3 ip 192.168.0.3 255.255.255.255 # return [SWA-vlan10]int g0/0/1 [SWA-GigabitEthernet0/0/1]ip-subnet-vlan enable //開啓G0/0/1端口下ip-subnet-vlan [SWA-GigabitEthernet0/0/1] Jun 9 2019 12:10:34-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 8, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/1]int g0/0/2 [SWA-GigabitEthernet0/0/2]ip-subnet-vlan enable //開啓G0/0/2端口下ip-subnet-vlan [SWA-GigabitEthernet0/0/2] Jun 9 2019 12:10:54-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 9, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/2]int g0/0/3 [SWA-GigabitEthernet0/0/3]ip-subnet-vlan enable //開啓G0/0/3端口下ip-subnet-vlan [SWA-GigabitEthernet0/0/3] Jun 9 2019 12:11:14-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 10, the change loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/3]quit [SWA]dis ip-subnet-vlan vlan all //檢查vlan10中IP地址(子網)綁定條目 ---------------------------------------------------------------- Vlan Index IpAddress SubnetMask Priority ---------------------------------------------------------------- 10 1 192.168.0.1 255.255.255.255 0 10 2 192.168.0.2 255.255.255.255 0 10 3 192.168.0.3 255.255.255.255 0 ---------------------------------------------------------------- ip-subnet-vlan count: 3 total count: 3 [SWA]
4、基於協議劃分VLAN:spa
[SWA]display vlan //流程同上,先檢查vlan和建立vlan10
---------
[SWA]vlan 10
---------
[SWA-vlan10]int g0/0/1 //再分別進入G0/0/一、二、3端口配置剝離vlan標籤的功能
[SWA-GigabitEthernet0/0/1]port hybrid untagged vlan 10
---------
[SWA-GigabitEthernet0/0/1]int g0/0/2
[SWA-GigabitEthernet0/0/2]port hybrid untagged vlan 10
---------
[SWA-GigabitEthernet0/0/2]int g0/0/3
[SWA-GigabitEthernet0/0/3]port hybrid untagged vlan 10
---------
[SWA-GigabitEthernet0/0/3]vlan 10
[SWA-vlan10]protocol-vlan ? //根據指定協議劃分vlan(華爲支持多種二層、三層協議) INTEGER<0-15> Protocol index at AT(AppleTalk Protocol) configuration information ipv4 IPv4 configuration information ipv6 IPv6 configuration information ipx IPX(Internetwork Packet eXchange) configuration information mode Other protocol mode configuration information [SWA-vlan10]protocol-vlan ipv4 //配置根據IPv4協議劃分vlan [SWA-vlan10] Jun 9 2019 14:13:29-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 5, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-vlan10]int g0/0/1 [SWA-GigabitEthernet0/0/1]protocol-vlan vlan 10 all //開啓G0/0/1端口下protocol-vlan,關聯vlan10,並引用全部配置協議 Jun 9 2019 14:16:19-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 6, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/1]protocol-vlan vlan 10 ? INTEGER<0-15> Protocol index all All the protocols of the VLAN [SWA-GigabitEthernet0/0/1]int g0/0/2 [SWA-GigabitEthernet0/0/2]protocol-vlan vlan 10 all //開啓G0/0/2端口下protocol-vlan,關聯vlan10,並引用全部配置協議 [SWA-GigabitEthernet0/0/2] Jun 9 2019 14:17:29-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 7, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/2]int g0/0/3 [SWA-GigabitEthernet0/0/3]protocol-vlan vlan 10 all //開啓G0/0/3端口下protocol-vlan,關聯vlan10,並引用全部配置協議 [SWA-GigabitEthernet0/0/3] Jun 9 2019 14:18:09-08:00 SWA DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25 .191.3.1 configurations have been changed. The current change number is 8, the c hange loop count is 0, and the maximum number of records is 4095. [SWA-GigabitEthernet0/0/3]q [SWA] [SWA]dis protocol-vlan vlan all //查看vlan中綁定的協議 ---------------------------------------------------------------- VLAN Protocol Index Protocol Type ---------------------------------------------------------------- 10 0 ipv4