有时候,当我孤独地坐着等待生命大门关闭时,一种与世隔绝的感觉就会像冷雾一样笼罩着我。远处有光明、音乐和友谊,但我进不去,命运之神无情地挡住了大门。我真想义正词严地提出抗议,因为我的心仍然充满了热情。但是那些酸楚而无益的话语流溢在唇边,欲言又止,犹如泪水往肚里流,沉默浸透了我的灵魂。然后,希望之神微笑着走来对我轻轻耳语说:“忘我就是快乐。”因而我要把别人眼睛所看见的光明当作我的太阳,别人耳朵所听见的音乐当作我的乐曲,别人嘴角的微笑当作我的快乐。

三层交换机实现不同vlan间的通信实验思路总结

上一篇 / 下一篇  2009-08-03 12:26:37 / 个人分类:面试小结

三层交换机实现不同vlan间的通信实验思路总结

 

从网上找到了一些实验,分析后进行思路总结:google_protectAndRun("render_ads.js::google_render_ad", google_handleError, google_render_ad);

  我们知道不同的vlan之间要相互的通行必须要借用第三层,也就是网络层,可以路由器也可以是三层的交换机,在这里我主要是介绍用三层交换机来实现不同的vlan之间的的通信。

  实验拓扑图结构:

三层交换机实现不同vlan间的通信

上图中,中间是二层交换机,最右是三层交换机。

从配置思路看,在二层交换机和三层交换机连接的端口,二层交换机设置为trunk 端口,相应的三层交换机针对不同vlan ,设置不同的子接口,配置不同网段的ip地址,作为网关IP地址。

经过pc1 发送的报文,目的地址是PC2,报文被发送到Fa01端口上,端口类型是access端口类型,接收了没有vlan 的报文,进入端口后,,加上vlan 2 ,出端口时删除vlan2 ,转发到接收vlan2 的端口上,也就是trunk 端口。

报文上送到Fa0/2端口上,传送到端口Fa0/1的vlan2上,VLAN2 上有网关地址,在三层交换机中查找路由表项 

C    192.168.1.0/24 is directly connected, Vlan2

  C    192.168.2.0/24 is directly connected, Vlan3

发现目的地址是192.168.2.0网段的,需要经过vlan 3 进行处理,就把报文转发到vlan3 进行处理。

vlan3 的端口将报文转发到Fa0/2的端口vlan3下。

在二层交换机中,查找mac表项,发现vlan 3 的端口连接的是Fa0/3,就将报文转发给Fa0/3。  

  实验描述:

  pc0和pc1分属于不同的vlan中,在实际的生活中,它们之间存在相互通信的可能。

  pc0                                                      

 ip 192168 1  2
 mask 255 255 255 0
 gataway 192 168 1 1

  pc1

 ip 192 168 2 2
 mask255255 2550 
 gataway 192 168 2 1

  实验命令:

  对于二层交换机

  Switch>

  Switch>en

  Switch#conf

  Configuring from terminal, memory, or network [terminal]?

  Enter configuration commands, one per line.  End with CNTL/Z.

  Switch(config)#hostname switch0

  switch0#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.

  switch0(vlan)#vlan 2 name 2

  VLAN 2 modified:

   Name: 2

  switch0(vlan)#vlan 3 name 3

  VLAN 3 added:

   Name: 3

  switch0(vlan)#exit

  APPLY completed.

  Exiting....

  switch0#conf

  Configuring from terminal, memory, or network [terminal]?

  Enter configuration commands, one per line.  End with CNTL/Z.

  switch0(config)#int f0/1

  switch0(config-if)#switchport mode access

  switch0(config-if)#switchport access vlan 2

  switch0(config-if)#exit

  switch0(config)#int f0/3

  switch0(config-if)#switchport mo

  switch0(config-if)#switchport mode a

  switch0(config-if)#switchport mode access

  switch0(config-if)#switchport access vlan 3

  switch0(config-if)#exit

  switch0(config)#int f0/2

  switch0(config-if)#switchport mode trunk

  switch0(config-if)#end

  %SYS-5-CONFIG_I: Configured from console by console

  switch0#copy run star

  Destination filename [startup-config]?

  Building configuration...

  [OK]

  对于三层交换机

  Switch>en

  Switch#

  Switch#conf

  Configuring from terminal, memory, or network [terminal]?

  Enter configuration commands, one per line.  End with CNTL/Z.

  Switch(config)#ip routing

  Switch(config)#interface f0/1

  Switch(config-if)#switchport mode trunk

  Switch(config-if)#end

  %SYS-5-CONFIG_I: Configured from console by console

  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 2 name 2

  VLAN 2 added:

   Name: 2

  Switch(vlan)#vlan 3 name 3

  VLAN 3 added:

   Name: 3

  Switch(vlan)#exit

  APPLY completed.

  Exiting....

  Switch#configure t

  Switch#configure terminal

  Enter configuration commands, one per line.  End with CNTL/Z.

  Switch(config)#int

  Switch(config)#interface vlan 2

  %LINK-5-CHANGED: Interface Vlan2, changed state to up

  %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan2, changed state to upSwitch(config-if)#ip add

  Switch(config-if)#ip address 192.168.1.1 255.255.255.0

  Switch(config-if)#no sh

  Switch(config-if)#no shutdown

  Switch(config-if)#exit

  Switch(config)#int vlan 3

  %LINK-5-CHANGED: Interface Vlan3, changed state to up

  %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan3, changed state to upSwitch(config-if)#ip add 192.168.2.1 255.255.255.0

  Switch(config-if)#no sh

  Switch(config-if)#end

  %SYS-5-CONFIG_I: Configured from console by console

  Switch#copy run star

  Destination filename [startup-config]?

  Building configuration...

  [OK]

  Switch#show ip route

  Codes: C - connected, S - static, I - IGRP, 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, E - EGP

   i - IS-IS, 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, Vlan2

  C    192.168.2.0/24 is directly connected, Vlan3

  测试

  Pinging 192.168.2.2with 32 bytes of data:

  Reply from 192.168.2.1: bytes=32 time=63ms TTL=255

  Reply from 192.168.2.1: bytes=32 time=63ms TTL=255

  Reply from 192.168.2.1: bytes=32 time=63ms TTL=255

  Reply from 192.168.2.1: bytes=32 time=62ms TTL=255

  Ping statistics for 192.168.2.1:

   Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

  Approximate round trip times in milli-seconds:

   Minimum = 62ms, Maximum = 63ms, Average = 62ms

  实验成功。。。

  需要注意的问题

  本次试验中对于三层交换机首先要启动它的路由功能ip routing,否则实验是不能成功的,通过show ip route 我们可以看见路由表是建立起来了的。例外,三层设备必须建立多个vlan,虽然建立的vlan没有划分给具体的某些端口,但是我们在建立vlan虚拟地址的先决条件是必须先有这些vlan的存在的,不知大家注意没有,电脑的网关就是它所属vlan的虚拟ip。


TAG:

 

评分:0

我来说两句

Open Toolbar