Sw1
Switch>
Switch>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vl 10
Switch(config-vlan)#vl 20
Switch(config-vlan)#int f0/1
Switch(config-if)#sw a v 10
Switch(config-if)#int f0/2
Switch(config-if)#sw a v 20
Switch(config-if)#int range f0/3-4
Switch(config-if-range)#sw m t
Sw2
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vl 10
Switch(config-vlan)#vl 20
Switch(config-vlan)#int f0/1
Switch(config-if)#sw a v 10
Switch(config-if)#int f0/2
Switch(config-if)#sw a v 20
Switch(config-if)#int range f0/3-4
Switch(config-if-range)#sw m t
Sw3
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vl 10
Switch(config-vlan)#vl 20
Switch(config-vlan)#int range f0/1-3
Switch(config-if-range)#sw t en d
Switch(config-if-range)#sw m t
Switch(config-if-range)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
Switch(config-if-range)#e
Switch(config)#ip routing
Switch(config)#int f0/2
Switch(config-if)#no switchport
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
Switch(config-if)#ip add 192.168.3.1 255.255.255.0
Switch(config-if)#no sh
Switch(config-if)#ex
Switch(config)#int vl 10
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
Switch(config-if)#ip add 192.168.1.1 255.255.255.0
Switch(config-if)#no sh
Switch(config-if)#int vl 20
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
Switch(config-if)#ip ad 192.168.2.1 255.255.255.0
Switch(config-if)#no sh
Switch(config-if)#ex
Sw4
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vl 10
Switch(config-vlan)#vl 20
Switch(config-vlan)#int range f0/1-3
Switch(config-if-range)#sw t en d
Switch(config-if-range)#sw m t
Switch(config-if-range)#ex
Switch(config)#ip routing
Switch(config)#int vl 10
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
Switch(config-if)#ip add 192.168.1.2 255.255.255.0
Switch(config-if)#no sh
Switch(config-if)#int vl 20
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up
ip add 192.168.2.2 255.255.255.0
Switch(config-if)#no sh
Switch(config-if)#int f0/1
Switch(config-if)#no switchport
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
ip add 192.168.3.2 255.255.255.0
Switch(config-if)#no sh
Switch(config-if)#ex
Sw3
Switch(config)#ip route 0.0.0.0 0.0.0.0 192.168.3.2指路
Switch(config)#spanning-tree vlan 10 root primary 设置生成树
Switch(config)#spanning-tree vlan 20 root secondary
sw4
Switch(config)#ip route 0.0.0.0 0.0.0.0 192.168.3.1
Switch(config)#spanning-tree vlan 20 root primary
Switch(config)#spanning-tree vlan 10 root secondary
Pc手动配置IP