SW1(config)#int f0/1
SW1(config-if)#switchport trunk encapsulation dot1q
^
% Invalid input detected at '^' marker. (发现此
IOS不支持此命令)
SW1#sh int f0/1 switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: dynamic auto
Operational Mode: static access
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: native
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk encapsulation: dot1q (发现默认就封装成
dot1q)
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk private VLANs: none
Operational private-vlan: none
Trunking VLANs Enabled: ALL
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL
Protected: false
Appliance trust: none
SW1#
|
SW1(config)#int f0/1
SW1(config-if)#switchport mode trunk (在
SW1上指定端口为
trunk模式)
SW2(config)#int f0/2
SW2(config-if)#switchport mode trunk (在
SW2上指定端口为
trunk模式)
|
SW2(config-if)#do sh int trunk
Port Mode Encapsulation Status Native vlan
Fa0/2 on 802.1q trunking 1 (缺省
VLAN被称为
Native Vlan)
Port Vlans allowed on trunk
Fa0/2 1-1005 (允许在
trunk上传输数据的
VLAN列表
)
Port Vlans allowed and active in management domain
Fa0/2 1
Port Vlans in spanning tree forwarding state and not pruned
Fa0/2 1
|
SW2#sh vtp status
VTP Version : 2 (
VTP协议的版本号为
2,增加了支持令牌环交换和令牌环
VLAN)
Configuration Revision : 0 (配置的版本号,每变更一次将会增加
1,为
0说明没有配置)
Maximum VLANs supported locally : 255
Number of existing VLANs : 5
VTP Operating Mode : Server (默认情况下所有交换机都为
VTP server 模式)
VTP Domain Name :
VTP Pruning Mode : Disabled (VTP修剪默认关闭的
)
VTP V2 Mode : Disabled
VTP Traps Generation : Disabled
MD5 digest : 0x7D 0x5A 0xA6 0x0E 0x9A 0x72 0xA0 0x3A (VTP的密码
)
Configuration last modified by 0.0.0.0 at 0-0-00 00:00:00
Local updater ID is 0.0.0.0 (no valid interface found)
|
SW1#vlan database
SW1(vlan)#vtp domain wxs (配置
VTP的域名为
wxs )
SW1(vlan)#vtp server (定义
VTP的模式为
client)
SW1(vlan)#vtp password cisco (为了
vtp的安全,配置
VTP的密码为
cisco)
SW2(config)#vtp domain wxs
SW2(config)#vtp mode client
SW2(config)#vtp password cisco
|
SW2#sh vtp status
VTP Version : 2
Configuration Revision : 0 (
因为没有对VLAN进行操作,故还为0)
Maximum VLANs supported locally : 255
Number of existing VLANs : 5
VTP Operating Mode : Client (VTP的操作模式从默认的
server变成
client)
VTP Domain Name : wxs (VTP域名为
wxs)
VTP Pruning Mode : Disabled
VTP V2 Mode : Disabled
VTP Traps Generation : Disabled
MD5 digest : 0x37 0x56 0xD3 0xEA 0x66 0xC8 0xA3 0x39
Configuration last modified by 0.0.0.0 at 0-0-00 00:00:00
|
SW1(config)#vlan 10 (在全局配置模式下创建
VLAN 10)
SW1(config-vlan)#name cisco (命名为
cisco)
SW1(config-vlan)#end
SW1#vlan database(同理在
服务器模式交换机
SW1上进入
vlan database模式下)
SW1(vlan)#vlan 20 name microsoft (在
vlan database模式下建立
vlan 20并命名为
microsoft)
|
SW1#sh vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/2, Fa0/3, Fa0/4, 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 cisco active
20 microsoft active
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
………………
SW1#
|
SW2#sh vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, 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 cisco active
20 microsoft active
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
………………
SW2#
|
SW1(config)#int f0/11
SW1(config-if)#switchport access vlan 10 (将
f0/11交换机端口加入到
VLAN 10 当中
)
SW1(config-if)#int f0/12
SW1(config-if)#sw ac vlan 20
SW2(config)#int f0/11
SW2(config-if)#sw ac vlan 20
|
SW1(config)#int f0/5
SW1(config-if)#switchport mode trunk (因为此
IOS默认就封装了
dot1q,我们指定接口
trunk模式)
R1(config)#int f0/0
R1(config-if)#no sh (激活此接口)
R1(config-if)#no ip address (但不要配置
IP)
R1(config-if)#int f0/0.10
R1(config-subif)#encapsulation dot1Q 10 (封装
dot1q类型并指定
VLAN,作用是出去的数据包打上
10的
VLAN标记,同时只接收
VLAN 10 的数据包)
R1(config-subif)#ip add 192.168.1.1 255.255.255.0 (为子接口配置
IP用于
VLAN 10的默认网关)
R1(config-subif)#int f0/0.20 (进入
f0/0.20的子接口)
R1(config-subif)#en dot1Q 20(发出的数据包会打上
20的
VLAN标记,同时只接收
VLAN 20 的数据包)
R1(config-subif)#ip add 192.168.2.1 255.255.255.0(为子接口配置
IP用于
VLAN 20的默认网关)
|
R1(config-subif)#do sh ip route
…………
Gateway of last resort is not set
C 192.168.1.0/24 is directly connected, FastEthernet0/0.10 (子接口直连路由)
C 192.168.2.0/24 is directly connected, FastEthernet0/0.20
|