跳到主要内容

3. VRFs - PE 中的多个转发表

3. VRFs: PE 中的多个转发表 (VRFs: Multiple Forwarding Tables in PEs)

每台 PE router 维护若干独立的 forwarding tables. 其中一个 forwarding table 是 "default forwarding table". 其他的是 "VPN Routing and Forwarding tables", 即 "VRFs".

3.1. VRFs 和 Attachment Circuits (VRFs and Attachment Circuits)

每个 PE/CE attachment circuit 都通过配置与一个或多个 VRFs 关联. 与某个 VRF 关联的 attachment circuit 称为 "VRF attachment circuit".

在最简单也最典型的情形下, 一个 PE/CE attachment circuit 恰好与一个 VRF 关联. 当通过某个特定 attachment circuit 接收到 IP packet 时, 会在关联的 VRF 中查找其 destination IP address. 该查找结果决定如何路由该 packet. packet 的 ingress PE 用于路由某个特定 packet 的 VRF 称为该 packet 的 "ingress VRF". (还存在 packet 的 "egress VRF" 概念, 位于 packet 的 egress PE; 这将在 Section 5 中讨论.)

如果某个 IP packet 通过未与任何 VRF 关联的 attachment circuit 到达, 则在 default forwarding table 中查找该 packet 的 destination address, 并据此路由该 packet. 按 default forwarding table 转发的 packets 包括来自相邻 P 或 PE routers 的 packets, 以及来自尚未与 VRFs 关联的 customer-facing attachment circuits 的 packets.

直观地说, 可以把 default forwarding table 看作包含 "public routes", 把 VRFs 看作包含 "private routes". 类似地, 可以把 VRF attachment circuits 看作 "private", 把非 VRF attachment circuits 看作 "public".

如果某个特定 VRF attachment circuit 将 site S 连接到 PE router, 则可以通过控制进入对应 VRF 的 routes 集合来限制从 S (经由该 attachment circuit) 的 connectivity. 该 VRF 中的 routes 集合应限制为通向那些至少与 S 有一个共同 VPN 的 sites 的 routes 集合. 这样, 从 S 通过 VRF attachment circuit 发送的 packet 只有当 S' 与 S 位于某个相同 VPN 中时, 才能由 PE 路由到另一个 site S'. 也就是说, 通过 PE routers, 在任何没有共同 VPN 的 VPN sites 对之间阻止通信. 通过不把到 VPN sites 的 routes 放入 default forwarding table, 可以阻止 VPN sites 与非 VPN sites 之间的通信.

如果从 S 到一个或多个 PE routers 有多个 attachment circuits, 则可能有多个 VRFs 可用于路由来自 S 的 traffic. 为了正确限制 S 的 connectivity, 所有这些 VRFs 中都必须存在相同的 routes 集合. 或者, 也可以对来自 S 的不同 attachment circuits 施加不同的 connectivity 限制. 在这种情况下, 与来自 S 的 attachment circuits 关联的一些 VRFs 将包含与其他 VRFs 不同的 routes 集合.

我们允许单个 attachment circuit 与一组 VRFs 关联, 而不是只与单个 VRF 关联. 如果希望将单个 VPN 划分为若干 "sub-VPNs", 每个 sub-VPN 具有不同的 connectivity 限制, 并使用 customer packets 的某些特征从这些 sub-VPNs 中进行选择, 这种方式会很有用. 不过为简单起见, 我们通常会说一个 attachment circuit 与单个 VRF 关联.

3.2. 将 IP 数据包与 VRF 关联 (Associating IP Packets with VRFs)

当 PE router 从 CE device 接收 packet 时, 它必须确定该 packet 是通过哪个 attachment circuit 到达的, 因为这又决定了可用于转发该 packet 的 VRF (或 VRFs 集合). 一般而言, 为了确定 packet 通过哪个 attachment circuit 到达, PE router 会记录 packet 到达的 physical interface, 并且可能还会记录该 packet 的 layer 2 header 的某些方面. 例如, 如果 packet 的 ingress attachment circuit 是 Frame Relay VC, 则可以根据 packet 到达的 physical Frame Relay interface, 以及 packet 的 Frame Relay header 中的 Data Link Connection Identifier (DLCI) field, 确定 attachment circuit 的身份.

虽然 PE 关于某个特定 packet 到达于某个特定 attachment circuit 的结论可能部分由 packet 的 layer 2 header 决定, 但 customer 必须不可能通过写入 header fields 来欺骗 SP, 使其认为一个通过某 attachment circuit 接收的 packet 实际上是通过另一个 attachment circuit 到达的. 在上面的例子中, 尽管 attachment circuit 部分通过检查 Frame Relay header 中的 DLCI field 来确定, 但 customer 不能随意设置该 field. 相反, 它必须被设置为 SP 指定的值, 否则 packet 无法到达 PE router.

在某些情况下, customer 可以将某个特定 site 划分为若干 "virtual sites". SP 可以指定一组特定 VRFs 用于路由来自该 site 的 packets, 并允许 customer 设置 packet 的某些特征, 然后用该特征从该集合中选择特定 VRF.

例如, 每个 virtual site 可以实现为一个 VLAN. SP 和 customer 可以约定, 对从某个特定 CE 到达的 packets, 使用某些 VLAN values 来标识某些 VRFs. 当然, 如果来自该 CE 的 packets 携带不在约定集合中的 VLAN tag values, PE 将丢弃这些 packets. 另一种实现方式是使用 IP source addresses. 在这种情况下, PE 使用从 CE 接收的 packet 中的 IP source address, 连同接收该 packet 的 interface, 将该 packet 分配给某个特定 VRF. 同样, customer 只能从允许其使用的特定 VRFs 集合中选择.

如果希望某个特定 host 位于多个 virtual sites 中, 则该 host 必须针对每个 packet 判断该 packet 与哪个 virtual site 关联. 例如, 它可以通过在不同 VLANs 上发送来自不同 virtual sites 的 packets, 或通过不同 network interfaces 发送这些 packets 来做到这一点.

3.3. 填充 VRFs (Populating the VRFs)

VRFs 用什么 routes 集合填充?

举例来说, 令 PE1, PE2 和 PE3 为三台 PE routers, 令 CE1, CE2 和 CE3 为三台 CE routers. 假设 PE1 从 CE1 学到 CE1 site 可达的 routes. 如果 PE2 和 PE3 分别连接到 CE2 和 CE3, 且存在某个 VPN V 包含 CE1, CE2 和 CE3, 则 PE1 使用 BGP 将其从 CE1 学到的 routes 分发给 PE2 和 PE3. PE2 和 PE3 使用这些 routes 来填充它们分别与 CE2 和 CE3 的 sites 关联的 VRFs. 不属于 VPN V 的 sites 的 routes 不会出现在这些 VRFs 中, 这意味着来自 CE2 或 CE3 的 packets 不能被发送到不在 VPN V 中的 sites.

当我们说 PE 从 CE "learning" routes 时, 并不预设任何特定的学习技术. PE 可以通过动态 routing algorithm 学到 routes, 但也可以通过配置这些 routes 来 "learn" routes (即 static routing). (在这种情况下, 说 PE 从 CE "learned" 了这些 routes 或许稍有诗意.)

PEs 还需要从其他 PEs 学到属于给定 VPN 的 routes. 用适当 routes 集合填充 VRFs 的过程在 Section 4 中规定.

如果从某个特定 PE router 到某个特定 site 有多个 attachment circuits, 它们可能全部映射到同一个 forwarding table. 但如果 policy 有要求, 它们也可以映射到不同 forwarding tables. 例如, policy 可能规定来自某 site 的某个特定 attachment circuit 仅用于 intranet traffic, 而来自该 site 的另一个 attachment circuit 仅用于 extranet traffic. (例如, 连接到 extranet attachment circuit 的 CE 可能是 firewall, 而连接到 intranet attachment circuit 的 CE 不是.) 在这种情况下, 这两个 attachment circuits 将与不同 VRFs 关联.

注意, 如果两个 attachment circuits 与同一个 VRF 关联, 则 PE 通过其中一个接收的 packets 能够到达的 destinations 集合, 与 PE 通过另一个接收的 packets 能够到达的 destinations 集合完全相同. 因此, 除非每个 CE 所属的 VPNs 集合与另一个完全相同, 否则两个 attachment circuits 不能与同一个 VRF 关联.

如果某个 attachment circuit 通向一个属于多个 VPNs 的 site, 该 attachment circuit 仍可与单个 VRF 关联, 在这种情况下, 该 VRF 将包含该 site 所属全部 VPNs 的 routes.