版权声明:原创作品,谢绝转载!否则将追究法律责任。 |
下面是实验拓扑图:
相关说明:VLAN中文叫做虚拟局域网,它的作用就是将物理上互连的网络在逻辑上划分为多个互不相干的网络,这些网络之间是无法通讯的,就好像互相之间没有连接一样,因此广播也就隔离开了。本次实验用于实现vlan间的路由。
实验过程:
I:配置个模拟主机PC-1
PC-2 PC-3的IP。
|
PC-1(config)#int f0/0
PC-1(config-if)#ip address 192.168.1.1 255.255.255.0
PC-1(config-if)#no sh
PC-1(config-if)#exit
PC-1(config)#no ip routing
#关闭路由功能,做PC机
PC-1(config)#ip default-gateway 192.168.1.110 #设置默认网关
PC-1(config)#exit
|
II:在交换机KC-S上创建vlan.
|
KC-S#vlan database
KC-S(vlan)#vlan 10 name 10 #创建编号和名称为20的vlan
VLAN 10 added:
Name: 10
KC-S(vlan)#apply
APPLY completed.
KC-S(vlan)#vlan 20 name 20
VLAN 20 added:
Name: 20
KC-S(vlan)#apply
APPLY completed.
KC-S(vlan)#exit
KC-S#sh vlan-switch
|
III:在交换机上将相应vlan接口上应用vlan.
|
KC-S(config)#int f1/13
KC-S(config-if)#switchport access vlan 10 #将当前接口应用到vlan
KC-S(config-if)#no sh
KC-S(config-if)#exit
KC-S(config)#int f1/14
KC-S(config-if)#switchport access vlan 10
KC-S(config-if)#exit
KC-S(config)#int f1/15
KC-S(config-if)#switchport access vlan 20
KC-S(config-if)#exit
KC-S#sh
vlan-switch
|
IV:PC-1不能ping通PC-2或PC-3,但PC-2和PC-3可以互通,可见vlan将主机阻隔
|
PC-1#ping 192.168.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
...
Success rate is 0 percent (0/3)
PC-2#ping 192.168.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 56/76/96 ms
PC-2#
PC-3#ping 192.168.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 48/70/88 ms
|
V:将KC-S的f1/1设定为trunk模式
|
KC-S(config)#int f1/1
KC-S(config-if)#switchport mode trunk #f1/1设定为trunk模式
*Mar 1 00:27:29.035:
%DTP-5-TRUNKPORTON: Port Fa1/1 has become dot1q trunk
KC-S(config-if)#exit
KC-S(config)#exit
*Mar 1 00:27:37.735:
%SYS-5-CONFIG_I: Configured from console by console
KC-S#sh int trunk #查看链路模式
Port Mode Encapsulation Status Native vlan
Fa1/1 on 802.1q trunking 1
|
VI:在路由器KC-R上设置支持trunk通信,采用子接口模式。
|
KC-R(config)#int f0/0
KC-R(config-if)#no ip address #必须no ip address和no
shutdown
KC-R(config-if)#no shut
KC-R(config-if)#exit
KC-R(config)#
子接口配置:
KC-R(config)#int
f0/0.10
KC-R(config-subif)#encapsulation
dot1Q 10 #设置trunk的封装协议
KC-R(config-subif)#ip
address 192.168.1.110 255.255.255.0
KC-R(config-subif)#no
shu
KC-R(config-subif)#exit
KC-R(config)#int
f0/0.20
KC-R(config-subif)#encapsulation
dot1Q 20
KC-R(config-subif)#ip
address 192.168.2.220 255.255.255.0
KC-R(config-subif)#no
sh
KC-R(config-subif)#exit
|
VII:测试。
|
PC-1#ping 192.168.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 64/82/120 ms
PC-1#ping 192.168.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:
..!!!
Success rate is 60 percent (3/5), round-trip min/avg/max = 72/88/104 ms
PC-1#ping 192.168.2.2
|
可见PC-1可以ping通PC-2和PC-3.
OK,实验完成
更多文章参见-- www.kachy.net本文出自 “Kachy” 博客,谢绝转载! 本文出自 51CTO.COM技术博客 |