实验拓扑
二层交换机配置
Switch>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 10
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#exit
Switch(config)#int f 0/1
Switch(config-if)#switchport access vlan 10
Switch(config-if)#exit
Switch(config)#int f 0/3
Switch(config-if)#switchport access vlan 20
Switch(config-if)#exit
Switch(config)#int f 0/2
Switch(config-if)#switchport mode trunkSwitch(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)#exit
Switch(config)#exit
Switch#
%SYS-5-CONFIG_I: Configured from console by consoleSwitch#write
Building configuration...
[OK]三层交换机配置
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int f 0/1
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
Switch(config-if)#exit
Switch(config)#vlan 10
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#exit
Switch(config)#interface vlan 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.254 255.255.255.0
Switch(config-if)#exit
Switch(config)#interface vlan 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 add 192.168.2.254 255.255.255.0
Switch(config-if)#exit
Switch(config)#ip routing
Switch(config)#exit
Switch#
%SYS-5-CONFIG_I: Configured from console by consoleSwitch#write
Building configuration...
[OK]
Switch#PC0 IP设置:
PC1 IP设置:
测试:去PC0上PING PC1
转载于:https://blog.51cto.com/simonxu/1386240