Switch#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Switch(vlan)# vlan 2 name marking
VLAN 2 added:
Name: marking
Switch(vlan)# vlan 3 name counting
VLAN 3 added:
Name: counting
2 分配端口
Switch(config)#interface FastEthernet0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 2
Switch(config-if)#exit
Switch(config)#interface FastEthernet0/2
Switch(config-if)#switchport access vlan 2
Switch(config-if)#interface FastEthernet0/3
Switch(config-if)#switchport access vlan 3
Switch(config-if)#interface FastEthernet0/4
Switch(config-if)#switchport access vlan 3
Switch(config-if)#exit
Switch(config)#exit
Switch#
3 Show vlan 查看信息
Switch#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active 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
2 marking active Fa0/1, Fa0/2
3 counting active Fa0/3, Fa0/4
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
2 enet 100002 1500 - - - - - 0 0
3 enet 100003 1500 - - - - - 0 0
1002 enet 101002 1500 - - - - - 0 0
1003 enet 101003 1500 - - - - - 0 0
其實(shí)做這個(gè)實(shí)驗(yàn)很簡單就是劃分子網(wǎng),主要是為了說明三層交換機(jī)最本質(zhì)工作原理,即一次路由,多次交換 結(jié)合arp的工作原理,兩臺(tái)主機(jī)通訊時(shí),傳統(tǒng)的2層交換機(jī)進(jìn)行arp廣播尋找目標(biāo)mac地址,,當(dāng)目的主機(jī)在同一網(wǎng)段內(nèi)時(shí),不需涉及網(wǎng)關(guān)。否則由網(wǎng)關(guān)回復(fù)arp廣播。
傳統(tǒng)的2層交換模塊不能實(shí)現(xiàn)網(wǎng)間互訪,而三層交互交換機(jī)的三層路由模塊把源和目的IP地址緩存交換機(jī)中,隨后第3層中跨子網(wǎng)的包傳送將不再由路由器來進(jìn)行。實(shí)驗(yàn)中的三層交換機(jī)充當(dāng)了傳統(tǒng)網(wǎng)絡(luò)中的路由器的角色,通過它可以實(shí)現(xiàn)網(wǎng)間互訪。