PC1前端
IP: 192.168.1.2spa
Submark: 255.255.255.0接口
Gateway: 192.168.1.1ip
PC2路由
IP: 192.168.2.2it
Submark: 255.255.255.0io
Gateway: 192.168.2.1配置
PC3route
IP: 192.168.1.3im
Submark: 255.255.255.0
Gateway: 192.168.1.1
PC1 Ping PC3
Ping 192.168.1.3 reply
PC1 Ping PC2
Ping 192.168.2.2 timeout
S2960
Switch>en
Switch#conf t
Switch(config )#vlan 2
Switch(config-vlan)#exit
Switch(config )#vlan 3
Switch(config-vlan)#exit
Switch(config )#int fa 0/2
Switch(config-if)#switchport access vlan 2
Switch(config-if)#exit
Switch(config )#int fa 0/3
Switch(config-if)#switchport access vlan 3
Switch(config-if)#exit
Switch(config )#int fa 0/1
Switch(config-if)#switchport mode trunk
Switch(config-if)#end
Switch#show vlan
S3560
Switch>en
Switch#conf t
Switch(config )#vlan 2 //新建vlan 2
Switch(config-vlan)#exit
Switch(config )#vlan 3 //新建vlan 3
Switch(config-vlan)#exit
Switch(config )#int fa 0/1 //進入0模塊第1端口
Switch(config-if)#switchport trunk encapsulation dot1q //給這個接口的trunk封裝爲802.1Q的幀格式
Switch(config-if)#switchport mode trunk //定義這個接口的工做模式爲trunk
Switch(config-if)#exit
Switch(config )#int fa 0/2 //進入0模塊第2端口
Switch(config-if)#switchport access vlan 2 //當前端口加入vlan 2
Switch(config-if)#exit
Switch(config )#interface vlan 2 //進入vlan2 虛擬接口
Switch(config-if)#ip address 192.168.1.1 255.255.255.0 //配置IP地址
Switch(config-if)#no shutdown //開啓該端口
Switch(config-if)#exit
Switch(config )#interface vlan 3
Switch(config-if)#ip address 192.168.2.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#end
Switch#show ip route //顯示路由表
Switch#show vlan //顯示vlan信息
PC1 Ping PC3
Ping 192.168.1.3 reply
PC1 Ping PC2
Ping 192.168.2.2 reply