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 00

SW1(config-line)#exit

SW1(config)#vlan 2

SW1(config-vlan)#name caiwu

SW1(config-vlan)#vlan 3

SW1(config-vlan)#name it

SW1(config-vlan)#exit

SW1(config)#interface range fastEthernet 0/1-2

SW1(config-if-range)#switchport mode access 

SW1(config-if-range)#switchport access vlan 2
SW1(config-if-range)#exit

SW1(config)#interface range fa0/3-5

SW1(config-if-range)#switchport mode access 

SW1(config-if-range)#switchport access vlan 3
SW1(config-if-range)#end
SW1#
%SYS-5-CONFIG_I: Configured from console by console

SW1#show vlan b
SW1#show vlan brief 

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    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, Gig0/1
                                                Gig0/2
2    caiwu                            active    Fa0/1, Fa0/2
3    it                               active    Fa0/3, Fa0/4, Fa0/5
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
SW1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.

SW1(config)#interface gigabitEthernet 0/1
SW1(config-if)#switchport mode trunk 

SW1(config-if)#end
SW1#

#修改native VLAN为VLAN 90

Switch(config)#interface gigabitEthernet 0/1

SW1(config-if)#switchport trunk native vlan 90
SW1(config-if)#
%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on GigabitEthernet0/1 (1), with Switch GigabitEthernet0/1 (90).

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 00
Switch(config-line)#exit

Switch(config)#vlan 2

Switch(config-vlan)#name caiwu

Switch(config-vlan)#vlan 3

Switch(config-vlan)#name it

Switch(config-vlan)#exit


Switch(config)#interface fa0/1

Switch(config-if)#switchport mode access 

Switch(config-if)#switchport access vlan 2

Switch(config-if)#int fa0/2

Switch(config-if)#switchport mode access 

Switch(config-if)#switchport access vlan 3
Switch(config-if)#end

Switch#
%SYS-5-CONFIG_I: Configured from console by console

Switch#show vlan brief 

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, Gig0/1, Gig0/2
2    caiwu                            active    Fa0/1
3    it                               active    Fa0/2
1002 fddi-default                     active    
1003 token-ring-default               active    
1004 fddinet-default                  active    
1005 trnet-default                    active    
Switch#
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up

Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#interface gigabitEthernet 0/1

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 0/1
Switch(config-if)#switchport trunk allowed vlan remove 3

#在trunk上允许VLAN3的流量,使得SW1、SW2的VLAN3之间能够通信
Switch(config-if)#switchport trunk allowed vlan add 3


#修改native VLAN为VLAN 90

Switch(config)#interface gigabitEthernet 0/1

Switch(config-if)#switchport trunk native vlan 90


Switch#show interfaces trunk 
Port        Mode         Encapsulation  Status        Native vlan
Gig0/1      on           802.1q         trunking      90

Port        Vlans allowed on trunk
Gig0/1      1-1005

Port        Vlans allowed and active in management domain
Gig0/1      1,2,3

Port        Vlans in spanning tree forwarding state and not pruned
Gig0/1      1,2,3

 

posted on 2018-07-31 18:05  彼de潘  阅读(308)  评论(0编辑  收藏  举报