示例:使用基于过滤器的隧道跨 IPv4 传输 IPv6 流量
此示例说明如何配置单向通用路由封装 (GRE) 隧道,以便通过 IPv4 传输网络传输 IPv6 单播传输流量。为了向两个不相交的 IPv6 网络提供网络连接,为两个 MX 系列 5G 通用路由平台配置了可以发起和识别 IPv4 和 IPv6 数据包的接口。此配置不需要在隧道服务物理接口卡 (PIC) 或 MPC3E 模块化端口集中器 (MPC) 上创建隧道接口。而是将防火墙过滤器连接到两个 MX 系列路由器中的模块化接口卡 (MIC) 或 MPC 上托管的以太网逻辑接口。
仅当网络服务设置为 时,PTX 系列路由器才支持基于过滤器的 GRE 隧道。enhanced-mode
有关更多详细信息,请参阅enhanced-mode
。
要求
此示例使用以下瞻博网络硬件和 Junos OS 软件:
传输网络 — 运行 Junos OS 12.3R2 或更高版本的 IPv4 网络。
PE 路由器 — 作为提供商边缘 (PE) 路由器安装的两个 MX80 路由器,将 IPv4 网络连接到两个需要从一个网络到另一个网络的逻辑路径的不相交的 IPv6 网络。
封装接口 — 在封装器(入口 PE 路由器)上,一个在内置 10 千兆以太网 MIC 上配置的以太网逻辑接口。
解封装接口 — 在解封装器(出口 PE 路由器)上,在内置 10 千兆以太网 MIC 的三个端口上配置的以太网逻辑接口。
在开始配置此示例之前:
在每个 PE 路由器上,使用操作模式命令确定 哪些路由器线卡支持基于过滤器的 GRE IPv4 隧道,然后使用配置语句配置 封装和解封装接口。show chassis fpc pic-status
interfaces
在封装器 PE1 上,在支持的线卡上配置 一个封装接口 。
在 PE2(解封装器)上,在支持的线卡上配置 三个解封装接口 。
检查网络中是否启用了 IPv4 路由协议,以支持从封装器到解封装器的路由路径。
通过手动将静态路由添加到路由表或者配置静态或动态路由共享协议来配置路由信息。有关更多信息,请参阅 《传输和互联网协议用户指南》。https://www.juniper.net/documentation/en_US/junos/information-products/pathway-pages/system-basics/system-management-ip.html
在 PE1 上,对 PE2 IPv4 环路地址 执行 ping 操作 ,以验证解封装器是否可从封装器访问。ping
在 PE2 上,对 CE2 路由器 IPv6 环路地址 执行 ping 操作 ,以验证是否可以从解封装器访问目标客户边缘路由器。ping
从 PE2 到 CE2 的 IPv6 路由路径可由手动添加到路由表中的静态路由或静态或动态路由共享协议提供。
默认情况下,PE2 根据从主路由表导入的接口路由(直接路由)转发数据包。
作为一个选项,解封装过滤器可以指定数据包转发引擎使用备用路由表将有效负载数据包转发到目标客户网络。在本例的可选配置任务中,您可以通过在路由实例 中安装从 PE2 到 C1 的静态路由来指定备用路由表。blue 配置路由信息库 (RIB) 组 以指定与 共享 的 路由信息,然后将 PE2 接口与 存储在默认路由和路由实例中的路由相关联。blue_groupinet6.0blue.inet6.0
概述
在此示例中,您将配置从路由器 PE1 到路由器 PE2 的基于单向过滤器的 GRE IPv4 隧道,提供从 IPv6 网络 C1 到 IPv6 网络 C2 的逻辑路径。
要启用基于过滤器的 双向 GRE 隧道,必须配置相反方向的第二个隧道。
作为此示例中的可选任务,您可以创建一个 RIB 组,该组指定共享多个路由表的路由信息(包括从对等方获知的路由、将协议策略应用于学习的路由而产生的本地路由以及向对等方播发的路由)。
拓扑
图 1 显示了使用基于过滤器的隧道从 PE1 到 PE2 且不需要隧道接口的情况下,通过 IPv4 传输网络从网络 C1 传输到网络 C2 的 IPv6 流量的路径。
总结了路由器 PE1 作为封装器的配置。 总结了路由器 PE2 作为解封装器的配置。表 1表 2
组件 |
CLI 名称 |
Description |
||
---|---|---|---|---|
|
封装器 |
设备名称:IPv4 环回:IPv6 环回: |
|
作为入口 PE 路由器安装的 MX80 路由器。PE1 将 IPv4 网络与客户边缘路由器 CE1 连接在 IPv6 源网络 C1 中。 |
封装接口 |
接口名称:IPv4 地址:IPv6 地址: |
|
面向客户的逻辑接口托管在 10 千兆以太网 MIC 上。CE1 发送此接口 IPv6 流量,该流量源自最终用户主机,并发往 IPv6 目标网络 C2 上的应用程序或主机。 |
|
封装过滤器 |
过滤器名称: |
|
IPv6 防火墙过滤器,其操作会导致数据包转发引擎使用指定的隧道特征封装匹配的数据包。封装包括添加 GRE 报头、添加 IPv4 数据包报头,然后通过 GRE IPv4 隧道转发生成的 GRE 报头。 |
|
隧道源接口 |
接口名称:IPv4 地址: |
|
隧道的面向核心的出口接口。 |
|
GRE 隧道模板 |
隧道名称: |
|
使用 IPv4 () 支持的隧道协议,定义从路由器 PE1 () 到路由器 PE2() 的 GRE IPv4 隧道。 |
组件 |
CLI 名称 |
Description |
||
---|---|---|---|---|
|
解封器 |
设备名称:IPv4 环回:IPv6 环回: |
|
作为出口 PE 路由器安装的 MX80 路由器,用于接收从入口路由器 PE1 通过 GRE IPv4 隧道转发的 GRE 数据包。 |
解封装接口 |
接口名称:IPv4 地址: 接口名称:IPv4 地址: 接口名称:IPv4 地址: |
|
托管在 10 千兆以太网 MIC 上的面向核心的入口逻辑接口。接口从 PE1 接收通过 GRE IPv4 隧道路由的 GRE 数据包。 |
|
解封装过滤器 |
过滤器名称: |
|
将操作应用于 GRE 数据包的 IPv4 防火墙过滤器。decapsulate 过滤器操作会导致数据包转发引擎解封装匹配的数据包。 解封装包括移除外部 GRE 报头,然后通过在默认路由表上执行目标查找,将内部 IPv6 有效负载数据包转发到其在目标 IPv6 网络上的原始目标。 |
|
隧道出口接口 |
接口名称:IPv4 地址:IPv6 地址: |
|
面向客户的接口,路由器通过该接口将解封装的 IPv6 数据包转发到目标 IPv6 网络 C2。 |
配置
要使用基于过滤器的隧道从 PE1 到 PE2,在不配置隧道接口的情况下,通过 IPv4 传输网络将 IPv6 数据包从 CE1 传输到 CE2,请执行以下操作:
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改与您的网络配置匹配所需的任何详细信息,然后将命令复制并粘贴到层次结构级别的 CLI 中。[edit]
配置 PE1 以封装 IPv6 数据包
set interfaces lo0 unit 0 family inet address 10.255.1.1 set interfaces lo0 unit 0 family inet6 address 2001:db8::1 set interfaces xe-0/0/0 unit 0 family inet address 10.0.1.10/30 set interfaces xe-0/0/0 unit 0 family inet6 address 2001::10.34.1.10/120 set interfaces xe-0/0/0 unit 0 family inet6 filter input gre_encap_1 set interfaces xe-0/0/2 unit 0 family inet address 10.0.1.12/30 set firewall family inet6 filter gre_encap_1 term t1 then count c_gre_encap_1 set firewall family inet6 filter gre_encap_1 term t1 then encapsulate tunnel_1 set firewall tunnel-end-point tunnel_1 ipv4 source-address 10.255.1.1 set firewall tunnel-end-point tunnel_1 ipv4 destination-address 10.255.2.2 set firewall tunnel-end-point tunnel_1 gre
配置 PE2 以解封装 GRE 数据包
set interfaces lo0 unit 0 family inet address 10.255.2.2 set interfaces lo0 unit 0 family inet6 address 2001:fc3::2 set interfaces xe-0/0/0 unit 0 family inet address 10.0.2.20/30 set interfaces xe-0/0/1 unit 0 family inet address 10.0.2.21/30 set interfaces xe-0/0/2 unit 0 family inet address 10.0.2.22/30 set interfaces xe-0/0/3 unit 0 family inet address 10.0.2.23/30 set interfaces xe-0/0/3 unit 0 family inet6 address ::20.34.2.23/120 set forwarding-options family inet filter input gre_decap_1 set firewall family inet filter gre_decap_1 term t1 from source-address 10.255.1.1/32 set firewall family inet filter gre_decap_1 term t1 from destination-address 10.255.2.2/32 set firewall family inet filter gre_decap_1 term t1 then count c_gre_decap_1 set firewall family inet filter gre_decap_1 term t1 then decapsulate gre
选:使用备用路由表配置 PE2
set routing-instances blue instance-type forwarding set routing-instances blue routing-options rib blue.inet6.0 static route 0::/0 next-hop fec0:0:2003::2 set routing-options passive set routing-options rib inet6.0 set routing-options rib-groups blue_group import-rib inet6.0 set routing-options rib-groups blue_group import-rib blue.inet6.0 set routing-options interface-routes rib-group inet6 blue_group set firewall family inet filter gre_decap_1 term t1 then decapsulate gre routing-instance blue
配置 PE1 以封装 IPv6 数据包
分步过程
要将路由器 PE1 配置为封装从 CE1 传入的 IPv6 数据包,请执行以下操作:
配置路由器环路地址。
[edit] user@PE1# set interfaces lo0 unit 0 family inet address 10.255.1.1 user@PE1# set interfaces lo0 unit 0 family inet6 address 2001:db8::1
配置封装接口 IPv4 和 IPv6 地址,并将封装过滤器连接到 IPv6 输入。
[edit] user@PE1# set interfaces xe-0/0/0 unit 0 family inet address 10.0.1.10/30 user@PE1# set interfaces xe-0/0/0 unit 0 family inet6 address ::10.34.1.10/120 user@PE1# set interfaces xe-0/0/0 unit 0 family inet6 filter input gre_encap_1
配置隧道面向核心的出口接口。
[edit] user@PE2# set interfaces xe-0/0/2 unit 0 family inet address 10.0.1.12/30
定义使数据包转发引擎封装所有数据包的 IPv6 防火墙过滤器。
[edit] user@PE1# set firewall family inet6 filter gre_encap_1 term t1 then count c_gre_encap_1 user@PE1# set firewall family inet6 filter gre_encap_1 term t1 then encapsulate tunnel_1
注:防火墙过滤器操作是终止过滤器操作。encapsulate 过滤器终止操作会停止对特定数据包的防火墙过滤器的所有评估。路由器执行指定的操作,并且不检查其他术语。
定义名为 tunnel_1 的 GRE IPv4 隧道模板,该模板指定一个隧道源接口和三个隧道目标接口的主机 IP 地址。
[edit] user@PE1# set firewall tunnel-end-point tunnel_1 ipv4 source-address 10.255.1.1 user@PE1# set firewall tunnel-end-point tunnel_1 ipv4 destination-address 10.255.2.2 user@PE1# set firewall tunnel-end-point tunnel_1 gre
注:如果使用 GRE 选项 唯一标识每个隧道,则可以从 10.0.1.10(PE1 上的隧道源接口)到 10.0.2.20 – 10.0.2.22(PE2 上的解封装接口)之间隧道传输多个不同的流量。key number
如果完成设备配置,请提交配置。
[edit ] user@PE1# commit
成果
在配置模式下,输入 show firewall
和 show interfaces
命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
路由器 PE1
确认封装器上的防火墙过滤器和隧道模板。
user@PE2# show firewall family inet6 { filter gre_encap_1 { term t1 { then { count c_gre_encap_1; encapsulate tunnel_1; } } } } tunnel-end-point tunnel_1 { ipv4 { source-address 10.255.1.1; destination-address 10.255.2.2; } gre; }
路由器 PE1
确认封装器上的接口。
user@PE1# show interfaces lo0 { unit 0 { family inet { address 10.255.1.1; } family inet6 { address 2001:db8::1; } } } xe-0/0/0 { unit 0 { family inet { address 10.0.1.10/30; } family inet6 { address ::10.34.1.10/120; filter input gre_encap_1; } } } xe-0/0/2 { unit 0 { family inet { address 10.0.1.12/30; } } }
配置 PE2 以解封装 GRE 数据包
分步过程
要将路由器 PE2 配置为解封装从 IPv4 隧道传入的 GRE 数据包,请执行以下操作:
配置路由器环路地址。
[edit] user@PE2# set interfaces lo0 unit 0 family inet address 10.255.2.2 user@PE2# set interfaces lo0 unit 0 family inet6 address 2001:fc3::2
配置解封装接口。
[edit] user@PE2# set interfaces xe-0/0/0 unit 0 family inet address 10.0.2.20/30 user@PE2# set interfaces xe-0/0/1 unit 0 family inet address 10.0.2.21/30 user@PE2# set interfaces xe-0/0/2 unit 0 family inet address 10.0.2.22/30
将面向客户的出口接口配置为 CE2。
[edit] user@PE2# set interfaces xe-0/0/3 unit 0 family inet address 10.0.2.23/30 user@PE2# set interfaces xe-0/0/3 unit 0 family inet6 address ::20.34.2.23/120
将入口解封装防火墙过滤器应用于所有转发的数据包。
[edit] user@PE2# set forwarding-options family inet filter input gre_decap_1
定义 IPv4 过滤器 。gre_decap_1
定义一个 IPv4 过滤器,用于解封装和转发所有 GRE 数据包。
[edit] user@PE2# set firewall family inet filter gre_decap_1
配置术语 以匹配通过路由器 PE1 上定义的隧道 传输的数据包。t1tunnel_1 隧道将数据包从路由器 PE1(配置了 IPv4 环路地址 10.255.1.1)发送到路由器 PE2(配置了 IPv4 环路地址 10.255.2.2)。
[edit firewall family inet filter gre_decap_1] user@PE2# set term t1 from source-address 10.255.1.1 user@PE2# set term t1 from destination-address 10.255.2.2
配置术语 以对匹配的数据包进行计数和解封装。t1
[edit firewall family inet filter gre_decap_1] user@PE2# set term t1 then count c_gre_decap_1 user@PE2# set term t1 then decapsulate gre
如果解封装过滤器操作 引用 路由实例,请确保已配置路由实例,并且 RIB 组 定义将备用路由共享到主表中。decapsulateblueblue_group
如果完成设备配置,请提交配置。
[edit] user@PE2# commit
成果
在配置模式下,输入 、 和 命令确认您的配置。show firewall
show forwarding-options
show interfaces
如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
路由器 PE2
确认解封装器上的防火墙过滤器。
user@PE2# show firewall family inet { filter gre_decap_1 { term t1 { from { source-address 10.255.1.1; destination-address 10.255.2.2; } then { count c_gre_decap_1; decapsulate gre routing-instance blue; } } } }
如果解封装过滤器操作 引用 路由实例,请确保已配置路由实例,并且 RIB 组 定义将备用路由共享到主表中。decapsulateblueblue_group
路由器 PE2
确认解封装器上的转发选项(用于将解封装防火墙过滤器连接到所有输入转发的数据包)。
user@PE2# show forwarding-options forwarding-options { family inet { filter { input gre_decap_1; } } }
路由器 PE2
确认解封装器上的接口。
user@PE2# show interfaces lo0 { unit 0 { family inet { address 10.255.2.2; } family inet6 { address 2001:fc3::2; } } } xe-0/0/0 { unit 0 { family inet { address 10.0.2.20/30; filter input gre_decap_1; } } } xe-0/0/1 { unit 0 { family inet { address 10.0.2.21/30; filter input gre_decap_1; } } } xe-0/0/2 { unit 0 { family inet { address 10.0.2.22/30; filter input gre_decap_1; } } } xe-0/0/3 { unit 0 { family inet { address 10.0.2.23/30; } family inet6 { address ::20.34.2.23/120; } } }
选:使用备用路由表配置 PE2
分步过程
要使用备用路由表配置路由器 PE2:
配置路由实例 ,并将静态路由添加到 CE2。blue
[edit ] user@PE2# set routing-instances blue instance-type forwarding user@PE2# set routing-instances blue routing-options rib blue.inet6.0 static route 0::/0 next-hop fec0:0:2003::2
Junos OS 软件使用在实例中获知的路由信息生成路由表 。blue.inet6.0
使路由保留在路由和转发表中,即使路由变为非活动状态也是如此。这允许静态路由在下一跃点不可用时保留在表中。
[edit ] user@PE2# set routing-options passive
通过显式创建默认路由表来创建 RIB 组。
[edit ] user@PE2# set routing-options rib inet6.0
定义 RIB 组 。blue_group
[edit ] user@PE2# set routing-options rib-groups blue_group import-rib inet6.0 user@PE2# set routing-options rib-groups blue_group import-rib blue.inet6.0
在语句中 ,首先指定主路由表。import-rib
将路由器接口与 RIB 组指定的路由信息相关联。
[edit ] user@PE2# set routing-options interface-routes rib-group inet6 blue_group
如果完成设备配置,请提交配置。
[edit ] user@PE2# commit
成果
在配置模式下,输入 、 和 命令确认您的配置。show firewall
show routing-instances
show routing-options
如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
路由器 PE2
如果您在路由器 PE2 上配置了备用路由表,请确认路由实例配置。
user@PE2# show routing-instances blue { instance-type forwarding; routing-options { static route 0::/0 next-hop fec0:0:2003::2; } }
路由器 PE2
如果您在路由器 PE2 上配置了备用路由表,请确认 RIB 组和直接路由配置。
user@PE2# show routing-options interface-routes { rib-group blue_group; } passive; rib inet6.0; rib-groups { blue_group { import-rib [ inet6.0 blue.inet6.0 ]; } }
验证
确认配置工作正常。
验证路由信息
目的
验证直接路由是否包含备用路由表信息。
操作
要执行验证,请执行以下操作:
(可选)要验证 PE2 上的路由实例,请使用操作模式命令显示该路由实例的主表和路由数。blueshow route instance
user@PE2> show route instance blue summary Instance Type Primary RIB Active/holddown/hidden blue forwarding blue.inet6.0 2/0/0
(可选)要查看与 PE2 上的路由实例 关联的路由表,请使用 操作模式命令blueshow route table
user@PE2> show route table blue.inet6.0 blue.inet6.0: 2 destinations, 2 routes (2 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 2001:db8::192:168:239:17/128 *[Direct/0] 00:02:26 > via lo0.0 fe80::2a0:a50f:fc64:e032/128 *[Direct/0] 00:02:26 > via lo0.0
(可选)要验证路由实例蓝色中的备用路由是否已导入到 PE2 转发表,请使用 操作模式命令显示路由器转发表和路由实例转发表的内容。show route forwarding-table
user@PE2> show route forwarding-table blue Routing table: blue.inet Internet: Destination Type RtRef Next hop Type Index NhRef Netif default perm 0 rjct 689 1 0.0.0.0/32 perm 0 dscd 687 1 172.16.233.0/4 perm 0 mdsc 688 1 172.16.233.1/32 perm 0 172.16.233.1 mcst 684 1 255.255.255.255/32 perm 0 bcst 685 1 Routing table: blue.iso ISO: Destination Type RtRef Next hop Type Index NhRef Netif default perm 0 rjct 695 1 Routing table: blue.inet6 Internet6: Destination Type RtRef Next hop Type Index NhRef Netif default perm 0 rjct 701 1 ::/128 perm 0 dscd 699 1 2001:db8::192:168:239:17/128 user 0 rtbl 2 3 fe80::2a0:a50f:fc64:e032/128 user 0 rtbl 2 3 ff00::/8 perm 0 mdsc 700 1 ff02::1/128 perm 0 ff02::1 mcst 697 1
验证 PE1 上的封装
目的
验证 PE1 上的封装接口。
操作
要执行验证,请执行以下操作:
使用操作模式命令验证封装防火墙过滤器是否已连接到封装接口的入口。show interfaces filters
user@PE1> show interfaces filters xe-0/0/0.0 Interface Admin Link Proto Input Filter Output Filter xe-0/0/0.0 up down inet6 gre_encap_1
使用 操作模式命令验证封装接口是否正在接收数据包。show interfaces
user@PE1> show interfaces xe-0/0/0.0 detail | filter ”Ingress traffic” ... Physical interface: xe-0/0/0, Enabled, Physical link is Up ... Ingress traffic statistics at Packet Forwarding Engine: Input bytes : 6970299398 0 bps Input packets: 81049992 0 pps Drop bytes : 0 0 bps Drop packets: 0 0 pps ...
使用操作模式命令验证入口乘客协议流量是否触发了封装过滤器。show firewall filter
user@PE1> show firewall filter gre_encap_1 Filter: gre_encap_1 Counters: Name Bytes Packets c_gre_encap_1 6970299398 81049992
意义
如果封装过滤器连接到封装接口,并且封装接口接收乘客协议流量,并且防火墙过滤器统计信息显示入口乘客协议流量正在封装,则 GRE 数据包将通过隧道转发。
验证 PE2 上的解封装
目的
验证 PE2 上的解封装接口。
操作
要执行验证,请执行以下操作:
在 PE1 上,使用操作模式命令验证 PE2 是否可访问。ping
user@PE1> ping 10.255.2.2 PING 10.255.2.2 (10.255.2.2): 56 data bytes 64 bytes from 10.255.2.2: icmp_seq=0 ttl=64 time=0.576 ms 64 bytes from 10.255.2.2: icmp_seq=1 ttl=64 time=0.269 ms ^C [abort]
在 PE2 上,使用操作模式命令验证 解封装防火墙过滤器是否已连接到解封装接口的入口。show interfaces filter
user@PE2> show interfaces filter | match xe- Interface Admin Link Proto Input Filter Output Filter xe-0/0/0.0 up down inet gre_decap_1 xe-0/0/1.0 up down inet gre_decap_1 xe-0/0/2.0 up down inet gre_decap_1
在 PE2 上,使用操作模式命令验证 解封装接口是否正在接收数据包。show interfaces
user@PE2> show interfaces xe-0/0/0.0 detail | filter ”Ingress traffic” Physical interface: xe-0/0/0, Enabled, Physical link is Up ... Ingress traffic statistics at Packet Forwarding Engine: Input bytes : 6970299398 0 bps Input packets: 81049992 0 pps Drop bytes : 0 0 bps Drop packets: 0 0 pps ... user@PE2> show interfaces xe-0/0/1.0 detail | filter ”Ingress traffic” Physical interface: xe-0/0/2, Enabled, Physical link is Up ... user@PE2> show interfaces xe-0/0/2.0 detail | filter ”Ingress traffic” Physical interface: xe-0/0/2, Enabled, Physical link is Up ...
根据路由的配置方式以及哪些链路已打开,哪些链路处于关闭状态,尽管隧道运行正常,但某些解封装接口可能无法接收数据包。
在 PE2 上,使用操作模式命令验证 入口 GRE 流量是否触发了解封装过滤器。show firewall filter
user@PE2> show firewall filter gre_decap_1 Filter: gre_decap_1 Counters: Name Bytes Packets c_gre_decap_1 6970299398 81049992
意义
验证确认封装器的以下操作状态和活动:
PE2 可从 PE1 访问。
解封装过滤器连接到所有解封装接口的输入端。
解封装器按预期在解封装接口上接收流量。
在解封装接口接收的 GRE 数据包会触发解封装防火墙过滤器操作。