简单理解 VTP 协议与实战单臂路由

前言:我是谁,我在哪,我干嘛要学计算机网络?

简介 VTP

VTP 的三种模式

VTP:VLAN Trunking Protocol

一个思科私有的 VLAN TRUNK 协议,通过一个共有的管理域,维持 VLAN 配置信息的一致性;

简单来说在 VTP 里面一共有三种模式:Server Mode、Client Mode、Transparent Mode

  • 服务器模式 Server Mode

我们可以在 VTP 服务器模式的交换机中创建,添加或删除 VTP 域的VLAN,并在 VTP 服务器中更改 VLAN 信息。服务器模式中的交换机所做的更改将通告给整个 VTP 域

  • 客户端模式 Client Mode

客户端模式交换机侦听来自其他交换机的 VTP 通告,并相应地修改其VLAN 配置。客户端交换机需要在服务端的通知下更改 VLAN。我们无法在 VTP 客户端中创建,添加或删除 VLAN。

  • 透明模式 Transparent Mode

透明模式的交换机不参与 VTP 域,透明模式的交换机可以通过 Trunk 接收和转发 VTP 通告

VTP 机制

  • VTP 协议通过组播地址 01-00-0C-CC-CC-CC 在 Trunk 链路上发送 VTP 通告;
  • VTP Server 和 clients 通过最高的修订号来同步数据库;
  • VTP 协议每隔 5 分钟发送一次 VTP 通告或者有变化时发生;

VTP 还有另外一个机制:Pruning(修剪)

作用是减少不必要的泛洪流量(例如广播,多播和单播数据包)来增强网络带宽使用,简而言之就是切掉这一块的泛洪

要使 VTP Pruning 生效,管理域中的所有设备都必须支持 VTP Pruning,或者在不支持 Pruning 的设备上,必须手动配置 Trunk 上允许的 VLAN

VTP 配置

Switch# configure terminal
Switch(config)# vtp mode [ server | client | transparent ]
Switch(config)# vtp domain domain-name 
Switch(config)# vtp password password
Switch(config)# vtp pruning



Switch(config)# vtp domain ICND
Changing VTP domain name to ICND
Switch(config)# vtp mode transparent
Setting device to VTP TRANSPARENT mode.
Switch(config)# end

Switch#show vtp status

实战——单臂路由

要求
实操

搭建环境

  • 配置所有 PC 地址
VPCS> ip 192.168.10.1/24 192.168.10.254

VPCS> ip 192.168.10.2/24 192.168.10.254

VPCS> ip 192.168.20.1/24 192.168.20.254
  • 配置路由器
R1(config)#int e0/0.1 
R1(config-subif)#encapsulation dot1q 10
R1(config-subif)#ip add 192.168.10.254 255.255.255.0 
R1(config-subif)#no shutdown

R1(config)#int e0/0.2 
R1(config-subif)#encapsulation dot1q 20
R1(config-subif)#ip add 192.168.20.254 255.255.255.0 
R1(config-subif)#no shutdown

开始配置单臂路由

  • 配置 s4 VLAN and Trunk

PC 端口的 vlan

s4(config)#vlan 10
s4(config)#int e0/0
s4(config-if)#switchport mode access 
s4(config-if)#switchport access vlan 10

配置 trunk

s4(config)#interface e0/1
s4(config-if)#switchport trunk encapsulation dot1q
s4(config-if)#switchport mode trunk
s4(config-if)#switchport nonegotiate

看结果

s4#show vlan br

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Et0/2, Et0/3
10   vlan10                           active    Et0/0
1002 fddi-default                     act/unsup 
1003 token-ring-default               act/unsup 
1004 fddinet-default                  act/unsup 
1005 trnet-default                    act/unsup 
  • 配置 s5 VLAN and Trunk

s5 有 4 个接口:

先配两个 trunk

s4(config)#interface e0/0
s4(config-if)#switchport trunk encapsulation dot1q
s4(config-if)#switchport mode trunk
s4(config-if)#switchport nonegotiate



s4(config)#interface e0/3
s4(config-if)#switchport trunk encapsulation dot1q
s4(config-if)#switchport mode trunk
s4(config-if)#switchport nonegotiate

再配两个 vlan

s4(config)#vlan 10
s4(config)#int e0/2
s4(config-if)#switchport mode access 
s4(config-if)#switchport access vlan 10

s4(config)#vlan 20
s4(config)#int e0/1
s4(config-if)#switchport mode access 
s4(config-if)#switchport access vlan 20

看结果

Switch#show vlan brief 

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    
10   VLAN0010                         active    Et0/2
20   VLAN0020                         active    Et0/1
1002 fddi-default                     act/unsup 
1003 token-ring-default               act/unsup 
1004 fddinet-default                  act/unsup 
1005 trnet-default                    act/unsup

最后 pc1 ping 通 pc2 和 pc3

VPCS> ping 192.168.10.2

84 bytes from 192.168.10.2 icmp_seq=1 ttl=64 time=2.875 ms
84 bytes from 192.168.10.2 icmp_seq=2 ttl=64 time=2.331 ms
84 bytes from 192.168.10.2 icmp_seq=3 ttl=64 time=2.510 ms
84 bytes from 192.168.10.2 icmp_seq=4 ttl=64 time=2.869 ms
84 bytes from 192.168.10.2 icmp_seq=5 ttl=64 time=2.041 ms



VPCS> ping 192.168.20.1

84 bytes from 192.168.20.1 icmp_seq=1 ttl=63 time=7.648 ms
84 bytes from 192.168.20.1 icmp_seq=2 ttl=63 time=4.272 ms
84 bytes from 192.168.20.1 icmp_seq=3 ttl=63 time=3.720 ms
84 bytes from 192.168.20.1 icmp_seq=4 ttl=63 time=4.064 ms
84 bytes from 192.168.20.1 icmp_seq=5 ttl=63 time=3.524 ms

单臂路由配置结束!

完结撒花!

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容