交换机下配置_休闲

主要思路:

(1)对于交换机:

1:命名

2:划分VLAN

3:将指定端口划分到指定vlan

4:将指定端口设置成trunk模式

(2)对于PC:(这里把router看成是PC)

1:命名

2:禁止路由功能

3:设置IP

4:ping IP

(3)查看配置命令:

查看vlan :show vlan-switch

查看trunk: show interface f0/0 switchport

----------------------------------------------

配置文档:

sw1:

enable

config terminal

hostname sw1 //命名

exit

vlan database //添加VLAN并命名

vlan 2 name v2

vlan 3 name v3

exit

config terminal //将端口添加到指定的VLAN

interface f0/1

switchport access vlan 2

exit

interface f0/2 //将端口添加到指定的VLAN

switchport access vlan 3

exit

interface f0/0 //将指定端口设置成trunk

switchport mode trunk

end

write

----------------------------------------------

sw2:

enable //命名

config terminal

hostname sw2

exit

vlan database //添加VLAN并命名

vlan 2 name v2

vlan 3 name v3

exit

config terminal //将指定端口添加到指定VLAN

interface f0/2

switchport access vlan 2

exit

interface f0/3 //将指定端口添加到指定VLAN

switchport access vlan 3

exit

interface f0/0 //将指定端口设置成trunk

switchport mode trunk

end

write

----------------------------------------------

pc1:

enable

config terminal

hostname pc1 //命名

no ip routing //禁止路由功能

interface f0/0

ip address 192.168.1.1 255.255.255.0 //设置IP

no shutdown //激活

end

write

-----------------------------------------------

pc2:

enable

config terminal

hostname pc2 //命名

no ip routing //禁止路由功能

interface f0/0

ip address 192.168.1.2 255.255.255.0 //设置IP

no shutdown //激活

end

write

-----------------------------------------------

pc3:

enable

config terminal

hostname pc3 //命名

no ip routing //禁止路由功能

interface f0/0

ip address 192.168.1.3 255.255.255.0 //设置IP

no shutdown //激活

end

write

-----------------------------------------------

pc4:

enable

config terminal

hostname pc4 //命名

no ip routing //禁止路由功能

interface f0/0

ip address 192.168.1.4 255.255.255.0 //设置IP

no shutdown //激活

end

write

-----------------------------------------------

测试截图:

(1)在SW1上查看VLAN 信息:

交换机下配置_休闲_02

(2)在SW1上查看F0/0端口模式:

交换机下配置_交换机_03

(3)在SW2上查看VLAN 信息:

交换机下配置_职场_04

(4)在SW2上查看F0/0端口模式:

交换机下配置_休闲_05

(5)在PC1上对其它PC进行PING命令:

交换机下配置_休闲_06

(5)在PC2上对其它PC进行PING命令:

交换机下配置_休闲_07

注明:

因为pc1和pc3都属于vlan2,所以能够PING通,

PC2与PC4都属于vlan3,所以它们也能够PING通。

但是PC1和PC3与PC2和PC4是不能够PING通的。。