交換機下配置

 

clip_image002

主要思路:

(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 信息:

clip_image004

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

clip_image006

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

clip_image008

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

clip_image010

(5)在PC1上對其它PC進行PING命令:

clip_image012

(5)在PC2上對其它PC進行PING命令:

clip_image014

註明:

因爲pc1和pc3都屬於vlan2,所以能夠PING通,

PC2與PC4都屬於vlan3,所以它們也能夠PING通。

但是PC1和PC3與PC2和PC4是不能夠PING通的。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章