注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 可扩展、高可用、负载均衡..
 帮助

Vlan小实验


2008-05-08 14:38:17
 标签:实验 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....
 
接下来,将PC1PC2加入到Vlan2PC3PC4加入到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可以pingPC2,不能pingPC3PC4。因为PC1PC2属于同一个vlan,PC1PC3PC4之间属于两个不同的vlan
 
 

本文出自 “Uione” 博客,请务必保留此出处http://weiqijun.blog.51cto.com/338163/75871





    文章评论
 
2008-05-08 17:12:12
非常感谢你的文章.
在此,我还有几个关于VLAN之间信息通信的设置问题要向你 请教:
我在俩个交换机上分别设置了VLAN2,3。设置的IP地址分别是在192.168.2.0 和192.168.3.0 ,然后PC2和PC3分别放在了里面,IP为2.1 和3.1 ,然后这个交换机通过一个Fast口连接到ROUTER,设置好了TRUNK协议。
并且在这个ROUTER的Fast口上进行了子接口设置,IP为2.254和3.254,同时在ROUTER上开启了RIP协议。也就是说的“单臂路由”。同时呢,又出了一个交换机和现在的这个交换机完成是一样的配置,也是接在了同一个ROUTER上,但是是不同的Fast口,但是第2个却不可以进行设置。为什么呢?还请高手多多指点~谢谢了~~

 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: