思科單臂路由與VTP綜合配置
阿新 • • 發佈:2018-11-08
拓撲圖:
一、配置交換機vtp
SW1:
SW1>enable SW1#config t Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#hostname SW1 SW1(config)#vlan 10 SW1(config-vlan)#exit SW1(config)#vlan 20 SW1(config-vlan)#exit SW1(config)#vtp mode server //配置sw1為伺服器端 Device mode already VTP SERVER. SW1(config)#vtp domain cisco //配置vtp 的域名為Cisco Domain name already set to cisco. SW1(config)#vtp password cisco123 //配置密碼 Password already set to cisco123 SW1(config)#service password-encryption //明文密碼加密 SW1(config)#interface f0/1 SW1(config-if)#switchport mode trunk //配置兩交換機間鏈路模式為trunk SW1(config-if)#switchport trunk allowed vlan all SW1(config-if)#no shutdown SW1(config-if)#exit SW1(config)#interface f0/2 SW1(config-if)#switchport mode access SW1(config-if)#switchport access vlan 10 SW1(config-if)#no shutdown SW1(config-if)#exit SW1(config)#interface f0/3 SW1(config-if)#switchport mode trunk //配置路由器與交換機相連鏈路為trunk SW1(config-if)#switchport trunk allowed vlan all SW1(config-if)#no shutdown SW1(config-if)#exit SW1(config)#
sw2:
SW2>enable SW2#config t Enter configuration commands, one per line. End with CNTL/Z. SW2(config)#hostname SW2 SW2(config)#vtp mode client Device mode already VTP CLIENT. SW2(config)#vtp domain cisco //配置sw2為vtp客戶端模式 Domain name already set to cisco. SW2(config)#vtp password cisco123 //配置密碼 Password already set to cisco123 SW2(config)#service password-encryption //明文密碼加密 SW2(config)#interface f0/1 SW2(config-if)#switchport mode trunk SW2(config-if)#switchport trunk allowed vlan all SW2(config-if)#no shutdown SW2(config-if)#exit SW2(config)#interface f0/2 SW2(config-if)#switchport mode access SW2(config-if)#switchport access vlan 20 SW2(config-if)#no shutdown SW2(config-if)#exit SW2(config)#
二、在SW2上檢視,是否學習到相應的VLAN
SW2(config)#do show vlan VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/3, Fa0/4, Fa0/5, Fa0/6 Fa0/7, Fa0/8, Fa0/9, Fa0/10 Fa0/11, Fa0/12, Fa0/13, Fa0/14 Fa0/15, Fa0/16, Fa0/17, Fa0/18 Fa0/19, Fa0/20, Fa0/21, Fa0/22 Fa0/23, Fa0/24, Gig1/1, Gig1/2 10 VLAN0010 active 20 VLAN0020 active Fa0/2 1002 fddi-default act/unsup 1003 token-ring-default act/unsup 1004 fddinet-default act/unsup 1005 trnet-default act/unsup VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ 1 enet 100001 1500 - - - - - 0 0 10 enet 100010 1500 - - - - - 0 0 20 enet 100020 1500 - - - - - 0 0 1002 fddi 101002 1500 - - - - - 0 0 1003 tr 101003 1500 - - - - - 0 0 1004 fdnet 101004 1500 - - - ieee - 0 0 1005 trnet 101005 1500 - - - ibm - 0 0 Remote SPAN VLANs ------------------------------------------------------------------------------ Primary Secondary Type Ports ------- --------- ----------------- ------------------------------------------ SW2(config)#
由檢視結果可知,SW2交換機已從SW1交換機學習到了VLAN 10和VLAN 20。
三、配置路由器子介面
AR1:
AR1>enable
AR1#config t
Enter configuration commands, one per line. End with CNTL/Z.
AR1(config)#hostname AR1
AR1(config)#interface g0/0 //進入物理介面
AR1(config-if)#no shutdown //啟用該介面
AR1(config-if)#interface g0/0.10 //進入子介面
AR1(config-subif)#encapsulation dot1q 10 // 將子介面封裝到VLAN 10中
AR1(config-subif)#ip address 192.168.10.254 255.255.255.0
//配置IP地址
AR1(config-subif)#no shutdown //啟用子介面
AR1(config-subif)#exit
AR1(config)#interface g0/0.20
AR1(config-subif)#encapsulation dot1q 20 //將子介面封裝到VLAN 20中
AR1(config-subif)#ip address 192.168.20.254 255.255.255.0
AR1(config-subif)#no shutdown
AR1(config-subif)#exit
AR1(config)#
四、電腦終端ip地址配置
PC1:
192.168.10.1
255.255.255.0
192.168.10.254
PC2:
192.168.20.1
255.255.255.0
192.168.20.254
五、測試
PC1 ping PC2
PC2 ping PC1