SW2
Switch>en Switch#conf t Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#hostname SW2 SW2(config)#vlan 2 SW2(config-vlan)#name caiwu SW2(config-vlan)#vlan 3 SW2(config-vlan)#name it SW2(config-vlan)#exit SW2(config)#interface range fastEthernet 0/1-2 SW2(config-if-range)#switchport mode access SW2(config-if-range)#switchport access vlan 2 SW2(config-if-range)#interface fastEthernet 0/3 SW2(config-if)#switchport mode access SW2(config-if)#switchport access vlan 3 SW2(config-if)#exit SW2(config)#do show vlan br VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active 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, Fa0/2 3 it active Fa0/3 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active SW2(config)#interface gigabitEthernet 0/1 SW2(config-if)#switchport mode trunk
SW1
Switch>en Switch#conf t Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#hostname SW1 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 gigabitEthernet 0/1 SW1(config-if)#switchport mode trunk Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode. #三层交换机要打trunj,需要开启dot1q协议 SW1(config-if)#switchport trunk encapsulation dot1q SW1(config-if)#switchport mode trunk SW1(config-if)# exit #进入VLAN2 SW1(config)#interface vlan 2 %LINK-5-CHANGED: Interface Vlan2, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan2, changed state to up #配置VLAN2的网关 SW1(config-if)#ip add 192.168.2.254 255.255.255.0 SW1(config-if)#no shutdown SW1(config-if)#interface vlan 3 %LINK-5-CHANGED: Interface Vlan3, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan3, changed state to up SW1(config-if)#ip add 192.168.2.254 255.255.255.0 SW1(config-if)#no shutdown SW1(config-if)#exit SW1#show ip interface brief Interface IP-Address OK? Method Status Protocol FastEthernet0/1 unassigned YES unset down down FastEthernet0/2 unassigned YES unset down down FastEthernet0/3 unassigned YES unset down down FastEthernet0/4 unassigned YES unset down down FastEthernet0/5 unassigned YES unset down down FastEthernet0/6 unassigned YES unset down down FastEthernet0/7 unassigned YES unset down down FastEthernet0/8 unassigned YES unset down down FastEthernet0/9 unassigned YES unset down down FastEthernet0/10 unassigned YES unset down down FastEthernet0/11 unassigned YES unset down down FastEthernet0/12 unassigned YES unset down down FastEthernet0/13 unassigned YES unset down down FastEthernet0/14 unassigned YES unset down down FastEthernet0/15 unassigned YES unset down down FastEthernet0/16 unassigned YES unset down down FastEthernet0/17 unassigned YES unset down down FastEthernet0/18 unassigned YES unset down down FastEthernet0/19 unassigned YES unset down down FastEthernet0/20 unassigned YES unset down down FastEthernet0/21 unassigned YES unset down down FastEthernet0/22 unassigned YES unset down down FastEthernet0/23 unassigned YES unset down down FastEthernet0/24 unassigned YES unset down down GigabitEthernet0/1 unassigned YES unset up up GigabitEthernet0/2 unassigned YES unset down down Vlan1 unassigned YES unset administratively down down Vlan2 192.168.2.254 YES manual up up Vlan3 192.168.3.254 YES manual up up SW1# #开启三层交换的路由功能 SW1#conf t Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#ip routing