学会VLAN的基础配置一、实验目的1、掌握VLAN的配置2、掌握Access 接口和Trunk接口的配置3、掌握将接口与VLAN关联的配置二、实验拓扑PC1与PC3属于默认的vlan1PC2与PC4属于vlan2交换机之间的接口E0/0/3配置为trunk链路三、实验步骤1、VLAN口与Access接口的配置LSW1:<Huawei>syEnter system view, return user view with Ctrl+Z.[Huawei]sysname LSW1[LSW1]info-center source DS channel 0 log state off trap state off[LSW1]user-interface console 0[LSW1-ui-console0]idle-timeout 0 0[LSW1-ui-console0]q[LSW1]vlan 2 //添加一个vlan2[LSW1-vlan2]q[LSW1]int e0/0/2 //进入2接口[LSW1-Ethernet0/0/2]port link-type access //端口的链路类型为Access(连接计算机的端口),华为的设置默认接口是hybrid的模式[LSW1-Ethernet0/0/2]port default vlan 2 //将这个接口加入到vlan2中[LSW1-Ethernet0/0/2]qLSW2:<Huawei>syEnter system view, return user view with Ctrl+Z.[Huawei]sysname LSW2[LSW2]info-center source DS channel 0 log state off trap state off[LSW2]user-interface console 0[LSW2-ui-console0]idle-timeout 0 0[LSW2-ui-console0]q[LSW2]vlan 2 //添加一个vlan2[LSW2-vlan2]int e0/0/2[LSW2-Ethernet0/0/2]port link-type access //端口的链路类型为Access [LSW2-Ethernet0/0/2]port default vlan 2 //将这个接口加入到vlan2中[LSW2-Ethernet0/0/2]q在各交换机上用dis vlan这个命令来查看上面的e0/0/2接口是否已经加入到vlan2中[LSW1]dis vlanThe 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:Eth0/0/1(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)2 common UT:Eth0/0/2(U) //已经属于vlan2了VID Status Property MAC-LRN Statistics Description--------------------------------------------------------------------------------1 enable default enable disable VLAN 00012 enable default enable disable VLAN 0002[LSW2]dis vlanThe 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:Eth0/0/1(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)2 common UT:Eth0/0/2(U) //已经属于vlan2了VID Status Property MAC-LRN Statistics Description--------------------------------------------------------------------------------1 enable default enable disable VLAN 00012 enable default enable disable VLAN 00022、Trunk接口的配置◇1上面的拓扑图和配置命令来看,交换机之间的e0/0/3接口默认是属于vlan1的,因此只能是PC1与PC3这两台主机是可以拼通的,要想实现PC2与PC4之间的互通,则需要将交换机之间相连的接口配置为trunk,命令如下:[LSW1]int e0/0/3 //进接口[LSW1-Ethernet0/0/3]port link-type trunk //接口链路类型为trunk [LSW1-Ethernet0/0/3]port trunk allow-pass vlan all //允许所有的vlan通过,华为的设备默认是不允许任何vlan通过的,除了缺省的vlan1[LSW2]int e0/0/3 //进接口[LSW2-Ethernet0/0/3]port link-type trunk //接口链路类型为trunk [LSW2-Ethernet0/0/3]port trunk allow-pass vlan all /允许所有的vlan通过◇2在各交换机上查看vlan的信息[LSW1]dis vlanThe 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:Eth0/0/1(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)2 common UT:Eth0/0/2(U)TG:Eth0/0/3(U)VID Status Property MAC-LRN Statistics Description--------------------------------------------------------------------------------1 enable default enable disable VLAN 00012 enable default enable disable VLAN 0002[LSW2]dis vlanThe 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:Eth0/0/1(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)2 common UT:Eth0/0/2(U)TG:Eth0/0/3(U)VID Status Property MAC-LRN Statistics Description--------------------------------------------------------------------------------1 enable default enable disable VLAN 00012 enable default enable disable VLAN 00023、接口与VLAN关联的配置◇1当交换机需要与网络层的设备通信时,可以在交换机上创建基于VLAN的逻辑接口,即VLANIF接口。