配置VTP
所有的交換機,在默認時(shí)都配置為VTP服務(wù)器。要配置VTP,首先必須配置你想要使用的VTP域名。在創(chuàng )建VTP域時(shí),有一些選項,包括設置域名、口令、操作模式和交換機的修建功能?墒褂肰TP全局配置模式命令來(lái)設置所有這些信息。在下面的列茲中,我將交換機設置為VTP server,將VTP域名設置為Cisco,將VTP口令設置為12345:
- 1900(config)#vtp server
- 1900(config)#vtp domain Cisco
- 1900(config)#vtp password 12345
默認時(shí)所有的交換機都設置為VTP服務(wù)器模式,如果想在交換機上改動(dòng)任何有關(guān)VLAN的信息,都必須在VTP服務(wù)器模式下進(jìn)行。
在2950交換機上配置VTP,同樣要首先配置想要使用的域名。同樣,一旦在交換機上配置了VTP信息,就需要驗證它?墒褂肰TP全局配置模式命令來(lái)設置這些信息。例子中,把交換機設置為服務(wù)器模式,域名設置為SZ_Lab
- Switch(config)#vtp mode server
- Switch(config)#vtp domain SZ_Lab
配置示例互聯(lián)網(wǎng)絡(luò )中的交換
先配置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
- (略)
之前我們已經(jīng)對2950B和2950C做了基本配置和trunk端口的配置,接下來(lái)應該設置VTP和創(chuàng )建VLAN,并且進(jìn)行驗證.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
- (略)
接下來(lái)分配端口,把Fa0/2分配給VLAN2,Fa0/3分配給VLAN3,默認所有的端口都處在VLAN1下,配置如下:
- 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,把它設置成客戶(hù)模式,2950B從2950C接收VLAN信息,如下:
- 2950B(config)#vtp mode client
- 2950B(config)#vtp domain Cisco
- 2950B(config)#^Z
驗證,注意2950B已經(jīng)從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
到現在,2950C和2950B的配置就算是完成了,經(jīng)過(guò)驗證,我們也沒(méi)發(fā)現什么問(wèn)題,接下來(lái)該配置什么呢?當然是配置VLAN間的通信,根據上面的拓撲圖,可以知道需要在RouterB上進(jìn)行配置,如下:
- RouterB(config)#hostname Trunkrouter
- Trunkrouter(config)#int f0/0
- Trunkrouter(config-if)#no ip address
- Trunkrouter(config-if)#no shut
創(chuàng )建子接口,并定義封裝類(lèi)型,如下:
- 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
創(chuàng )建子接口,每個(gè)接口對應1個(gè)VLAN.注意,如果你試圖在第一個(gè)子接口分配IP地址,將收到錯誤信息,除非你先定義了封裝類(lèi)型,如下:
- 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.