1. 清除VLAN配置

S1#erase starting-config
S1#delete flash:vlan.dat //把 VLAN 数据删除
S1#reload //重新加载

2. 在全局配置模式中创建 VLAN并命名

S1(config)#vlan 2
S1(config-vlan)#name VLAN2
S1(config-vlan)#exit
S1(config)#vlan 3
S1(config-vlan)#name VLAN3

3. 把端口划分在 VLAN 中

S1(config)#interface f0/1
S1(config-if)#switch mode access //以上把交换机端口的模式改为 access 模式,说明该端口是用于连接计算机的,而不是用
于 trunk
S1(config-if)#switch access vlan 2 //然后把该端口 f0/1 划分到 VLAN 2 中

4. 删除VLAN

no vlan 2 //在交换上,VLAN1是默认VLAN,不能删除,也不能改名。此外还有1002、1003等VLAN的存在

5. 查看 VLAN

show vlan
show vlan brief

6. 配置Trunk

S1(config)#int f0/13
S1(config-if)#switchport trunk encanpsulation dot1q //以上是配置 trunk 链路的封装类型,同一链路的两端封装要相同。有的交换机,例如 2950只能封装 dot1q,因此无需执行该命令。
S1(config-if)#switch mode trunk //以上是把接口配置为 trunk

7. 检查 trunk 链路的状态,测试跨交换机、同一 VLAN 主机间的通信

Switch#show interface f0/13 trunk
Switch#show interface f0/0 switchport //不一定是中继链路

8. 配置 Native VLAN

S1(config)#int f0/13
S1(config-if)#switchport trunk native vlan 2 //以上是在 Trunk 链路上配置 Native VLAN,我们把它改为 VLAN 2 了,默认是 VLAN 1

9. DTP 配置

(1)配置 Trunk 链路上的封装类型,可以是双方协商确定,也可以是指定的 isl 或者 dot1q
switchport trunk encapsulation { negotiate | isl | dot1q }
(2)Trunk 链路上不发送协商包,默认是发送的
switchport nonegotiate
(3)把接口配置为negotiate
S1(config-if)#switchport trunk encapsulation { isl | dot1q }
S1(config-if)#switchport mode trunk
S1(config-if)#no switchport negotiate
(4)把接口配置为nonegotiate
S1(config-if)#switchport trunk encapsulation { isl | dot1q }
S1(config-if)#switchport mode trunk
S1(config-if)#switchport nonegotiate
(5)把接口配置为desirable
S1(config-if)#switchport mode dynamic desirable
S1(config-if)#switchport trunk encapsulation { negotiate | isl | dot1q }
(6)把接口配置为auto
S1(config-if)#switchport mode dynamic auto
S1(config-if)#switchport trunk encapsulation { negotiate | isl | dot1q }

10. 配置 S1 为 VTP server

S1(config)#vtp mode server
配置 S2 为 VTP client
S2(config)#vtp mode client
配置 S3 为 VTP transparent
S3(config)#vtp mode transparent

11. 配置 VTP 域名

S1(config)#vtp domain VTP-TEST

12. 配置 VTP 的密码

S1(config)#vtp password cisco

13. 查看 VTP 信息

S1#show vtp status
信息如下:
VTP Version : 2 //该 VTP 支持版本 2
Configuration Revision : 2 //修订号为 2,该数值非常重要
Maximum VLANs supported locally : 1005
Number of existing VLANs : 7 //VLAN 数量
VTP Operating Mode : Server //VTP 模式
VTP Domain Name : VTP-TEST //VTP 域名
VTP Pruning Mode : Disabled //VTP 修剪没有启用
VTP V2 Mode : Disabled //VTP 版本 2 没有启用,现在是版本 1
VTP Traps Generation : Disabled
MD5 digest : 0xD4 0x30 0xE7 0xB7 0xDC 0xDF 0x1B 0xD8
Configuration last modified by 0.0.0.0 at 3-1-93 00:22:16
Local updater ID is 0.0.0.0 (no valid interface found)

14. VTP配置修剪

S1(config)#vtp pruning //VTP 修剪是为了防止不必要的流量从 trunk 链路上通过,通常需要启用

15. VTP配置版本 2

S1(config)#vtp version 2

16. 手动配置EtherChannel

S1 (config)#interface port-channel 1 //以上是创建以太通道,要指定一个唯一的通道组号,组号的范围是1~6的正整数

17. 取消EtherChannel

no interface port-channel 1

18. 将物理接口指定到已创建的EtherChannel通道中

S1(config)#interface f0/13
S1(config-if)#channel-group 1 mode on

19. 配置EtherChannel通道中的物理接口的属性

S1(config)#int port-channel 1
S1(config-if)#switchport mode trunk
S1(config-if)#speed 100
S1(config-if)#duplex full

20. 配置EtherChannel的负载平衡方式

S1(config)# port-channel load-balance dst-ip
S2(config)# port-channel load-balance dst-mac
S1(config)# port-channel load-balance src-dst-ip
S2(config)# port-channel load-balance src-dst-mac

21. 查看etherchannel信息

S1#show etherchannel summary

22. 配置 PAGP 或者 LAGP

把接口配置为 PAGP 的 desirable 模式
channel-group 1 mode desirable
把接口配置为 PAGP 的 auto 模式
channel-group 1 mode auto
把接口配置为 LACP 的 active 模式
channel-group 1 mode active
把接口配置为 LACP 的 passive 模式
channel-group 1 mode passive

23.接入链路和中继链路

接入S1(config-if)#switch mode access
接入链路只是VLAN的成员。连接到这个端口上的设备完全不知道存在VLAN这个东西,主机与交换机之间连接的链路就是接入链路。设备只是根据配置在该设备上的第3层信息,认为它是网络或子网的一个部分。接入链路是属于一个并且只属于一个VLAN的端口。这个端口不能从另外一个VLAN接收或发送信息,除非该信息经过了路由。

中继S1(config-if)#switch mode trunk
中继链路可以承载多个VLAN

24.创建子接口并定义封装类型

R1(config)#int g0/0
R1(config-if)#no shutdown
R1(config)#int g0/0.1
//本征vlan
R1(config-subif)#encapture dot1q 1 native
//不是本征vlan
R1(config-subif)#encapture dot1q 1
//以上是定义该子接口承载哪个 VLAN 流量,由于交换机上的 native vlan 是 VLAN 1,所以
我们这里也要指明该 VLAN 就是 native vlan。实际上默认时 native vlan 就是 vlan 1。
R1 (config-subif)#ip address 172.16.1.254 255.255.255.0
//在子接口上配置 IP 地址,这个地址就是 VLAN 1 的网关了

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐