CCNA实验-VLAN间的路由
下面是实验拓扑图:

相关说明:
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,
实验完成
更多文章参见--
[url]www.kachy.net[/url]
转载于:https://blog.51cto.com/kachy/69473