Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3175147
  • 博文数量: 39
  • 博客积分: 10067
  • 博客等级: 上将
  • 技术积分: 4018
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-03 15:39
文章分类

全部博文(39)

文章存档

2011年(2)

2009年(3)

2008年(34)

分类: 系统运维

2008-04-15 09:04:38

Section I. 路由器IRB特性介绍及配置实例

 

本文描述了路由器上VLAN的扩展应用。这种扩展应用体现在路由器运行IP路由、IP桥接及IP桥接与综合路由和桥接(IRB)协同作用的时候。同时本文接供了一个在路由器上配置IRB特性的例子。

 

背景资料

 

为了使VLAN跨越路由器,路由器必须有能力把帧从一个接口转发到另一个接口,同时又要维持VLAN头部信息。如果路由器配置成三层(网络层)协议路由,它就会在帧到达的接口上终结VLANMAC层。如果路由器桥接网络层协议,MAC层头部信息就能保留下来。但是,传统的桥接仍然会终结VLAN的头部信息。利用Cisco IOS 11.2或更高版本的IRB特性,路由器可以配置成在相同的接口上路由及桥接网络协议。这样,当帧从一个接口穿越到另一个接口时,VLAN的头部信息仍可保留。

 

 

 

IRB的路由与桥接概念

 

上图中:两台交换机的vlan id是一样的,但它们实际上不是同一个vlan.

 

本图也描述了从PCA穿越链路到达PCB的数据帧的三层帧头的流程。

 

当帧流过交换机时,VLAN头被加上去了因为连接的是一个trunk链路。可能有好几个vlan穿过这个trunk进行通信。

 

路由器终结VLAN层及MAC层。它检查目标IP地址然后正确地转发这个帧。在这个例子中,IP帧将被从与PCB相连的端口转发出去。这也是一个VLAN trunk所以同样也会加上一个VLAN头。

 

虽然连接交换机2到路由器的VLAN号与连接交换机1到路由器的VLAN号是一样的,它实际上不是相同的VLAN。当帧到达路由器时原始VLAN头就被除去了。当帧离开路由器时,一个新头可能被加上去。这个新头可能包含一个与帧到达路由器时剥离掉的VLAN头一样的VLAN号。这一点被如下实事证明:当一个IP帧通过路由器时是没有附加VLAN头的,它是基于目标地址转发而不是VLAN号。

 

因为这两个VLAN trunk分别位路由器不同的两边,所以它们必须属于不同的IP网络段。

 

为了让这两个PC拥有相同的网段,路由器必须在它的接口上桥接IP。然而,让两个VLAN中的设备拥有相同的网段并不意谓着它们属于相同的VLAN

 

下图显示VLAN拓扑:

 

 

通过在路由器上一些或所有连接VLAN的接口上桥接IP,避免了终端设备的IP地址的重新编址。但这么一来就失去了在网络层上的基于路由器控制广播流量的所有好处。图三显示当路由器配置成桥接IP后所产生的变化。图四显示当路由器配置成用IRP桥接IP后所发生的变化。

 

图三显示路由器现在是IP桥接的。两台PC处于相同的网段。

 

注意:路由器(桥)现在转发MAC层头穿过出口接口。路由器仍然终结VLAN头,同时在发送帧到PCB之前加上一个新头。

 

图四显示IRB配置后发生了什么。VLAN现在跨越了路由器,并且当帧穿越路由器时VLAN头被保留下来。

 

IRB配置实例

 

这是一个IRB的配置实例。这个配置允许在两个以太口之间桥接IP,路由IP则使用一个桥接虚拟接口(BVI)。在下面的网络图中,当PCA试图连络PCB时,路由器R1检查到目标IP地址(PCB)是在同一网段,于是数据包被路由器R1E0桥接到E1,而数据包是由BVI进行路由的。这样,IP协议在路由器既桥接又路由了。

 

 

 

Current configuration:

!

version 12.0

service timestamps debug uptime

service timestamps log uptime

no service password-encryption

!

hostname R1

!

!

ip subnet-zero

no ip domain-lookup

bridge irb

 

!-- This command enables the IRB feature on this router.

 

!

!

!

interface Ethernet0

no ip address

no ip directed-broadcast

bridge-group 1

 

!-- The interface E0 is in bridge-group 1.

 

!

Interface Ethernet1

no ip address

no ip directed-broadcast

bridge-group 1

 

!-- The interface E1 is in bridge-group 1.

 

!

Interface Serial0

ip address 10.10.20.1 255.255.255.0

no ip directed-broadcast

no ip mroute-cache

no fair-queue

!

interface Serial1

no ip address

no ip directed-broadcast

shutdown

!

interface BVI1

ip address 10.10.10.1 255.255.255.0

 

!-- An ip address is assigned to the logical BVI for routing

 

 

!-- IP between bridged interfaces and routed interfaces.

 

no ip directed-broadcast

!

ip classless

ip route 10.10.30.0 255.255.255.0 10.10.20.2

!

bridge 1 protocol ieee

 

!-- This command enables the bridging on this router.

 

bridge 1 route ip

 

!-- This command enable bridging as well routing for IP protocol.

 

!

line con 0

transport input none

line aux 0

line vty 0 4

!

end

show interfaces [interface] irb

This command displays the protocols that can be routed or bridged for the specified interface, as follows:

R1#show interface e0 irb

 

Ethernet0

 

Routed protocols on Ethernet0:

ip

   

Bridged protocols on Ethernet0:

ip         ipx

 

!-- IP protocol is routed as well as bridged.

 

 

Software MAC address filter on Ethernet0

 Hash Len    Address      Matches  Act      Type

 0x00:  0 ffff.ffff.ffff     0     RCV  Physical broadcast

 0x2A:  0 0900.2b01.0001     0     RCV  DEC spanning tree

 0x9E:  0 0000.0c3a.5092     0     RCV  Interface MAC address

 0x9E:  1 0000.0c3a.5092     0     RCV  Bridge-group Virtual Interface

 0xC0:  0 0100.0ccc.cccc    157    RCV  CDP

 0xC2:  0 0180.c200.0000     0     RCV  IEEE spanning tree

 0xC2:  1 0180.c200.0000     0     RCV  IBM spanning tree

R1#

 

 

 

Section II. Cisco IRB BVI

 

Cisco路由器提供集成的路由与桥接(Integrated Routing and Bridging,IRB)功能。当配置了IRB后,不可路由的协议数据流可以在配置为相同网桥组的端口上实现桥接交换,同时可以路由的协议数据流则在其他的路由端口或不同的网桥组之间实现路由。

  这里提到了一个概念,即网桥组(Bridge-Group)。要实现不同的端口之间的桥接交换,必须将这些端口归到同一个网桥组当中。从概念上说,配置为同一个网桥组中的所有端口属于同一个第二层的广播域,不管这个端口类型是广域网端口还是以太网端口,也不管这个端口是物理端口还是逻辑端口(如X.25的子口或以太网的VLAN子口)。Cisco路由器为每一个已配置的网桥组自动产生一个虚拟接口,称之为Beidge-Group Virtual Interface(BVI),在不同的BVI之间或BVI与其它的端口之间可以实现路由的能力。下面说明BVI的主要概念和IRB的配置任务。
 
 
SW1
 
switch#conf t
switch(config)#vlan 2
switch(config-vlan)#exit
switch(config)#interface fastethernet0/1
switch(config-if)#switchport mode access
switch(config-if)#switchport access vlan 1
switch(config-if)#interface fastethernet 0/2
switch(config-if)#switchport mode access
switch(config-if)#switchport access vlan 2
switch(config-if)#interface fastethernet 0/24
switch(config-if)#encapsulation dot1q
switch(config-if)#switchport mode trunk
 
SW2
switch#configure terminal
switch(config)#vlan 2
switch(config-vlan)#exit
switch(config)#interface fastethernet 0/1
switch(config-if)#switchport mode access
switch(config-if)#switchport access vlan 1
switch(config-if)#interface fastethernet 0/2
switch(config-if)#switchport mode access
switch(config-if)#switchport accesss vlan 2
switch(config-if)#interface fastethernet 0/24
switch(config-if)#encapsulation isl
switch(config-if)#switchport mode trunk
 
R1
 
router#configure terminal
router(config)#interface fastethernet 0/0
router(config-if)#no shut
router(config-if)#interface fastethernet 0/0.1
router(config-subif)#encapsulation dot1q 1
router(config-subif)#bridge-group 1
router(config-subif)#interface fastethernet 0/0.2
router(config-subif)#encapsultion dot1q 2
router(config-subif)#bridge-group 2
router(config-subif)#exit
router(config-if)#interface fastetherent 0/1
router(config-if)#no shut
router(config-if)#interface fastethernet 0/1.1
router(config-subif)#encapsulation isl 1
router(config-subif)#brdige group 1
router(config-subif)#interface fastethernet 0/1.2
router(config-subif)#encapsulation isl 2
router(config-subif)#brdige group 2
router(config-subif)#exit
router(config-if)#exit
router(config)# bridge irb
router(config)#bridge 1 protocol ieee
router(config)#bridge 2 protocol ieee
router(config)#bridge 1 route ip
router(config)#brdige 2 route ip
router(config)#int bvi 1
router(config-if)#ip add 192.168.1.254 255.255.255.0
router(config-if)#int bvi 2
router(config-if)#ip add 192.168.2.254 255.255.255.0
 
 
 
Section III. 实验-子接口桥接
 

    实验中的IP划分:
   SW1 VLAN 2  192.168.2.250     VLAN 3    192.168.2.250
   SW2 VLAN 2  192.168.2.249     VLAN 3    192.168.2.249
   R1  bvi  1  192.168.2.251     bvi  2    192.168.3.251
   R2  bvi  1  192.168.2.248     bvi  2    192.168.3.248
       HSRP 2  192.168.2.254     HSRP 3    192.168.3.254
  
一。实验目的
    了解桥接的作用:桥接”,是指依据OSI网络模型的链路层的地址,对网络数据包进行转发的过程。当路由器配置了桥接选项后,会处理所有接口上的所有的数据帧,并实时调查每个主机的位置。若在某个接口上收入一个帧,就会在一个桥接内置入一个条目,列出发送数据的主机和接收到数据帧的接口MAC地址,这样路由表就被不断地在通信中完善起来。
参考:


二。实验内容
    1。在实验中,我们使用的是二层交换机,通过路由器来实现VLAN之间的路由
       在E0/0 E0/1下面划分子接口
       int e0/0.1         int e0/0.2
       en dot1q 2         en dot1q 3   分别封装VLAN 2 VLAN 3
    2。因为在同一物理接口不能配置同一网段的IP地址,我们要通过桥接组来实现子接口之间的桥接
       int e0/0.1            int e0/1.1
       bridge-group 1        bridge-group 2  建立两个桥接组
    3。这只是简单的两层桥接,要实现三层桥接,我们要给桥接组配置IP地址
       int bvi 1                              int bvi 2
       ip add 192.168.2.1 255.255.255.0       ip add 192.168.3.1 255.255.255.0
       两个组分别使用VLAN2 与VLAN 3的网段,这样可以实现VLAN之间的路由
    4。为了完成VLAN之间的路由,所有橙色线路的端口为trunk
       switchport mode truck
       switchport truck en do
    5。所有PC接入端号使作protfast 端口,接到收敛速成度
       spanning-stree protfast
    6。为了终端PC的安全,我们可以采用热备份协议,实现网关冗余
        R1: int bvi 1                              int bri 2
            standy 1 ip 192.168.2.254              standy 2 ip 192.168.3.254
            standy 1 pree                          standy 2 pree    开启抢占
       R2: int bvi 1
            standy 1 ip 192.168.2.254              standy 2 ip 192.168.3.254
            standy 1 pree                          standy 2 pree    开启抢占
            standy 1 pri 50 让R1成为VLAN 1主网关   standy 2 pri 200 让R2成为VLAN 2的主网关
       在第6中,我们分别分R1与R2成为VLAN 1与VLAN 2的主,彼此之间成为备份,使得网络更可靠
    7。ISP与本地路由器之间采用路由协议,可以实现负载均衡
在实验中用到如下命令:
   bridge 1 protocol ieee 封装协议
   birdge 1 route ip     支持IP路由
  birdge irb             将桥接接口集成路由功能

二。实验配置
    这个实验中,主要是难点是子接口的路由桥接,但这个设计早以最淘汰了,我们可以在三层路由来实现上面的功能 。另一个知识点就是为这个VLAN 建立备份网关,我们可以采用HSRP VRRP GLBP协议来实现
 
三.配置
R1-up#sh run
Building configuration...
Current configuration : 1119 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1-up
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
ip subnet-zero
!
!
!
ip cef
bridge irb
!
!
!
interface Loopback1
 ip address 1.1.1.1 255.255.255.0
!
interface Ethernet0/0
 no ip address
 half-duplex
!
interface Ethernet0/0.1
 encapsulation dot1Q 2
 bridge-group 1
!
interface Ethernet0/0.2
 encapsulation dot1Q 3
 bridge-group 2
!
interface Serial0/0
 ip address 10.1.1.1 255.255.255.0
 no fair-queue
!
interface Ethernet0/1
 no ip address
 half-duplex
!
interface Ethernet0/1.1
 encapsulation dot1Q 2
 bridge-group 1
!
interface Ethernet0/1.2
 encapsulation dot1Q 3
 bridge-group 2
!
interface BVI1
 ip address 192.168.2.251 255.255.255.0
 standby 1 ip 192.168.2.1
 standby 1 preempt
!
interface BVI2
 ip address 192.168.3.251 255.255.255.0
 standby 2 ip 192.168.3.1
!
ip http server
ip classless
!
!
!
!
bridge 1 protocol ieee
bridge 1 route ip
bridge 2 protocol ieee
bridge 2 route ip
!
!
!
!
line con 0
line aux 0
line vty 0 4
 login
!
!
end

R2-down#sh run
Building configuration...
Current configuration : 1173 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R2-down
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
ip subnet-zero
ip cef
!
!
!
ip audit po max-events 100
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
bridge irb
!
!
!
interface Ethernet0/0
 no ip address
 half-duplex
!
interface Ethernet0/0.1
 encapsulation dot1Q 2
 bridge-group 1
!
interface Ethernet0/0.2
 encapsulation dot1Q 3
 bridge-group 2
!
interface Serial0/0
 no ip address
 shutdown
 no fair-queue
!
interface Ethernet0/1
 no ip address
 half-duplex
!
interface Ethernet0/1.1
 encapsulation dot1Q 2
 bridge-group 1
!
interface Ethernet0/1.2
 encapsulation dot1Q 3
 bridge-group 2

!
interface BVI1
 ip address 192.168.2.248 255.255.255.0
 standby 1 ip 192.168.2.1
 standby 1 priority 50
 standby 1 preempt
//桥接组1 并启用了HSRP
!
interface BVI2
 ip address 192.168.3.248 255.255.255.0
 standby 2 ip 192.168.3.1
 standby 2 priority 200
 standby 2 preempt
//桥接组2 并启用了HSRP
!
ip http server
no ip http secure-server
ip classless
!
!
!
bridge 1 protocol ieee
bridge 1 route ip
bridge 2 protocol ieee
bridge 2 route ip
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
!
!
end
 
 
Sw1-up#sh run
Building configuration...
Current configuration:
!
version 12.0
no service pad
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname Sw1-up
!
!
!
!
!
!
!
ip subnet-zero
!
!
!
interface FastEthernet0/1
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/2
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/3
!
interface FastEthernet0/4
!
interface FastEthernet0/5
!
interface FastEthernet0/6
!
interface FastEthernet0/7
!
interface FastEthernet0/8
!
interface FastEthernet0/9
!
interface FastEthernet0/10
 switchport access vlan 2
 spanning-tree portfast
!
interface FastEthernet0/11
!
interface FastEthernet0/12
!
interface VLAN1
 no ip directed-broadcast
 no ip route-cache
!
interface VLAN2
 ip address 192.168.2.250 255.255.255.0
 no ip directed-broadcast
 no ip route-cache
!
interface VLAN3
 ip address 192.168.3.250 255.255.255.0
 no ip directed-broadcast
 no ip route-cache
!
!
line con 0
 transport input none
 stopbits 1
line vty 0 4
 login
line vty 5 15
 login
!
end
Sw1-up#
 
Sw2-down#sh run
Building configuration...
Current configuration:
!
version 12.0
no service pad
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname Sw2-down
!
!
!
!
!
!
!
ip subnet-zero
!
!
!
interface FastEthernet0/1
 
switchport trunk encapsulation dot1q
 switchport mode trunk
 spanning-tree portfast
!
interface FastEthernet0/2
 switchport trunk encapsulation dot1q
 switchport mode trunk
 spanning-tree portfast
!
interface FastEthernet0/3
 spanning-tree portfast
!
interface FastEthernet0/4
 spanning-tree portfast
!
interface FastEthernet0/5
 spanning-tree portfast
!
interface FastEthernet0/6
 spanning-tree portfast
!
interface FastEthernet0/7
 spanning-tree portfast
!
interface FastEthernet0/8
 spanning-tree portfast
!
interface FastEthernet0/9
 spanning-tree portfast
!
interface FastEthernet0/10
 spanning-tree portfast
!
interface FastEthernet0/11
 spanning-tree portfast
!
interface FastEthernet0/12
 spanning-tree portfast
!
interface VLAN1
 no ip directed-broadcast
 no ip route-cache
!
interface VLAN2
 ip address 192.168.2.249 255.255.255.0
 no ip directed-broadcast
 no ip route-cache
!
interface VLAN3
 ip address 192.168.3.249 255.255.255.0
 no ip directed-broadcast
 no ip route-cache
!
!
line con 0
 transport input none
 stopbits 1
line vty 0 4
 login
line vty 5 15
 login
!
end
Sw2-down#
 
阅读(8137) | 评论(0) | 转发(0) |
0

上一篇:Voice Vlan详解

下一篇:[Note] pVLAN详解

给主人留下些什么吧!~~