交换机实验之: VLAN间路由实验
 
实验目的:  在交换机上通过干道连接一台路由器,用来为不同VLAN进行路由。
实验拓扑图:
实验步骤:
(1)按照拓扑图连线。
            路由器f0/0 连接交换机1的gigabitEthernet 1/1  交换机1的f0/1连接交换机2的f0/1
(2)交换机的配置。
           创建VLAN:
Switch>enable
Switch#vlan database
% Warning: It is recommended to configure VLAN from config mode,
  as VLAN database mode is being deprecated. Please consult user
  documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vlan 10 name 10
VLAN 10 added:
    Name: 10
Switch(vlan)#vlan 20 name 20
VLAN 20 added:
    Name: 20
        将连接PC机的端口赋给VLAN:
Switch#config t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#inter f0/2
Switch(config-if)#switchport mode access
Switch(config-if)#swit
Switch(config-if)#switchport access vlan 10
Switch(config-if)#no shutdown
Switch(config-if)#^Z
Switch#config t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#inter f0/3
Switch(config-if)#switchport mode access
Switch(config-if)#swit
Switch(config-if)#switchport access vlan 20
Switch(config-if)#no shutdown
启用trunk通道:
witch#config t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#interface gigabitEthernet 1/1
Switch(config-if)#switchport mode trunk
Switch(config-if)#no shutdown
注:交换机2亦作如上相同配置。
(3)路由器的配置
Router>enable
Router#config t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#interface f0/0
Router(config-if)#no shutdown
Router(config-if)#end
%SYS-5-CONFIG_I: Configured from console by console
Router#confi t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#interface f 0/0.1
%LINK-5-CHANGED: Interface FastEthernet0/0.1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.1, changed state to upRouter(config-subif)#
Router(config-subif)#description name 10 vlan 10 (描述VLAN10)
Router(config-subif)#encapsulation dot1q 10 (封装802.1q协议)
Router(config-subif)#ip add 10.1.1.1 255.255.255.0  (网关IP地址)
Router(config-subif)#no shutdown
Router(config-subif)#^Z
%SYS-5-CONFIG_I: Configured from console by console
Router#config t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#interface  f 0/0.2
%LINK-5-CHANGED: Interface FastEthernet0/0.2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.2, changed state to upRouter(config-subif)#
Router(config-subif)#description name 20 vlan 20
Router(config-subif)#encapsulation dot1q 20
Router(config-subif)#ip add  192.168.1.1 255.255.255.0
Router(config-subif)#no shutdown
(4)PC机配置
0:
 
 
 
 
 
 
 
 
 
 
1: 如上相似配置
    IP: 192.168.1.10 子网掩码:255.255.255.0 默认网关:192.168.1.1
2:如上相似配置
    IP: 10.1.1.20子网掩码:255.255.255.0 默认网关:10.1.1.1
3:如上相似配置
    IP: 192.168.1.20子网掩码:255.255.255.0 默认网关:192.168.1.1
 
实验结果:
主机0可以PING通同一网段的不同区域的主机2,也可PING通不同VLAN的相同区域的主机1,也可PING通不同VLAN的不同区域的主机3。实现不同地区不同VLAN 的通信。
实验注意:注意配置trunk 通道,在真机操作时注意路由与交换机的连接线须为交叉线,由于刚开始我疏忽用直通线连接,主机之间一直不能通信。