配置vlan 1:可以使用show vlan命令。查看vlan 步驟1 configure terminal 進入全局配置模式 步驟2 vlan vlan-id 輸入一個。如果輸入的是一個新的VLAN IDVLAN ,則交換機會創建一個,如果輸入的是已經存在的IDVLANVLAN ,則修改相應的。 步驟3 name vlan-name (可選)爲取一個名字。如果沒有進行這一步,則VLAN交換機會自動爲它起一個名字 ,其中是用開頭的四位號。比如,就是VLAN xxxxxxxx0VLAN IDVLAN 0004VLAN 的缺省名字。 步驟4 End 回到特權命令模式 步驟5 show vlan {id 檢查一下您剛纔的配置是否正確 步驟6 copy running-config startup config (可選)將配置保存進配置文件中 如果您想把VLAN的名字改回缺省名字,只需輸入no name命令即可。 下面是一個創建VLAN 888,將它命名爲test888,並且保存進配置文件的例子: Switch# configure terminal Switch(config)# vlan 888 Switch(config-vlan)# name test888 Switch(config-vlan)# end
刪除一個VLAN no vlan vlan-id 輸入一個VL,刪除它。 end 回到特權命令模式 show vlan 檢查一下是否正確刪除 copy running-config startup config (可選)將配置保存進配置文件
2:向VLAN分配Access口
步驟1 configure terminal 進入全局配置模式 步驟2 Interface interface-id 輸入想要加入的VLANinterface id 步驟3 switchport mode access 定義該接口的成員類型(二層口)VLANACCESS 步驟4 switchport access vlan vlan-id 將這個口分配給一個VLAN 步驟5 end 回到特權命令模式 步驟6 show interfaces 檢查接口的完整信息 步驟7 copy running-config startup config (可選)將配置保存進配置文件 下面這個例子把ethernet 0/10作爲access口加入了VLAN20: Switch# configure terminal Switch(config)# interface fastethernet0/10 Switch(config-if)# switchport mode access Switch(config-if)# switchport access vlan 20 Switch(config-if)# end 下面這個例子顯示瞭如何檢查配置是否正確: Switch# show interfaces fastethernet0/1 switchport Interface Switchport Mode Access Native Protected VLAN lists ---------- ---------- --------- --------- --------- --------- ----------- Fa0/1 Enabled Access 1 1 Enabled All 如果要把一個接口在ACCESS模式和TRUNK模式之間切換,請用 switchport mode命令: 將一個接口設置成爲模式access switchport mode access [vlan vlan-id] Switchport mode trunk 將一個接口設置成爲Trunk模式 作 爲Trunk,這個口要屬於一個native VLAN。所謂native VLAN,就是指在這個接口上收發的UNTAG報文,都被認爲是屬於這個VLAN的。顯然,這個接口的缺省VLAN ID(即IEEE 802.1Q中的PVID)就是native VLAN的VLAN ID。同時,在Trunk上發送屬於native VLAN的幀,則必然採用UNTAG的方式。Trunk口具體的行爲,請參見接口管理。 每個Trunk口的缺省native VLAN是VLAN 1。
Trunk口基本配置 在特權模式下,利用如下步驟可以將一個接口配置成一個Trunk口。 步驟1 configure terminal 進入全局配置模式 步驟2 interface interface-id 輸入想要配成口的Trunkinterface id 步驟3 switchport mode trunk 定義該接口的類型爲二層口Trunk 步驟4 switchport trunk native vlan vlan-id 爲這個口指定一個native VLAN 步驟5 end 回到特權命令模式 步驟6 show interfaces interface-id switchport 檢查接口的完整信息 步驟7 show interfaces interface-id trunk 顯示這個接口的設置trunk 步驟8 copy running-config startup config (可選)將配置保存進文件startup config
如果想把一個Trunk口的所有Trunk相關屬性都復位成缺省值,請使用no switchport trunk 接口配置命令。 定義Trunk口的許可VLAN列表 一個Trunk口缺省可以傳輸本交換機支持的所有VLAN(1-4093)的流量。但是,您也可以通過設置Trunk口的許可VLAN列表來限制某些VLAN的流量不能通過這個Trunk口。 在特權模式下,利用如下步驟可以修改一個Trunk口的許可VLAN列表。 步驟1 configure terminal 進入全局配置模式 步驟2 interface interface-id 輸入想要修改許可列表的口的VLANTrunkinterface id 步驟3 switchport mode trunk 定義該接口的類型爲二層口Trunk 步驟4 switchport trunk allowed vlan { all | [add | remove | except]} vlan-list (可選)配置這個口的許可列表。參數TrunkVLANvlan-list可以是一個V,也可以是一系列,以小的開頭,以大的LANVLANVLAN IDVLAN 結尾,中間用ID-號連接。如: 10–。20 的含義是許可列表包含所有支持的;allVLANVLAN 表示將指定列表加addVLAN入許可列表;VLAN 表示將指定列表從許可列表中刪除;removeVLANVLAN 表示將除列出的列表外的所有加入許可列表;exceptVLANVLANVLAN 您不能將從許可列表中移出。VLAN 1VLAN 步驟5 end 回到特權命令模式 步驟6 show interfaces interface-id switchport 檢查接口的完整信息 步驟7 copy running-config startup config (可選)將配置保存進配置文件 如果想把Trunk的許可VLAN列表改爲缺省的許可所有VLAN的狀態,請使用no switchport trunk allowed vlan接口配置命令。 下面是一個把從端口中移出的例子:VLAN 2 0/15 Switch(config)# interface fastethernet0/15 Switch(config-if)# switchport trunk allowed vlan remove 2 Switch(config-if)# end Switch# show interfaces fastethernet0/15 switchport Interface Switchport Mode Access Native Protected VLAN lists --------- ---------- --------- --------- --------- --------- ----------- Fa0/15 Enabled Trunk 1 1 Enabled 1,3-4093 配置Native VLAN 一個Trunk口能夠收發TAG或者UNTAG的802.1Q幀。其中UNTAG幀用來傳輸Native VLAN的流量。缺省的Native VLAN是VLAN 1。 在特權模式下,利用如下步驟可以爲一個Trunk口配置Native VLAN。 步驟1 configure terminal 進入全局配置模式 步驟2 interface interface-id 輸入配置Native 的口的VLANTrunkinterface id 步驟3 switchport trunk native vlan vlan-id 配置Native VLAN 步驟4 end 回到特權命令模式 步驟5 show interfaces interface-id switchport 驗證配置 步驟6 copy running-config startup config (可選)將配置保存進配置文件 如果想把Trunk的Native VLAN列表改回缺省的VLAN 1,請使用no switchport trunk native vlan接口配置命令。 如果一個幀帶有Native VLAN的VLAN ID,在通過這個Trunk口轉發時,會自動被剝去TAG。 當把一個接口的native VLAN設置爲一個不存在的VLAN時,交換機不會自動創建此VLAN。此外,一個接口的native VLAN可以不在接口的許可VLAN列表中。此時,native VLAN的流量不能通過該接口。 顯示VLAN 在特權模式下,纔可以查看VLAN的信息。顯示的信息包括VLAN vid、VLAN狀態、VLAN成員端口以及VLAN配置信息。以下羅列了相關的顯示命令: 命令 show vlan[id vlan-id] 在特權模式下,可以按照下列步驟配置網絡接口的IP: 步驟1 configure terminal 進入全局配置模式。 步驟2 interface interface_id 進入網絡接口配置模式,並指定要配置的三層網絡接口 步驟3 no switchport 去除接口的二層屬性(僅對物理接口或二層AL有效) 步驟4 ip address ip-address address_mask ip address 172.168.1.1 255.255.255.0 [secondary] 配置IP地址和子網掩碼,每個網絡接口可以配置多個IP,通過參數secondary來配置從屬IP地址。 步驟5 no shutdown 啓用這個網絡接口 步驟6 end 退回到特權模式。 步驟7 show interfaces [interface-id] show ip interface [interface-id] show running-config 察看網絡接口的設置結果。 步驟8 copy running-config startup-config 保存配置。 如果要刪除某個網絡接口的IP地址,使用接口配置命令 no ip address。 配置VLAN 進入VLAN模式 swl#vlan database 配置VTP域名 swl(vlan)#vtp domain cctv.com 配置vtp工作模式 swl(vlan)#vtp server 配置VTP密碼 swl(vlan)#vtp password cisco 配置VTP修剪 模擬器不能配置 swl(vlan)#vtp pruning 配置Trunk鏈路 swl(config)#int fa0/1 swl(config-if)#switchport mode trunk 創建VLAN 10 20 都是VLAN的編號 swl(vlan)#vlan 10 name googchengbu swl(vlan)#vlan 20 name caiwubu |