SW1
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#hostname SW1
SW1(config)#no ip domain-lo SW1(config)#line console 0 SW1(config-line)#exec-timeout SW1(config-line)#exit SW1(config)#vlan SW1(config-vlan)#name caiwu SW1(config-vlan)#vlan SW1(config-vlan)#name it SW1(config-vlan)#exit SW1(config)#interface range fastEthernet /- SW1(config-if-range)#switchport mode access SW1(config-if-range)#switchport access vlan
SW1(config-if-range)#exit SW1(config)#interface range fa0/- SW1(config-if-range)#switchport mode access SW1(config-if-range)#switchport access vlan
SW1(config-if-range)#end
SW1#
%SYS--CONFIG_I: Configured from console by console SW1#show vlan b
SW1#show vlan brief VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
default active Fa0/, Fa0/, Fa0/, Fa0/
Fa0/, Fa0/, Fa0/, Fa0/
Fa0/, Fa0/, Fa0/, Fa0/
Fa0/, Fa0/, Fa0/, Fa0/
Fa0/, Fa0/, Fa0/, Gig0/
Gig0/
caiwu active Fa0/, Fa0/
it active Fa0/, Fa0/, Fa0/
fddi-default active
token-ring-default active
fddinet-default active
trnet-default active
SW1#conf t
Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#interface gigabitEthernet /
SW1(config-if)#switchport mode trunk SW1(config-if)#end
SW1# #修改native VLAN为VLAN Switch(config)#interface gigabitEthernet / SW1(config-if)#switchport trunk native vlan
SW1(config-if)#
%CDP--NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on GigabitEthernet0/ (), with Switch GigabitEthernet0/ (). SW1(config-if)
SW2
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#no ip domain-lo Switch(config)#line console 0 Switch(config-line)#logging synchronous Switch(config-line)#exec-timeout
Switch(config-line)#exit Switch(config)#vlan Switch(config-vlan)#name caiwu Switch(config-vlan)#vlan Switch(config-vlan)#name it Switch(config-vlan)#exit Switch(config)#interface fa0/ Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan Switch(config-if)#int fa0/ Switch(config-if)#switchport mode access Switch(config-if)#switchport access vlan
Switch(config-if)#end Switch#
%SYS--CONFIG_I: Configured from console by console Switch#show vlan brief VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
default active Fa0/, Fa0/, Fa0/, Fa0/
Fa0/, Fa0/, Fa0/, Fa0/
Fa0/, Fa0/, Fa0/, Fa0/
Fa0/, Fa0/, Fa0/, Fa0/
Fa0/, Fa0/, Fa0/, Fa0/
Fa0/, Fa0/, Gig0/, Gig0/
caiwu active Fa0/
it active Fa0/
fddi-default active
token-ring-default active
fddinet-default active
trnet-default active
Switch#
%LINEPROTO--UPDOWN: Line protocol on Interface GigabitEthernet0/, changed state to down %LINEPROTO--UPDOWN: Line protocol on Interface GigabitEthernet0/, changed state to up Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#interface gigabitEthernet / Switch(config-if)#switchport mode trunk Switch(config-if)#end Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z. #在trunk上移除VLAN3的流量,使得SW1、SW2的VLAN3之间不能够通信
Switch(config)#interface gigabitEthernet /
Switch(config-if)#switchport trunk allowed vlan remove #在trunk上允许VLAN3的流量,使得SW1、SW2的VLAN3之间能够通信
Switch(config-if)#switchport trunk allowed vlan add #修改native VLAN为VLAN Switch(config)#interface gigabitEthernet / Switch(config-if)#switchport trunk native vlan Switch#show interfaces trunk
Port Mode Encapsulation Status Native vlan
Gig0/ on .1q trunking Port Vlans allowed on trunk
Gig0/ - Port Vlans allowed and active in management domain
Gig0/ ,, Port Vlans in spanning tree forwarding state and not pruned
Gig0/ ,,