
ip vrf BLUE
!
ip vrf RED
!
ip vrf YELLOW
!
interface GigabitEthernet0/1
ip vrf forwarding RED
ip address 192.168.2.1 255.255.255.0
!
interface GigabitEthernet0/2
ip vrf forwarding YELLOW
ip address 192.168.2.2 255.255.255.0
!
interface GigabitEthernet0/3
ip vrf forwarding BLUE
ip address 172.16.2.1 255.255.255.0
!
interface GigabitEthernet0/0
no shutdown
!
interface GigabitEthernet0/0.10
encapsulation dot1Q 10
ip vrf forwarding RED
ip address 10.12.1.2 255.255.255.0
!
interface GigabitEthernet0/0.20
encapsulation dot1Q 20
ip vrf forwarding YELLOW
ip address 10.12.2.2 255.255.255.0
!
interface GigabitEthernet0/0.30
encapsulation dot1Q 30
ip vrf forwarding BLUE
ip address 10.12.3.2 255.255.255.0
!

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

在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

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


在VRF上配置OSPF
- 课程48:43,OSPF 懒人配置方法不是 0.0.0.0 255.255.255.255 area 0 么,为什么0.0.0.0 0.0.0.0 也能生效
- 配置
router bgp 65200
no bgp default ipv4-unicast
!
address-family ipv4 vrf BLUE
bgp router-id auto-assign
neighbor 10.12.3.1 remote-as 65100
neighbor 10.12.3.1 activate
neighbor 10.23.3.3 remote-as 65300
neighbor 10.23.3.3 activate
exit-address-family

在VRF上配置BGP
- 需要先配置RD,否则报错。配置RD是在vrf下:rd 100:100

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

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

在VRF上配置EIGRP
- EIGRP 只能使用Named模式,Classic 模式不支持VRF
router eigrp R1_EIGRP
!
address-family ipv4 unicast vrf GREEN autonomous-system 100
!
topology base
exit-af-topology
network 4.4.4.41 0.0.0.0
network 10.12.4.0 0.0.0.255
exit-address-family
