注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 子域部署Exchange服务器详..
 帮助

三层交换机实现VLAN互通实例


2007-06-12 00:24:04
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://lanfox.blog.51cto.com/90302/29672
实验目的:
随着企业内部流量的逐步增大,使用路由器的独臂路由功能来实现不同vlan间互访已不能满足企业用户的需求。这时我们可以使用转发速度较快的三层交换机来实现这些功能。通过在三层交换上配置相应的vlan地址(即网关地址),让不同vlan的用户通过三层交换的中继链路实现快速的互访。
 
实验拓扑:
 
 
 
 
 
 
 
实验步骤
v2层交换机上配置VLAN
SW-2L(config)#vlan 2
SW-2L(config-vlan)#vlan 3
SW-2L(config-vlan)#exit
配置所需要的接口加入到vlan
SW-2L(config)#interface range f0/2
SW-2L(config-if-range)#switchport mode access
SW-2L(config-if-range)#switchport access vlan 2
 
SW-2L(config)#interface range f0/3
SW-2L(config-if-range)#switchport mode access
SW-2L(config-if-range)#switchport access vlan 3
v2层交换机上配制Trunk接口
SW-2L(config)#interface f0/1
SW-2L(config-if)#switchport mode trunk
v 3层交换机上配置与2层交换机相同的VLAN(配置步骤与方法相同,也可以配置一台交换机为VTP域服务器,其它交换机为VTP域客户端来自动学习vlan信息)
SW-3L(config)#vlan database
SW-3L(config-vlan)#vlan 2
SW-3L(config-vlan)#vlan 3
SW-3L(config-vlan)#exit
v3层交换机上配置中继接口
SW-3L(config)#interface f0/1
SW-3L(config-if)#switchport  trunk encapsulation dot1q
SW-3L(config-if)#switchport mode trunk
v3层交换机上启动路由
         SW-3L(config)#ip routing
v3层交换机上配置各VLANIP地址
SW-3L(config)#interface vlan 1
SW-3L(config-if)#ip address 192.168.1.1 255.255.255.0
SW-3L(config-if)#no shut
 
SW-3L(config)#interface vlan 2
SW-3L(config-if)#ip address 192.168.2.1 255.255.255.0
SW-3L(config-if)#no shut
 
SW-3L(config)#interface vlan 3
SW-3L(config-if)#ip address 192.168.3.1 255.255.255.0
SW-3L(config-if)#no shut
v3层交换机上查看路由表
SW-3L#show ip route
SW-3L #sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is not set
 
C    192.168.1.0/24 is directly connected, Vlan1
C    192.168.2.0/24 is directly connected, Vlan2
C    192.168.3.0/24 is directly connected, Vlan3
v在主机192.168.2.2ping 192.168.3.2
在这里,主机也是用路由器模拟的,这里举一台的配置为例:
Router#conf t
Router(config)#host PC2
PC2(config)#int f0/2
PC2(config-if)#no sw
PC2(config-if)#ip add 192.168.2.2 255.255.255.0
PC2(config-if)#no shut
PC2(config-if)#exit
PC2(config)#ip default-ga 192.168.2.1
PC2(config)#no ip routing
PC2#ping 192.168.3.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 96/143/232 ms
v查看FIB   FIB,即转发信息库。从概念上看,FIB类似于路由表,包含路由表中的转发信息的镜像)
SW-3L#show ip cef    查看FIB
SW-3L #sh ip cef
Prefix              Next Hop             Interface
0.0.0.0/0           drop                 Null0 (default route handler entry)
0.0.0.0/32          receive
192.168.1.0/24      attached             Vlan1
192.168.1.0/32      receive
192.168.1.1/32      receive
192.168.1.2/32      192.168.1.2          Vlan1
192.168.1.255/32    receive
192.168.2.0/24      attached             Vlan2
192.168.2.0/32      receive
192.168.2.1/32      receive
192.168.2.2/32      192.168.2.2          Vlan2
192.168.2.255/32    receive
192.168.3.0/24      attached             Vlan3
192.168.3.0/32      receive
192.168.3.1/32      receive
192.168.3.2/32      192.168.3.2          Vlan3
192.168.3.255/32    receive
224.0.0.0/4         drop
224.0.0.0/24        receive
255.255.255.255/32  receive
SW-3L#show adjacency detail 查看邻接关系表
SW-3L #sh adjacency detail
Protocol Interface                 Address
IP       Vlan2                     192.168.2.2(5)
                                   20 packets, 2280 bytes
                                   CC000924F002CC000CC800000800
                                   ARP        03:53:59 
                                   Epoch: 0
IP       Vlan3                     192.168.3.2(5)
                                   30 packets, 3420 bytes
                                   CC0002D4F003CC000CC800000800
                                   ARP        03:55:52 
                                   Epoch: 0
IP       Vlan1                     192.168.1.2(5)
                                   10 packets, 1140 bytes
                                   CC0008D4F004CC000CC800000800
                                   ARP        03:57:06 
                                   Epoch: 0
 

本文出自 “lanfox” 博客,请务必保留此出处http://lanfox.blog.51cto.com/90302/29672





    文章评论
 
2007-06-12 18:59:18
搞个间单的看看!

2007-09-02 19:59:06
请问下那个二层的交换机也可以配置 interface vlan 吗,好象二层交换机也有个管理ip什么的

2007-09-14 11:23:07
二层的交换机,也可以设置vlan啊,vlan1的ip就是所谓的管理ip

2007-11-01 23:41:55
C   192.168.1.0/24 is directly connected, Vlan1
C   192.168.2.0/24 is directly connected, Vlan2
C   192.168.3.0/24 is directly connected, Vlan3

2007-11-04 20:27:33
    [匿名]这个出不来删除
2007-11-01 23:41:55
C   192.168.1.0/24 is directly connected, Vlan1
C   192.168.2.0/24 is directly connected, Vlan2
C   192.168.3.0/24 is directly connected, Vlan3

???
不会吧?这个是属于直连的,怎么会出不来呢?

2008-01-02 23:31:18
C   192.168.1.0/24 is directly connected, Vlan1
C   192.168.2.0/24 is directly connected, Vlan2
C   192.168.3.0/24 is directly connected, Vlan3
我也出不来!!!

 

发表评论

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