Vlan小实验
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://weiqijun.blog.51cto.com/338163/75871 |
一、场景设置
![]() 二、具体实现
首先,将所有的PC配置在192.168.10.0/24这个网络,并测试连通性:
PC1----192.168.10.2
PC2----192.168.10.3
PC3----192.168.10.4
PC4----192.168.10.5
PC1àPC2
C:>ping 192.168.10.3
Pinging 192.168.10.3 with 32 bytes of data:
Reply from 192.168.10.3: bytes=32 time=60ms TTL=241
Reply from 192.168.10.3: bytes=32 time=60ms TTL=241
Reply from 192.168.10.3: bytes=32 time=60ms TTL=241
Reply from 192.168.10.3: bytes=32 time=60ms TTL=241
Reply from 192.168.10.3: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.10.3: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
PC1àPC3
C:>ping 192.168.10.4
Pinging 192.168.10.4 with 32 bytes of data:
Reply from 192.168.10.4: bytes=32 time=60ms TTL=241
Reply from 192.168.10.4: bytes=32 time=60ms TTL=241
Reply from 192.168.10.4: bytes=32 time=60ms TTL=241
Reply from 192.168.10.4: bytes=32 time=60ms TTL=241
Reply from 192.168.10.4: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.10.4: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
PC1àPC4
C:>ping 192.168.10.5
Pinging 192.168.10.5 with 32 bytes of data:
Reply from 192.168.10.5: bytes=32 time=60ms TTL=241
Reply from 192.168.10.5: bytes=32 time=60ms TTL=241
Reply from 192.168.10.5: bytes=32 time=60ms TTL=241
Reply from 192.168.10.5: bytes=32 time=60ms TTL=241
Reply from 192.168.10.5: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.10.5: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
由此可见,网络连接正常。
然后,在交换机上配置Vlan:
Switch>enable
Switch#vlan database
Switch(vlan)#vlan 2 name Vlan2
VLAN 2 added:
Name:Vlan2
Switch(vlan)#vlan 3 name Vlan3
VLAN 3 added:
Name:Vlan3
Switch(vlan)#exit
APPLY completed.
Exiting....
接下来,将PC1和PC2加入到Vlan2、PC3和PC4加入到Vlan3:
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname Switch1
Switch1(config)#interface FastEthernet0/1
Switch1(config-if)#switchport mode access
Switch1(config-if)#switchport access vlan 2
Switch1(config-if)#exit
Switch1(config)#interface FastEthernet0/2
Switch1(config-if)#switchport mode access
Switch1(config-if)#switchport access vlan 2
Switch1(config-if)#exit
Switch1(config)#interface FastEthernet0/3
Switch1(config-if)#switchport mode access
Switch1(config-if)#switchport access vlan 3
Switch1(config-if)#exit
Switch1(config)#interface FastEthernet0/4
Switch1(config-if)#switchport mode access
Switch1(config-if)#switchport access vlan 3
Switch1(config-if)#exit
验证:
PC1àPC2
C:>ping 192.168.10.3
Pinging 192.168.10.3 with 32 bytes of data:
Reply from 192.168.10.3: bytes=32 time=60ms TTL=241
Reply from 192.168.10.3: bytes=32 time=60ms TTL=241
Reply from 192.168.10.3: bytes=32 time=60ms TTL=241
Reply from 192.168.10.3: bytes=32 time=60ms TTL=241
Reply from 192.168.10.3: bytes=32 time=60ms TTL=241
Ping statistics for 192.168.10.3: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
PC1àPC3
C:>ping 192.168.10.4
Pinging 192.168.10.4 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 192.168.10.4:
Packets: Sent = 5, Received = 0, Lost = 5 (100% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
PC1àPC4
C:>ping 192.168.10.5
Pinging 192.168.10.5 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 192.168.10.5:
Packets: Sent = 5, Received = 0, Lost = 5 (100% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
由此可见,PC1可以ping通PC2,不能ping通PC3和PC4。因为PC1和PC2属于同一个vlan,PC1和PC3、PC4之间属于两个不同的vlan。
本文出自 “Uione” 博客,请务必保留此出处http://weiqijun.blog.51cto.com/338163/75871 本文出自 51CTO.COM技术博客 |



weiqijun
博客统计信息
热门文章
最新评论
友情链接
