实验01 - VRF Lite - 图1

  • 配置接口和VRF
  • 配置sub-interface
  1. ip vrf BLUE
  2. !
  3. ip vrf RED
  4. !
  5. ip vrf YELLOW
  6. !
  7. interface GigabitEthernet0/1
  8. ip vrf forwarding RED
  9. ip address 192.168.2.1 255.255.255.0
  10. !
  11. interface GigabitEthernet0/2
  12. ip vrf forwarding YELLOW
  13. ip address 192.168.2.2 255.255.255.0
  14. !
  15. interface GigabitEthernet0/3
  16. ip vrf forwarding BLUE
  17. ip address 172.16.2.1 255.255.255.0
  18. !
  19. interface GigabitEthernet0/0
  20. no shutdown
  21. !
  22. interface GigabitEthernet0/0.10
  23. encapsulation dot1Q 10
  24. ip vrf forwarding RED
  25. ip address 10.12.1.2 255.255.255.0
  26. !
  27. interface GigabitEthernet0/0.20
  28. encapsulation dot1Q 20
  29. ip vrf forwarding YELLOW
  30. ip address 10.12.2.2 255.255.255.0
  31. !
  32. interface GigabitEthernet0/0.30
  33. encapsulation dot1Q 30
  34. ip vrf forwarding BLUE
  35. ip address 10.12.3.2 255.255.255.0
  36. !

实验01 - VRF Lite - 图2

  • 创建VRF后,原先依赖全局路由表的命令,必须显式地指明使用哪个路由表

实验01 - VRF Lite - 图3

在VRF上配置静态路由

  • 在VRF RED上配置默认路由,可以看到路由只出现在了VRF RED路由表中,也说明了VRF 是相互隔离的。对称地,在R3 上也创建默认路由
    • R1、R3 上配置默认路由
    • R2上配置具体的静态路由
    • R2(config)#ip route vrf RED 192.168.1.0 255.255.255.0 10.12.1.1
    • R2(config)#ip route vrf RED 192.168.2.0 255.255.255.0 10.23.1.3

实验01 - VRF Lite - 图4

  • 此时从VPC_RED_1 和 VPC_RED_2 已相互可达

实验01 - VRF Lite - 图5

实验01 - VRF Lite - 图6

在VRF上配置OSPF

  • 课程48:43,OSPF 懒人配置方法不是 0.0.0.0 255.255.255.255 area 0 么,为什么0.0.0.0 0.0.0.0 也能生效
  • 配置
  1. router bgp 65200
  2. no bgp default ipv4-unicast
  3. !
  4. address-family ipv4 vrf BLUE
  5. bgp router-id auto-assign
  6. neighbor 10.12.3.1 remote-as 65100
  7. neighbor 10.12.3.1 activate
  8. neighbor 10.23.3.3 remote-as 65300
  9. neighbor 10.23.3.3 activate
  10. exit-address-family

实验01 - VRF Lite - 图7

在VRF上配置BGP

  • 需要先配置RD,否则报错。配置RD是在vrf下:rd 100:100

实验01 - VRF Lite - 图8

  • 配置
    • router-id 获取方式 必须手动配置,即使是指定 auto-assign —— 看起来指定 auto-assign 之后也还是会有提示
    • router-id 可以在bgp 进程下全局配置1个,也可以在每个vrf 下单独配置
    • 另外这里的定义remote-as 和 激活是在一起的,不像标准配置 remote-as 是在bgp,而激活是在 address family
  1. router bgp 65100
  2. bgp log-neighbor-changes
  3. no bgp default ipv4-unicast
  4. !
  5. address-family ipv4 vrf BLUE
  6. bgp router-id auto-assign
  7. redistribute connected
  8. neighbor 10.12.3.2 remote-as 65200
  9. neighbor 10.12.3.2 activate
  10. exit-address-family
  • 在R2查看BGP 邻居: show bgp vrf BLUE vpnv4 unicast summary

实验01 - VRF Lite - 图9

  • 在R1查看BGP 路由条目: show bgp vrf BLUE vpnv4 unicast

实验01 - VRF Lite - 图10

在VRF上配置EIGRP

  • EIGRP 只能使用Named模式,Classic 模式不支持VRF
  1. router eigrp R1_EIGRP
  2. !
  3. address-family ipv4 unicast vrf GREEN autonomous-system 100
  4. !
  5. topology base
  6. exit-af-topology
  7. network 4.4.4.41 0.0.0.0
  8. network 10.12.4.0 0.0.0.255
  9. exit-address-family

实验01 - VRF Lite - 图11