天天看點

VLAN配置

Vlan(Virtual Local Area Network)即虛拟區域網路。VLAN可以把同一個實體網絡劃分為多個邏輯網段,是以,Vlan可以抑制網絡風暴,增強網絡的安全性。

一、執行個體拓撲圖
VLAN配置

PC1的配置:

PC>ipconfig 192.168.0.1 255.255.255.0

配置前的測試:

PC>ping 192.168.0.2

Pinging 192.168.0.2 with 32 bytes of data:

Reply from 192.168.0.2: bytes=32 time=125ms TTL=128

Reply from 192.168.0.2: bytes=32 time=62ms TTL=128

Reply from 192.168.0.2: bytes=32 time=63ms TTL=128

Ping statistics for 192.168.0.2:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 62ms, Maximum = 125ms, Average = 78ms

PC>ping 192.168.0.3

Pinging 192.168.0.3 with 32 bytes of data:

Reply from 192.168.0.3: bytes=32 time=109ms TTL=128

Reply from 192.168.0.3: bytes=32 time=47ms TTL=128

Reply from 192.168.0.3: bytes=32 time=63ms TTL=128

Ping statistics for 192.168.0.3:

Minimum = 47ms, Maximum = 109ms, Average = 70ms

二、建立VLAN

在Cisco IOS中有兩種方式建立vlan,在全局配置模式下使用vlan vlanid指令,如switch(config)#vlan 10;在vlan database下建立vlan,如switch(vlan)vlan 20

Swtich

Switch>enable

Switch#config terminal

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#vlan 10

Switch(config-vlan)#vlan 20

Switch(config-vlan)#end

Switch#show vlan

VLAN Name Status Ports

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

1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4

Fa0/5, Fa0/6, Fa0/7, Fa0/8

Fa0/9, Fa0/10, Fa0/11, Fa0/12

Fa0/13, Fa0/14, Fa0/15, Fa0/16

Fa0/17, Fa0/18, Fa0/19, Fa0/20

Fa0/21, Fa0/22, Fa0/23, Fa0/24

10 VLAN0010 active

20 VLAN0020 active

三、把端口劃分給vlan(基于端口的vlan)

Switch(config)#interface fa0/1

Switch(config-if)#switchport mode access

Switch(config-if)#switchport access vlan 10

Switch(config-if)#exit

Switch(config)#interface fa0/2

Switch(config-if)#switchport mode access

Switch(config)#interface fa0/3

Switch(config-if)#switchport access vlan 20

Switch(config)#interface fa0/4

四、檢視vlan資訊

1 default active Fa0/5, Fa0/6, Fa0/7, Fa0/8

10 VLAN0010 active Fa0/1, Fa0/2

20 VLAN0020 active Fa0/3, Fa0/4

配置後的測試:

Minimum = 62ms, Maximum = 63ms, Average = 62ms

Request timed out.

Packets: Sent = 4, Received = 0, Lost = 4 (100% loss)

VLAN配置
VLAN配置

計算機的配置:

PC>ipconfig 192.168.0.2 255.255.255.0

PC>ipconfig 192.168.0.3 255.255.255.0

PC>ipconfig 192.168.0.4 255.255.255.0

PC>ipconfig 192.168.0.5 255.255.255.0

交換機的配置:

Switch#configure terminal

Switch(config-vlan)#exit

Switch(config)#interface fa0/24

Switch(config-if)#switchport mode trunk

Switch(config)#

Switch(config-if)#

測試:

Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

PC>ping 192.168.0.4

Pinging 192.168.0.4 with 32 bytes of data:

Ping statistics for 192.168.0.4:

PC>ping 192.168.0.5

Pinging 192.168.0.5 with 32 bytes of data:

Reply from 192.168.0.5: bytes=32 time=94ms TTL=128

Reply from 192.168.0.5: bytes=32 time=78ms TTL=128

Ping statistics for 192.168.0.5: