BOOTCAMP之把一台路由器虚拟出多台路由器-VRF技术
一般我们在自己做试验的时候出于成本的考虑,都尽可能的买少的路由器来实现更多的功能。
下面就介绍一个方法把一个路由器当两个路由器用。即VRF技术。
物理拓朴如图上部分所示,配置完成后的逻辑拓朴如图下部分所示。
物理上Router1和Router2有两条以太连接,分别接FE0/0和FE1/0,完成后把Router1虚拟为RouterA和RouterB,分别连Router2的FE0/0和FE1/0。
RouterA和Router2启用OSPF路由协议,RouterB和Router2启用RIP路由协议,Router2配置路由再分发。
第一步:配置Router1虚拟出RouterA和RouterB
虚拟Router A ! ip vrf routera
rd 100:100
route-target export 100:100
route-target import 100:100 ! interface Loopback0
ip vrf forwarding routera
ip address 10.10.10.1 255.255.255.255 ! interfaceFastEthernet0/0 ip vrf forwarding routera ip address 192.168.1.1 255.255.255.0 no shutdown
! 注意:首先配置VRF然后应用,然后配置IP地址
虚拟Router B !
ip vrf routerb
rd 200:300
route-target export 200:300 route-target import 200:300 ! interface Loopback1 ip vrf forwarding routerb ip address 30.30.30.1 255.255.255.255 ! interfaceFastEthernet1/0 ip vrf forwarding routerb ip address 192.168.2.1 255.255.255.0 no shutdown
! 第二步:配置路由协议 2.1配置VRF路由
以下是在Router1上的相关配置
RouterA启用OSPF
!
router ospf 100 vrf routera
network 192.168.1.0 0.0.0.255 area 100 network 10.10.10.0 0.0.0.255 area 100
!
RouterB启用RIP
!
router rip
!
address-family ipv4 vrf routerb
network 30.0.0.0
network 192.168.2.0 version 2
no auto-summary
exit-address-family
!
2.2配置普通路由及路由重分布
在R2上启用OSPF和RIP并且配置互相再分发 !
interface Loopback0
ip address 20.20.20.1 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.2 255.255.255.0
no shutdown
!
interface FastEthernet0/1
ip address 192.168.2.2 255.255.255.0
no shutdown
!
router ospf 100
redistribute rip metric 100 metric-type 1 subnets
network 20.20.20.0 0.0.0.255 area 100
network 192.168.1.0 0.0.0.255 area 100
!
router rip
version 2
redistribute ospf 100 metric 8
network 192.168.2.0
no auto-summary
!
第三步:验证测试
使用下列命令验证:
Router1:
sh ip route vrf routera 验证虚拟RouterA的路由表
sh ip route vrf routerb 验证虚拟RouterB的路由表
结果如下:
R1# show ip route vrf routera
Gateway of last resort is not set
20.0.0.0/32 is subnetted, 1 subnets
O 20.20.20.1 [110/2] via 192.168.1.2, 00:04:43, FastEthernet0/0
10.0.0.0/32 is subnetted, 1 subnets
C 10.10.10.1 is directly connected, Loopback0
C 192.168.1.0/24 is directly connected, FastEthernet0/0
O E1 192.168.2.0/24 [110/101] via 192.168.1.2, 00:04:43, FastEthernet0/0
30.0.0.0/32 is subnetted, 1 subnets
O E1 30.30.30.1 [110/101] via 192.168.1.2, 00:04:43, FastEthernet0/0
R1# show ip route vrf routerb
Gateway of last resort is not set
20.0.0.0/32 is subnetted, 1 subnets
R 20.20.20.1 [120/8] via 192.168.2.2, 00:00:18, FastEthernet0/1
10.0.0.0/32 is subnetted, 1 subnets
R 10.10.10.1 [120/8] via 192.168.2.2, 00:00:18, FastEthernet0/1
R 192.168.1.0/24 [120/8] via 192.168.2.2, 00:00:18, FastEthernet0/1
C 192.168.2.0/24 is directly connected, FastEthernet0/1
30.0.0.0/32 is subnetted, 1 subnets
C 30.30.30.1 is directly connected, Loopback1
R2# show ip route
Gateway of last resort is not set
20.0.0.0/32 is subnetted, 1 subnets
C 20.20.20.1 is directly connected, Loopback0
10.0.0.0/32 is subnetted, 1 subnets
O 10.10.10.1 [110/2] via 192.168.1.1, 00:05:41, FastEthernet0/0
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet0/1
30.0.0.0/32 is subnetted, 1 subnets
R 30.30.30.1 [120/1] via 192.168.2.1, 00:00:09, FastEthernet0/1
R2#
注意,在VRF模式下,telnet、ping和trace需要添加相应的VRF路由器名称,
如Ping vrf routera x.x.x.x,trace vrf routerb x.x.x.x等。
VRF虚拟路由器的学习,对于MPLS VPN的来说,是很重要的基础。
通过VRF的学习,也能够较好的理解当下的很多虚拟设备的应用,如Juniper的虚拟路由器概念,
Cisco的虚拟防火墙概念,Redback的虚拟网关路由器概念等。
|