main name
password Set VTP password
pruning VTP pruning
server VTP server
transparent VTP transparent
trap VTP trap
1900(config)#vtp server
1900(config)#vtp domain noco
1900(config)#vtp password noko
在特权模式下使用show vtp命令验证,如下:
1900#sh vtp
VTP version: 1
Configuration revision: 0
Maximum VLANs supported locally: 1005
Number of existing VLANs: 5
VTP domain name: noco
VTP password: noko
VTP operating mode: Server
(
)
2950
如下:
2950(config)#vtp mode server
2950(config)#vtp domain noco
验证信息,如下:
2950#sh vtp ?
counters VTP statistics
status VTP domain status
2950#sh vtp status
(
)

Configuring Switching in Our Sample Internetwork

配置实例:先配置2950C,如下
2950C(config)#enable secret noko
2950C(config)#line con 0
2950C(config-line)#login
2950C(config-line)#password noco
2950C(config-line)#line vty 0 15
2950C(config-line)#login
2950C(config-line)#password noco
2950C(config-line)#banner motd #
2950C
#
2950C(config-line)#exit
2950C(config)#int vlan1
2950C(config-if)#ip address 172.16.10.2 255.255.255.0
2950C(config-if)#no shut
2950C(config-if)#exit
2950C(config)#up default-gateway 172.16.10.1
2950C(config)#^Z
2950C#copy run start
配置2950B,如下:
2950B(config)#enable secret noko
2950B(config)#line con 0
2950B(config-line)#login
2950B(config-line)#password noco
2950B(config-line)#line vty 0 15
2950B(config-line)#login
2950B(config-line)#password noco
2950B(config-line)#banner motd #
2950B
#
2950B(config-line)#exit
2950B(config)#int vlan1
2950B(config-if)#ip address 172.16.10.3 255.255.255.0
2950B(config-if)#no shut
2950B(config-if)#exit
2950B(config)#up default-gateway 172.16.10.1
2950B(config)#^Z
2950B#copy run start
配置trunk,2950B如下:
2950B(config)#int f0/1
2950B(config-if)#switchport mode trunk
2950B(config-if)#int f0/4
2950B(config-if)#switchport mode trunk
2950B(config-if)#int f0/5
2950B(confgi-if)#switchport mode trunk
配置trunk,2950C如下:
2950C(config)#int f0/4
2950C(confgi-if)#switchport mode trunk
2950C(config-if)#int f0/5
2950C(config-if)#switchport mode trunk
验证trunk信息,使用show interface trunk命令.如下:
2950B#sh int trunk
Port Mode Encapsulation Status Native vlan
Fa0/1 on 802.1q trunking 1
Fa0/4 on 802.1q trunking 1
Fa0/5 on 802.1q trunking 1
(
)
之前我们已经对2950B2950C做了基本配置和trunk端口的配置,接下来应该设置VTP和创建VLAN,并且进行验证.2950C如下:
2950C(config)#vtp mode server
2950C(config)#vtp domain Cisco
2950C(config)#^Z
2950C#vlan database
2950C(vlan)#vlan 2 name sales
2950C(vlan)#vlan 3 name marketing
2950C(vlan)#apply
2950C(vlan)#^C
2950C#sh vlan brief
(
)
接下来分配端口,Fa0/2分配给VLAN2,Fa0/3分配给VLAN3,默认所有的端口都处在V
LAN1,配置如下:
2950C(config)#int fa0/2
2950C(config-if)#switchport access vlan2
2950C(config)#int fa0/3
2950C(config-if)#switchport access vlan3
验证信息,注意VLAN1里的Ports,如下:
2950C#sh vlan brief
VLAN Name Status Ports
----------------------------------------------------------------------------
1 default active Fa0/1 Fa0/5...Fa0/10
2 sales active Fa0/2
3 marketing active Fa0/3
配置2950B,把它设置成客户模式,2950B2950C接收VLAN信息,如下:
2950B(config)#vtp mode client
2950B(config)#vtp domain Cisco
2950B(config)#^Z
验证,注意2950B已经从2950C知道了VLAN的信息,如下:
2950B#sh vlan brief
VLAN Name Status Ports
----------------------------------------------------------------------------
1 default active Fa0/1...Fa0/12
2 sales active
3 marketing active
但是仍然要给2950B分配端口,如下:
2950B(config)#int fa0/2
2950B(config-if)#switchport access vlan2
2950B(config)#int fa0/3
2950B(config-if)#switchport access vlan3
验证信息,如下:
VLAN Name Status Ports
----------------------------------------------------------------------------
1 default active Fa0/1 Fa0/5...Fa0/12
2 sales active Fa0/2
3 marketing active Fa0/3
到现在,2950C2950B的配置就算是完成了,经过验证,我们也没发现什么问题,接下来该配置什么呢?当然是配置VLAN间的通信,根据上面的拓扑图,可以知道需要在RouterB上进行配置,如下:
RouterB(config)#hostname Trunkrouter
Trunkrouter(config)#int f0/0
Trunkrouter(config-if)#no ip address
Trunkrouter(config-if)#no shut
创建子接口,并定义封装类型,如下:
Trunkrouter(config-if)#int f0/0.1
Trunkrouter(config-subif)#encapsulation dot1q 1
Trunkrouter(config-subif)#ip address 172.16.10.1 255.255.255.0
Trunkrouter(config-if)#int f0/0.2
Trunkrouter(config-subif)#encapsulation dot1q 2
Trunkrouter(config-subif)#ip address 172.16.20.1 255.255.255.0
Trunkrouter(config-if)#int f0/0.3
Trunkrouter(config-subif)#encapsulation dot1q 3
Trunkrouter(config-subif)#ip address 172.16.30.1 255.255.255.0
Trunkrouter(config-if)#exit
创建子接口,每个接口对应1VLAN.注意,如果你试图在第一个子接口分配IP地址,将收到错误信息,除非你先定义了封装类型,如下:
Trunkrouter(config-if)#int f0/0.1
Trunkrouter(config-subif)#ip address 172.16.10.1 255.255.255.0
Configuring IP routing on a LAN subinterface is only allowed if that subinterface is already configured as part of an IEEE 802.10, IEEE 802.1Q, or ISL VLAN.
验证配置信息,如下:
Trunkrouter#sh run