如何利用VRF在单台路由器上创建多份路由表

 文章转发于:http://net.zdnet.com.cn/files/all-2081627.htm
 
本文摘要

在本文中,思科认证互联网专家布兰登·卡罗尔将向大家说明,如何利用多虚拟路径转发(VRF)IP技术实现在单台路由器上创建路由表的多种实例。

ZDNET至顶网网络频道 3月2日 编译:在学习过如何对运行思科互联网操作系统(IOS)设备上运行的IP安全协议进行设置后,现在将通过设定使用多虚拟路径转发(VRF)IP技术的方式来进行一次小小的实验。在某些需要在单台路由器上建立多份路由表的案例下,这种方法非常有用。接下来,首先将对什么是VRF技术进行详细的介绍,并且还会对如何进行具体配置作出说明。


  什么是多虚拟路径转发?

  对于希望在路由器上配置多份路由表的用户来说,VRF是一种不错的选择。它的功能就是在同一设备上实现隔离路由控制客户流量的效果。不过,也许有人可能会更喜欢,使用子接口或者不同的物理接口来对客户进行分割,并利用访问控制列表过滤来实现流量分离的方法。确实,这肯定属于一种行之有效的方法;但是,如果处于某种原因需要对客户地址进行重叠处理的话,它就会面临着一个严重的问题。而利用VRF,路由器就可以实现在同时将相同IP地址分配给两个不同接口的效果。

  最近,我就遇到了这样的情况。在开展培训的时间,我建立了一个包括八个单独部分的实验环境,并且它们都采用了相同的拓扑结构和相同的地址。基本的拓扑结构如图A所示:

  

如何利用VRF在单台路由器上创建多份路由表

  现在看来,即便拓扑结构非常简单,我依然需要机械地进行七次重复设置。毕竟,本质上我还是希望每个部分都可以成为一位独立的用户。因此,我决定选择利用路由器来进行隔离处理。这时,第一步要做的工作就是建立VRF。

  创建VRF

ip vrf POD1
 rd 1:1
!
ip vrf POD2
 rd 2:2
!
ip vrf POD3
 rd 3:3
!
ip vrf POD4
 rd 4:4
!
ip vrf POD5
 rd 5:5
!
ip vrf POD6
 rd 6:6
!
ip vrf POD7
 rd 7:7
!
ip vrf POD8
 rd 8:8
!

  完成了上述配置的设定后,现有路由器就变成了八台独立的路由器。大家注意,这里有一点非常重要,就是只有设置了rd或者Route Distinguisher的参数后,才能容许IP地址重叠。因此,在路由器中的所有地址才会被利用RD来进行标记;在这里,采取的格式就是IP地址:rd。它属于一个本地设定参数。

  接下来我们要做的就是为每一个接口配备一份VRF:

interface FastEthernet0/0.1
 encapsulation dot1Q 201
 ip vrf forwarding POD1
 ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0.2
 encapsulation dot1Q 202
 ip vrf forwarding POD2
 ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0.3
 encapsulation dot1Q 203
 ip vrf forwarding POD3
 ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0.4
 encapsulation dot1Q 204
 ip vrf forwarding POD4
 ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0.5
 encapsulation dot1Q 205
 ip vrf forwarding POD5
 ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0.6
 encapsulation dot1Q 206
 ip vrf forwarding POD6
 ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0.7
 encapsulation dot1Q 207
 ip vrf forwarding POD7
 ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0.8
 encapsulation dot1Q 208
 ip vrf forwarding POD8
 ip address 192.168.1.1 255.255.255.0
!
!
interface FastEthernet0/1.1
 encapsulation dot1Q 211
 ip vrf forwarding POD1
 ip address 172.26.26.53 255.255.255.0 secondary
 ip address 172.26.26.1 255.255.255.0
!
interface FastEthernet0/1.2
 encapsulation dot1Q 212
 ip vrf forwarding POD2
 ip address 172.26.26.53 255.255.255.0 secondary
 ip address 172.26.26.1 255.255.255.0
!
interface FastEthernet0/1.3
 encapsulation dot1Q 213
 ip vrf forwarding POD3
 ip address 172.26.26.53 255.255.255.0 secondary
 ip address 172.26.26.1 255.255.255.0
!
interface FastEthernet0/1.4
 encapsulation dot1Q 214
 ip vrf forwarding POD4
 ip address 172.26.26.53 255.255.255.0 secondary
 ip address 172.26.26.1 255.255.255.0
!
interface FastEthernet0/1.5
 encapsulation dot1Q 215
 ip vrf forwarding POD5
 ip address 172.26.26.53 255.255.255.0 secondary
 ip address 172.26.26.1 255.255.255.0
!
interface FastEthernet0/1.6
 encapsulation dot1Q 216
 ip vrf forwarding POD6
 ip address 172.26.26.53 255.255.255.0 secondary
 ip address 172.26.26.1 255.255.255.0
!
interface FastEthernet0/1.7
 encapsulation dot1Q 217
 ip vrf forwarding POD7
 ip address 172.26.26.53 255.255.255.0 secondary
 ip address 172.26.26.1 255.255.255.0
!
interface FastEthernet0/1.8
 encapsulation dot1Q 218
 ip vrf forwarding POD8
 ip address 172.26.26.53 255.255.255.0 secondary
 ip address 172.26.26.1 255.255.255.0

  为了确保路由现在都是独立的,我们可以选择从VRF的角度查看路由表。

  首先就是第一部分:

BBR#show ip route vrf POD1
Routing Table: POD1
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
     172.26.0.0/24 is subnetted, 1 subnets
C       172.26.26.0 is directly connected, FastEthernet0/1.1
     10.0.0.0/24 is subnetted, 2 subnets
S       10.0.1.0 [1/0] via 192.168.1.2
C       10.0.100.0 is directly connected, Loopback201
C    192.168.1.0/24 is directly connected, FastEthernet0/0.1
BBR#

  为了确认到每个接口对应的VRF都是什么,我们现在可以利用show ip vrf brief命令来获取相关信息。

BBR#sh ip vrf brief
  Name                             Default RD          Interfaces
  POD1                             1:1                 Lo201
                                                       Fa0/0.1
                                                       Fa0/1.1
  POD2                             2:2                 Lo202
                                                       Fa0/0.2
                                                       Fa0/1.2
  POD3                             3:3                 Lo203
                                                       Fa0/0.3
                                                       Fa0/1.3
  POD4                             4:4                 Lo204
                                                       Fa0/0.4
                                                       Fa0/1.4
  POD5                             5:5                 Lo205
                                                       Fa0/0.5
                                                       Fa0/1.5
  POD6                             6:6                 Lo206
                                                       Fa0/0.6
                                                       Fa0/1.6
  POD7                             7:7                 Lo207
                                                       Fa0/0.7
                                                       Fa0/1.7
  POD8                             8:8                 Lo208
                                                       Fa0/0.8
                                                       Fa0/1.8
BBR#

  当然,还有很多其它命令可以用来验证VRF;但正如我们所看到的,只有这样才能将路由器用VRF分拆为八个部分。在以后的文章中,我还将会对如何利用VRF对IP安全协议进行相同步骤的设置进行介绍。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值