第 2 层 VPN 配置示例
以下部分介绍如何在连接到每个站点的提供商边缘 (PE) 路由器上配置第 2 层 VPN 功能:
简单全网状 2 层 VPN 概述
在以下部分中,您将配置一个简单的全网状第 2 层 VPN,该 VPN 跨越三个站点:森尼维尔、奥斯汀和波特兰。每个站点都连接到一个 PE 路由器。每个站点的客户边缘 (客户边缘) 路由器使用帧中继将第 2 层流量传输到 PE 路由器。由于此示例在所有三个站点之间使用全网状拓扑,因此每个站点都需要两个逻辑接口(每个客户边缘路由器一个),但只需一个物理链路即可将每个 PE 路由器连接到每个客户边缘路由器。 图 1 展示了此第 2 层 VPN 的拓扑。
示例
在 PE 路由器上启用 IGP
要允许 PE 路由器在它们之间交换路由信息,您必须在这些路由器上配置内部网关协议 (IGP) 或静态路由。您可以在路由协议进程 (rpd) 的主实例(即层次结构级别) [edit protocols] 上配置 IGP,而不是在第 2 层 VPN 路由实例中(即不在 [edit routing-instances] 层次结构级别)。在 IGP 上开启流量工程。
您以标准方式配置 IGP。此示例不包含此部分配置。
在 PE 路由器之间配置 MPLS LSP 隧道
在此配置示例中,RSVP 用于 MPLS 信令。因此,除了配置 RSVP 之外,还必须创建 MPLS 标签交换路径 (LSP) 来对 VPN 流量进行隧道传输。
在路由器 A 上,启用 RSVP 并配置到路由器 B 的 MPLS LSP 隧道一端。配置 MPLS LSP 时,请使用 interface all 语句包含所有接口。
[edit]
protocols {
rsvp {
interface all;
}
mpls {
interface all;
label-switched-path RouterA-to-RouterB {
to 192.168.37.5;
primary Path-to-RouterB;
}
label-switched-path RouterA-to-RouterC {
to 192.168.37.10;
primary Path-to-RouterC;
}
}
}
在路由器 B 上,启用 RSVP 并配置 MPLS LSP 隧道的另一端。同样,使用语句配置 interface all 接口。
[edit]
protocols {
rsvp {
interface all;
}
mpls {
interface all;
label-switched-path RouterB-to-RouterA {
to 192.168.37.1;
primary Path-to-RouterA;
}
label-switched-path RouterB-to-RouterC {
to 192.168.37.10;
primary Path-to-RouterC;
}
}
}
在路由器 C 上,启用 RSVP 并配置 MPLS LSP 隧道的另一端。同样,使用语句配置 interface all 所有接口。
[edit]
protocols {
rsvp {
interface all;
}
mpls {
interface all;
label-switched-path RouterC-to-RouterA {
to 192.168.37.1;
primary Path-to-RouterA;
}
label-switched-path RouterC-to-RouterB {
to 192.168.37.5;
primary Path-to-RouterB;
}
}
}
在 PE 路由器上配置 IBGP
在 PE 路由器上,使用以下参数配置 IBGP 会话:
-
第 2 层 VPN — 要指示 IBGP 会话用于第 2 层 VPN,请包含该
family l2vpn语句。 -
本地地址 — 语句中的
local-addressIP 地址与在远程 PE 路由器的层次结构级别上在[edit protocols mpls label-switched-path lsp-path-name]语句中to配置的地址相同。第 2 层 VPN 的 IBGP 会话通过此地址运行。 -
邻接方地址 — 包括
neighbor指定相邻 PE 路由器 IP 地址的语句。
在路由器 A 上,配置 IBGP:
[edit]
protocols {
bgp {
import match-all;
export match-all;
group pe-pe {
type internal;
neighbor 192.168.37.5 {
local-address 192.168.37.1;
family l2vpn {
signaling;
}
}
neighbor 192.168.37.10 {
local-address 192.168.37.1;
family l2vpn {
signaling;
}
}
}
}
}
在路由器 B 上,配置 IBGP:
[edit]
protocols {
bgp {
local-address 192.168.37.5;
import match-all;
export match-all;
group pe-pe {
type internal;
neighbor 192.168.37.1 {
local-address 192.168.37.5;
family l2vpn {
signaling;
}
}
neighbor 192.168.37.10 {
local-address 192.168.37.5;
family l2vpn {
signaling;
}
}
}
}
}
在路由器 C 上,配置 IBGP:
[edit]
protocols {
bgp {
local-address 192.168.37.10;
import match-all;
export match-all;
group pe-pe {
type internal;
neighbor 192.168.37.1 {
local-address 192.168.37.10;
family l2vpn {
signaling;
}
}
neighbor 192.168.37.5 {
local-address 192.168.37.10;
family l2vpn {
signaling;
}
}
}
}
}
在 PE 路由器上为第 2 层 VPN 配置路由实例
三个 PE 路由器为第 2 层 VPN 提供服务,因此您需要在每台路由器上配置一个路由实例。对于 VPN,您必须在每个路由实例中定义以下内容:
-
路由识别符,对于 PE 路由器上的每个路由实例必须是唯一的。它用于区分一个 VPN 中的地址和另一个 VPN 中的地址。
-
实例类型
l2vpn,用于将路由器配置为运行第 2 层 VPN。 -
连接到客户边缘路由器的接口。
-
虚拟路由和转发 (VRF) 导入和导出策略,在为同一 VPN 提供服务并用于控制网络拓扑的每台 PE 路由器上都必须相同。除非导入策略仅包含语
then reject句,否则它必须包含对社区的引用。否则,当您尝试提交配置时,提交作将会失败。
在路由器 A 上,为第 2 层 VPN 配置以下路由实例:
[edit]
routing-instances {
VPN-Sunnyvale-Portland-Austin {
instance-type l2vpn;
interface so-6/0/0.0;
interface so-6/0/0.1;
route-distinguisher 100:1;
vrf-import vpn-SPA-import;
vrf-export vpn-SPA-export;
protocols {
l2vpn {
encapsulation-type frame-relay;
site Sunnyvale {
site-identifier 1;
interface so-6/0/0.0 {
remote-site-id 2;
}
interface so-6/0/0.1 {
remote-site-id 3;
}
}
}
}
}
}
在路由器 B 上,为第 2 层 VPN 配置以下路由实例:
[edit]
routing-instances {
VPN-Sunnyvale-Portland-Austin {
instance-type l2vpn;
interface so-6/0/0.2;
interface so-6/0/0.3;
route-distinguisher 100:1;
vrf-import vpn-SPA-import;
vrf-export vpn-SPA-export;
protocols {
l2vpn {
encapsulation-type frame-relay;
site Austin {
site-identifier 2;
interface so-6/0/0.2 {
remote-site-id 1;
}
interface so-6/0/0.3 {
remote-site-id 3;
}
}
}
}
}
}
在路由器 C 上,为第 2 层 VPN 配置以下路由实例:
[edit]
routing-instances {
VPN-Sunnyvale-Portland-Austin {
instance-type l2vpn;
interface so-6/0/0.4;
interface so-6/0/0.5;
route-distinguisher 100:1;
vrf-import vpn-SPA-import;
vrf-export vpn-SPA-export;
protocols {
l2vpn {
encapsulation-type frame-relay;
site Portland {
site-identifier 3;
interface so-6/0/0.4 {
remote-site-id 1;
}
interface so-6/0/0.5 {
remote-site-id 2;
}
}
}
}
}
}
在接口上配置 CCC 封装
您需要为第 2 层 VPN 中运行的每个 PE 路由器到客户边缘路由器接口指定电路交叉连接 (CCC) 封装类型。此封装类型应与路由实例下配置的封装类型匹配。
为路由器 A 上的接口配置以下 CCC 封装类型:
[edit]
interfaces so-6/0/0 {
encapsulation frame-relay-ccc;
unit 0 {
encapsulation frame-relay-ccc;
}
}
interfaces so-6/0/0 {
encapsulation frame-relay-ccc;
unit 1 {
encapsulation frame-relay-ccc;
}
}
为路由器 B 上的接口配置以下 CCC 封装类型:
[edit]
interfaces so-6/0/0 {
encapsulation frame-relay-ccc;
unit 2 {
encapsulation frame-relay-ccc;
}
}
interfaces so-6/0/0 {
encapsulation frame-relay-ccc;
unit 3 {
encapsulation frame-relay-ccc;
}
}
为路由器 C 上的接口配置以下 CCC 封装类型:
[edit]
interface so-6/0/0 {
encapsulation frame-relay-ccc;
unit 4 {
encapsulation frame-relay-ccc;
}
}
interface so-6/0/0 {
encapsulation frame-relay-ccc;
unit 5 {
encapsulation frame-relay-ccc;
}
}
在 PE 路由器上配置 VPN 策略
您必须在每台 PE 路由器上配置 VPN 导入和导出策略,以便它们在其 VRF 表中安装相应的路由,路由器使用这些路由在 VPN 内转发数据包。
在层次结构级别使用[edit policy-options policy-statement policy-statement-name term term-name then]该community add community-name 语句来促进第 2 层 VPN VRF 导出策略。
在路由器 A 上,配置以下 VPN 导入和导出策略:
[edit]
policy-options {
policy-statement match-all {
term acceptable {
then accept;
}
}
policy-statement vpn-SPA-export {
term a {
then {
community add SPA-com;
accept;
}
}
term b {
then reject;
}
}
policy-statement vpn-SPA-import {
term a {
from {
protocol bgp;
community SPA-com;
}
then accept;
}
term b {
then reject;
}
}
community SPA-com members target:69:100;
}
在路由器 B 上,配置以下 VPN 导入和导出策略:
[edit]
policy-options {
policy-statement match-all {
term acceptable {
then accept;
}
}
policy-statement vpn-SPA-import {
term a {
from {
protocol bgp;
community SPA-com;
}
then accept;
}
term b {
then reject;
}
}
policy-statement vpn-SPA-export {
term a {
then {
community add SPA-com;
accept;
}
}
term b {
then reject;
}
}
community SPA-com members target:69:100;
}
在路由器 C 上,配置以下 VPN 导入和导出策略:
[edit]
policy-options {
policy-statement match-all {
term acceptable {
then accept;
}
}
policy-statement vpn-SPA-import {
term a {
from {
protocol bgp;
community SPA-com;
}
then accept;
}
term b {
then reject;
}
}
policy-statement vpn-SPA-export {
term a {
then {
community add SPA-com;
accept;
}
}
term b {
then reject;
}
}
community SPA-com members target:69:100;
}
要在路由器上应用 VPN 策略,请在配置路由实例时包含 vrf-export and vrf-import 语句。VRF 导入和导出策略处理在 PE 路由器之间运行的 IBGP 会话中的路由分配。
要在路由器 A 上应用 VPN 策略,请加入以下语句:
[edit]
routing-instances {
VPN-Sunnyvale-Portland-Austin {
vrf-import vpn-SPA-import;
vrf-export vpn-SPA-export;
}
}
要在路由器 B 上应用 VPN 策略,请加入以下语句:
[edit]
routing-instances {
VPN-Sunnyvale-Portland-Austin {
vrf-import vpn-SPA-import;
vrf-export vpn-SPA-export;
}
}
要在路由器 C 上应用 VPN 策略,请加入以下语句:
[edit]
routing-instances {
VPN-Sunnyvale-Portland-Austin {
vrf-import vpn-SPA-import;
vrf-export vpn-SPA-export;
}
}
按路由器汇总的第 2 层 VPN 配置
有关本章示例中每个路由器上的配置摘要,请参阅以下部分:
路由器 A(Sunnyvale 的 PE 路由器)摘要
第 2 层 VPN 的路由实例
[edit]
routing-instances {
VPN-Sunnyvale-Portland-Austin {
instance-type l2vpn;
interface so-6/0/0.0;
interface so-6/0/0.1;
route-distinguisher 100:1;
vrf-import vpn-SPA-import;
vrf-export vpn-SPA-export;
protocols {
l2vpn {
encapsulation-type frame-relay;
site Sunnyvale {
site-identifier 1;
interface so-6/0/0.0 {
remote-site-id 2;
}
interface so-6/0/0.1 {
remote-site-id 3;
}
}
}
}
}
}
为接口配置 CCC 封装类型
interfaces {
interface so-6/0/0 {
encapsulation frame-relay-ccc;
unit 0 {
encapsulation frame-relay-ccc;
}
}
interface so-6/0/0 {
encapsulation frame-relay-ccc;
unit 1 {
encapsulation frame-relay-ccc;
}
}
}
主协议实例
protocols {
}
启用 RSVP
rsvp {
interface all;
}
配置 MPLS LSP
mpls {
label-switched-path RouterA-to-RouterB {
to 192.168.37.5;
primary Path-to-RouterB {
cspf;
}
}
label-switched-path RouterA-to-RouterC {
to 192.168.37.10;
primary Path-to-RouterC {
cspf;
}
}
interface all;
}
配置 IBGP
bgp {
import match-all;
export match-all;
group pe-pe {
type internal;
neighbor 192.168.37.5 {
local-address 192.168.37.1;
family l2vpn {
signaling;
}
}
neighbor 192.168.37.10 {
local-address 192.168.37.1;
family l2vpn {
signaling;
}
}
}
}
配置 VPN 策略
policy-options {
policy-statement match-all {
term acceptable {
then accept;
}
}
policy-statement vpn-SPA-export {
term a {
then {
community add SPA-com;
accept;
}
}
term b {
then reject;
}
}
policy-statement vpn-SPA-import {
term a {
from {
protocol bgp;
community SPA-com;
}
then accept;
}
term b {
then reject;
}
}
community SPA-com members target:69:100;
}
路由器 B(奥斯汀的 PE 路由器)摘要
VPN 路由实例
[edit]
routing-instances {
VPN-Sunnyvale-Portland-Austin {
instance-type l2vpn;
interface so-6/0/0.2;
interface so-6/0/0.3;
route-distinguisher 100:1;
vrf-import vpn-SPA-import;
vrf-export vpn-SPA-export;
}
}
配置第 2 层 VPN
protocols {
l2vpn {
encapsulation-type frame-relay;
site Austin {
site-identifier 2;
interface so-6/0/0.2 {
remote-site-id 1;
}
interface so-6/0/0.3 {
remote-site-id 3;
}
}
}
}
为接口配置 CCC 封装类型
[edit]
interfaces {
interface so-6/0/0 {
encapsulation frame-relay-ccc;
unit 2 {
encapsulation frame-relay-ccc;
}
}
interface so-6/0/0 {
encapsulation frame-relay-ccc;
unit 3 {
encapsulation frame-relay-ccc;
}
}
}
主协议实例
protocols {
}
启用 RSVP
rsvp {
interface all;
}
配置 MPLS LSP
mpls {
label-switched-path RouterB-to-RouterA {
to 192.168.37.1;
primary Path-to-RouterA {
cspf;
}
}
label-switched-path RouterB-to-RouterC {
to 192.168.37.10;
primary Path-to-RouterC {
cspf;
}
}
interface all;
}
配置 IBGP
bgp {
local-address 192.168.37.5;
import match-all;
export match-all;
group pe-pe {
type internal;
neighbor 192.168.37.1 {
local-address 192.168.37.5;
family l2vpn {
signaling;
}
}
neighbor 192.168.37.10 {
local-address 192.168.37.5;
family l2vpn {
signaling;
}
}
}
}
配置 VPN 策略
policy-options {
policy-statement match-all {
term acceptable {
then accept;
}
}
policy-statement vpn-SPA-import {
term a {
from {
protocol bgp;
community SPA-com;
}
then accept;
}
term b {
then reject;
}
}
policy-statement vpn-SPA-export {
term a {
then {
community add SPA-com;
accept;
}
}
term b {
then reject;
}
}
community SPA-com members target:69:100;
}
路由器 C(波特兰的 PE 路由器)摘要
VPN 路由实例
[edit]
routing-instances {
VPN-Sunnyvale-Portland-Austin {
instance-type l2vpn;
interface so-6/0/0.3;
interface so-6/0/0.4;
route-distinguisher 100:1;
vrf-import vpn-SPA-import;
vrf-export vpn-SPA-export;
}
}
配置第 2 层 VPN
protocols {
l2vpn {
encapsulation-type frame-relay;
site Portland {
site-identifier 3;
interface so-6/0/0.4 {
remote-site-id 1;
}
interface so-6/0/0.5 {
remote-site-id 2;
}
}
}
}
为接口配置 CCC 封装类型
[edit]
interfaces {
interface so-6/0/0 {
encapsulation frame-relay-ccc;
unit 4 {
encapsulation frame-relay-ccc;
}
}
interface so-6/0/0 {
encapsulation frame-relay-ccc;
unit 5 {
encapsulation frame-relay-ccc;
}
}
}
主协议实例
protocols {
}
启用 RSVP
rsvp {
interface all;
}
配置 MPLS LSP
mpls {
label-switched-path RouterC-to-RouterA {
to 192.168.37.1;
primary Path-to-RouterA {
cspf;
}
}
label-switched-path RouterC-to-RouterB {
to 192.168.37.5;
primary Path-to-RouterB {
cspf;
}
}
interface all;
}
配置 IBGP
bgp {
local-address 192.168.37.10;
import match-all;
export match-all;
group pe-pe {
type internal;
neighbor 192.168.37.1 {
local-address 192.168.37.10;
family l2vpn {
signaling;
}
}
neighbor 192.168.37.5 {
local-address 192.168.37.10;
family l2vpn {
signaling;
}
}
}
}
配置 VPN 策略
policy-options {
policy-statement match-all {
term acceptable {
then accept;
}
}
policy-statement vpn-SPA-import {
term a {
from {
protocol bgp;
community SPA-com;
}
then accept;
}
term b {
then reject;
}
}
policy-statement vpn-SPA-export {
term a {
then {
community add SPA-com;
accept;
}
}
term b {
then reject;
}
}
community SPA-com members target:69:100;
}