配置 GRE 激活时间
通用路由封装 (GRE) 隧道接口没有内置的机制来检测隧道何时关闭。激活消息可帮助 GRE 隧道接口检测隧道何时关闭。下面的主题讨论 GRE 激活时间的工作和配置。
了解 GRE 激活时间
通用路由封装 (GRE) 隧道接口没有内置的机制来检测隧道何时关闭。您可以启用激活消息作为检测机制。
激活时间仅适用于 ATM-over-ADSL 接口,从 Junos OS 版本 15.1X49-D10 开始,SRX300、SRX320、SRX340、SRX345、SRX380 和 SRX550HM 不再支持激活时间。其他接口默认启用激活时间。
激活可以在物理或 逻辑接口上配置。如果在物理接口上配置,激活将在属于物理接口一部分的所有逻辑接口上发送。如果在单个逻辑接口上配置,则激活只会发送至该逻辑接口。除了配置激活器,您还必须配置保留时间。
通过在层次结构级别上包括 keepalive-time
语句和 hold-time
语句 [edit protocols oam gre-tunnel interface interface-name]
,您可以在通用路由封装 (GRE) 隧道接口上配置激活。
要在 GRE 接口上正确操作激活,还必须将语 family inet
句包含在 [edit interfaces interface-name unit unit]
层次结构级别。如果未包含此语句,则接口标记为向下。
另请参阅
配置 GRE 激活时间
激活时间仅适用于 ATM-over-ADSL 接口,从 Junos OS 版本 15.1X49-D10 开始,SRX300、SRX320、SRX340、SRX345、SRX380 和 SRX550HM 不再支持激活时间。
配置激活时间并为 GRE 隧道接口留时间
通过在层次结构级别上包括 keepalive-time
语句和 hold-time
语句 [edit protocols oam gre-tunnel interface interface-name]
,您可以在通用路由封装 (GRE) 隧道接口上配置激活。
要在 GRE 接口上正确操作激活,还必须将语 family inet
句包含在 [edit interfaces interface-name unit unit]
层次结构级别。如果未包含此语句,则接口标记为向下。
要配置 GRE 隧道接口,
要为 GRE 隧道接口配置激活时间:
在 GRE 隧道接口的层次结构级别上配置操作、管理和维护 (OAM) 协议
[edit protocols]
。[edit] user@host# edit protocols oam
配置 OAM 协议的 GRE 通道接口选项。
[edit protocols oam] user@host# edit gre-tunnel interface interface-name
为 GRE 隧道接口配置 1 到 50 秒的激活时间。
[edit protocols oam gre-tunnel interface interface-name] user@host# set keepalive-time seconds
配置 5 到 250 秒的等待时间。请注意,保留时间必须至少是激活时间的两倍。
[edit protocols oam gre-tunnel interface interface-name] user@host# set hold-time seconds
显示 GRE 激活时间配置
显示 GRE 隧道接口上的激活时间信息
目的
在配置激活时间和保存时间参数时以及保留时间过期时,显示 GRE 隧道接口的当前状态信息。
行动
要验证 GRE 隧道接口上的当前状态信息(例如 gr-3/3/0.3),请运行 show interfaces gr-3/3/0.3 terse
和 show interfaces gr-3/3/0.3 extensive
操作命令。
show interfaces gr-3/3/0.3 terse
user@host> show interfaces gr-3/3/0.3 terse Interface Admin Link Proto Local Remote gr-3/3/0.3 up up inet 200.1.3.1/24 mpls
show interfaces gr-3/3/0.3 extensive
user@host> show interfaces gr-3/3/0.3 extensive Logical interface gr-3/3/0.3 (Index 73) (SNMP ifIndex 594) (Generation 900) Flags: Point-To-Point SNMP-Traps 0x4000 IP-Header 10.1.19.11:10.1.19.12:47:df:64:0000000000000000 Encapsulation: GRE-NULL Gre keepalives configured: On, Gre keepalives adjacency state: down ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Traffic statistics: Input bytes : 15629992 Output bytes : 15912273 Input packets: 243813 Output packets: 179476 Local statistics: Input bytes : 15322586 Output bytes : 15621359 Input packets: 238890 Output packets: 174767 Transit statistics: Input bytes : 307406 0 bps Output bytes : 290914 0 bps Input packets: 4923 0 pps Output packets: 4709 0 pps Protocol inet, MTU: 1476, Generation: 1564, Route table: 0 Flags: Sendbcast-pkt-to-re Addresses, Flags: Dest-route-down Is-Preferred Is-Primary ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Destination: 200.1.3/24, Local: 200.1.3.1, Broadcast: 200.1.3.255, Generation: 1366 Protocol mpls, MTU: 1464, Maximum labels: 3, Generation: 1565, Route table: 0
保留时间到期时:
即使接口无法发送或接收信息流,GRE 隧道也会保持正常运行。
状态
Link
将是Up
和Gre keepalives adjacency state
将Down
。
意义
具有激活时间和保留时间参数的 GRE 隧道接口的当前状态信息在保留时间过期时按预期显示。
示例:GRE 配置
通用路由封装 (GRE) 是一种 IP 封装协议,用于通过网络传输数据包。信息通过 GRE 隧道从一个网络发送至另一个网络。GRE 将有效负载封装为 GRE 数据包。此 GRE 数据包封装在外部协议(交付协议)中。GRE 隧道端点将有效负载转发至 GRE 隧道,以便将数据包路由至目标。到达端点后,GRE 封装将被移除,有效负载将传输到其最终目标。GRE 的主要用途是通过 IP 网络传输非 IP 数据包;但是,GRE 也用于通过 IP 云传输 IP 数据包。
要求
-
配置 GRE (gr-) 接口。gr- 接口包含本地地址和目标地址。配置后就会立即出现。您甚至可以在 gr-interface 上配置 IP 地址。
-
配置到达目标子网的路由(端到端连接)。您可通过 gr-interface 配置静态路由,或者使用 OSPF 等内部网关协议 (IGP)。
概述
GRE 隧道设计为完全无状态,这意味着每个隧道端点不会保留有关远程隧道端点状态或可用性的任何信息。一般情况下,GRE 隧道接口在配置后即出现,只要有有效的通道源地址或接口已打开,该接口就会保持正常运行。
配置
默认情况下,本地子网接口为 ge-0/0/0,IPv4 地址为 10.10.11.1/24。目标子网为 10.10.10.0/24,隧道端点 IPv4 接口为 10.10.10.1/24。
GRE 配置显示 SRX 系列设备上的隧道接口之间的默认配置。

配置到达目标子集的路由
逐步过程
您可以通过 gr-interface 或使用 IGP 配置静态路由。
-
配置本地子网接口 ge-0/0/0 接口。
[edit interfaces] user@host# set interfaces ge-0/0/0 unit 0 family inet address 10.10.11.1/24
-
配置接口 ge-0/0/1。
[edit interfaces] user@host# set interfaces ge-0/0/1 unit 0 family inet address 10.1.12.1/24
-
配置 gr-tunnel 端点,并为隧道端点指定源地址、目标地址和家族。
[edit interfaces] user@host# set interfaces gr-0/0/0 unit 0 tunnel source 10.1.12.1 destination 10.1.23.1 user@host# set interfaces gr-0/0/0 unit 0 family inet address 192.168.1.1/24
-
配置的接口绑定在层次结构级别的安全
[edit security]
区域。show zones
使用 命令查看区域。按照以下内容配置区域:[edit security zones security-zones trust]] user@host# set host-inbound-traffic system-services all user@host# set host-inbound-traffic protocols all user@host# set interfaces gr-0/0/0.0 user@host# set zones zone names protocols all
[edit security zones security-zones untrust]] user@host# set host-inbound-traffic system-services all user@host# set host-inbound-traffic protocols all
-
使用 命令在
[edit interfaces]
层次结构级别查看已配置的show
接口。[edit interfaces] user@host# set routing options static route 10.10.10.0/24 next hop gr-0/0/0.0
-
如果不想定义静态路由,OSPF 可在两侧的 gr-0/0/0 接口和内部子网之间配置为被动邻接方,以便接收所有内部路由。在
[edit protocols]
层次结构级别配置 OSPF 并使用show
命令查看。[edit protocols] user@host# set protocols ospf area 0.0.0.0 interface gr-0/0/0.0
结果
在配置模式下,输入 show
命令以确认设备上的配置。如果输出未显示预期的配置,请重复此示例中的配置说明以将其更正。
使用静态路由的 GRE 配置:
[edit interfaces] root@SRX-1# show ge-0/0/0 { unit 0 { family inet { address 10.10.11.1/24; } } } gr-0/0/0 { unit 0 { tunnel { source 10.1.12.1; destination 10.1.23.1; } family inet { address 192.168.1.1/24; } } } ge-0/0/1 { unit 0 { family inet { address 10.1.12.1/24; } } } [edit security] root@SRX-1# show zones { security-zone trust { host-inbound-traffic { system-services { all; } protocols { all; } } interfaces { gr-0/0/0.0; } } } root@SRX-1# show routing-options static { route 10.10.10.0/24 next-hop gr-0/0/0.0; }
GRE 配置在两侧的接口 gr-0/0/0 和内部子网之间作为被动邻接方的 OSPF:
[edit protocols] root@SRX-1# show ospf { area 0.0.0.0 { interface gr-0/0/0.0; interface ge-0/0/0.0 { passive; } } }
验证
要验证 SRX 系列设备上的 GRE 配置是否成功,请执行以下任务:
GRE 接口验证
目的
验证 GRE 接口是否已打开。
行动
show interfaces
在层次结构级别上[edit interfaces]
运行 命令:
show interfaces gr-0/0/0 terse [edit interfaces] Interface Admin Link Proto Local Remote gr-0/0/0 up up gr-0/0/0.0 up up inet 192.168.1.1/24
路由验证
目的
验证目标网络的路由是否可通过 GRE 隧道接口到达。
行动
show route forwarding-table matching 10.10.10.0/24
在层次结构级别上[edit interfaces]
运行 命令:
[edit interfaces] user@router# run show route forwarding-table matching 10.10.10.0/24 Routing table: default.inet Internet: .... Destination Type RtRef Next hop Type Index NhRef Netif 10.10.10.0/24 user 0 ucst 595 2 gr-0/0/0.0
通过 GRE 隧道验证流量
目的
将信息流发送至目标子网并验证 GRE 接口是否已打开。
行动
show interfaces gr-0/0/0 extensive
运行操作命令。同时验证数据包是否通过 gr-interface 离开。
user@host> show interfaces gr-0/0/0 extensive Physical interface: gr-0/0/0, Enabled, Physical link is Up Interface index: 134, SNMP ifIndex: 40, Generation: 17 Type: GRE, Link-level type: GRE, MTU: Unlimited, Speed: 800mbps Hold-times : Up 0 ms, Down 0 ms Device flags : Present Running Interface flags: Point-To-Point SNMP-Traps Statistics last cleared: 2005-08-05 21:39:41 UTC (00:00:47 ago) Traffic statistics: Input bytes : 8400 0 bps Output bytes : 8400 0 bps Input packets: 100 0 pps Output packets: 100 0 pps Logical interface gr-0/0/0.0 (Index 72) (SNMP ifIndex 28) (Generation 17) Flags: Point-To-Point SNMP-Traps 16384 IP-Header 10.1.12.1:10.1.23.1:47:df:64:0000000000000000 Encapsulation: GRE-NULL Traffic statistics: Input bytes : 8400 Output bytes : 8400 Input packets: 100 Output packets: 100 Local statistics: Input bytes : 0 Output bytes : 0 Input packets: 0 Output packets: 0 Transit statistics: Input bytes : 8400 0 bps Output bytes : 8400 0 bps Input packets: 100 0 pps Output packets: 100 0 pps Protocol inet, MTU: 1476, Generation: 25, Route table: 0 Flags: None Addresses, Flags: Is-Primary Destination: Unspecified, Local: 192.168.0.1, Broadcast: Unspecified, Generation: 30
示例:在 IPsec 隧道上配置 GRE
要求
概述
GRE 隧道提供的最低安全性,而 IPsec 隧道则在机密性、数据身份验证和完整性保证方面提供增强的安全性。此外,IPsec 不能直接支持组播数据包。但是,如果先使用封装 GRE 隧道,则可以使用 IPsec 隧道为组播数据包提供安全性。在 IPsec 上的 GRE 隧道中,所有路由流量(IP 和非 IP)均可通过路由。当原始数据包(IP/非 IP)封装时,其具有 GRE 隧道定义的 IP 报头,通常是隧道接口 IP 地址。IPsec 协议可以了解 IP 数据包;因此,它会封装 GRE 数据包,使其通过 IPsec 进行 GRE。
通过 IPsec 配置 GRE 涉及的基本步骤如下:
配置基于路由的 IPsec 隧道。
配置 GRE 隧道。
将目标配置为通过 gr-interface 的远程子网,使用目标配置静态路由。
为 GRE 端点配置静态路由,并将 st0 接口配置为下一跳跃。
配置
在此示例中,默认配置的本地子网接口为 ge-0/0/0,IPv4 地址为 10.10.11.1/24。目标子网为 10.10.10.0/24。gr-0/0/0 接口隧道端点是两侧的回传地址,本地回传 IPv4 地址为 172.20.1.1,远程回传 IPv4 地址为 172.20.1.2。gr-0/0/0、st0 和 lo0 接口绑定到安全区域,并相应创建策略。
通过 IPsec 隧道配置 GRE 接口
逐步过程
在
[set interfaces interface-name unit unit-number]
层次结构级别配置 GRE,其中接口名称为 ge-0/0/0,并且家族设置为 inet。[edit interfaces] user@host# set interfaces ge-0/0/0 unit 0 family inet address 10.10.11.1/24
配置 gr-tunnel 端点,并为隧道端点指定源地址、目标地址和家族。
[edit interfaces] user@host# set interfaces gr-0/0/0 unit 0 tunnel source 172.20.1.1 destination 172.20.1.2 user@host# set interfaces gr-0/0/0 unit 0 family inet 192.168.1.1/24
同样配置带系列集 inet 的 lo0 和 st0 接口。
[edit interfaces] user@host# set interfaces lo0 unit 0 family inet address 172.20.1.1/32
[edit interfaces] user@host# set interfaces st0 unit 0 family inet
配置带有安全区域的 GRE 接口。
show zones
使用 命令查看已配置的隧道接口、lo0 和 st0 所在的区域。[edit security zones security-zones trust]] user@host# set host-inbound-traffic system-services all user@host# set host-inbound-traffic protocols all user@host# set interfaces gr-0/0/0.0 user@host# set zones zone names protocols all user@host# set interfaces lo0.0 user@host# set interfaces st0.0
[edit security zones security-zones untrust]] user@host# set host-inbound-traffic system-services all user@host# set host-inbound-traffic protocols all user@host# set interfaces gr-0/0/0.0.1 user@host# set interfaces lo0.0 user@host# set interfaces st0.0
结果
在配置模式下,输入 show
命令以确认您的接口配置。配置的接口绑定在层次结构级别的安全 [edit security]
区域。 show zones
使用 命令查看已配置接口(gr-、st0.0 和 lo0)所在的区域。如果输出未显示预期的配置,请重复此示例中的配置说明以将其更正。
配置 GRE 接口的参数:
user@host> show interfaces ge-0/0/0 { unit 0 { family inet { address 10.10.11.1/24; } } } gr-0/0/0 { unit 0 { tunnel { source 172.20.1.1; destination 172.20.1.2; } family inet { address 192.168.1.1/24; } } } lo0 { unit 0 { family inet { address 172.20.1.1/32; } } } st0 { unit 0 { family inet; } } [edit] root@Juniper# show routing-options { static { route 10.10.10.0/24 next-hop gr-0/0/0.0; route 172.20.1.2/32 next-hop st0.0; } }
使用安全区域配置 GRE 接口的参数:
[edit security] root@Juniper# show zones { security-zone trust { host-inbound-traffic { system-services { all; } protocols { all; } } interfaces { gr-0/0/0.0; lo0.0; st0.0; } } }
示例:当隧道目标处于路由实例中时配置 GRE 隧道
要求
概述
当隧道目标处于默认路由实例或非默认路由实例时,您可以配置 GRE 隧道。GRE 隧道的配置需要定义隧道源和隧道目标地址。如果隧道目标处于路由实例中,且存在多个路由实例,则需要指定正确的路由实例以及用于到达配置的隧道目标地址的路由表。
隧道目标地址默认情况下被视为可使用默认路由表“inet.0”到达。
配置
在此示例中,您可以使用两个实例在 SRX 系列设备上的 gr-interfaces 之间配置 GRE 隧道。当隧道目标处于默认路由实例中,以及隧道目标处于非默认路由实例时,实例将发生。
当隧道目标处于默认路由实例时配置 GRE 隧道
此示例使用默认路由实例到达隧道目标。因此,默认情况下会使用路由表 inet.0。
逐步过程
指定隧道的来源和目标地址。
[edit interfaces] user@host# set interfaces gr-0/0/0 unit 0 tunnel source 172.16.0.1 destination 10.10.1.2 user@host# set interfaces gr-0/0/0 unit 0 family inet 192.168.100.1/30;
将 ge-interface 和 lo0 接口配置为以 inet 为系列集。
[edit interfaces] user@host# set interfaces ge-0/0/0 unit 0 family inet address 172.30.73.56/24 user@host# set interfaces lo0 unit 0 family inet address 172.16.0.1/32
-
配置 GRE 配置主题中所述路由选项的 GRE 通道接口。
当隧道目标处于非默认路由实例时配置 GRE 隧道
对于非默认路由实例,请确保您已配置 gr-0/0/0 接口。
逐步过程
使用 gr-0/00 接口和系列设置为 inet 配置 GRE 隧道。
[edit interfaces] user@host# set interfaces gr-0/00 unit 0 family inet address
指定隧道的来源和目标地址。
[edit interfaces] user@host# set interfaces gr-0/0/0 unit 0 tunnel source 172.16.0.1 tunnel destination 10.10.1.2 family inet 192.168.100.1/30;
将 ge-interface 和 lo0 接口配置为以 inet 为系列集。
[edit interfaces] user@host# set interfaces ge-0/0/0 unit 0 family inet address 172.30.73.56/24 user@host# set interfaces lo0 unit 0 family inet address 172.16.0.1/32
配置用于隧道接口的路由实例。
[edit routing-instances] user@host# set routing-instances test instance-type virtual-router user@host# set routing-instances test routing-options static route 10.10.1.2/32 next-hop 172.30.73.57 user@host# set routing-instances test interface ge-0/0/0.0
配置 GRE 隧道接口的路由实例。
[edit interfaces] user@host# set interfaces gr-0/0/0 unit 0 tunnel routing-instance destination test
为隧道目标添加静态路由。
[edit interfaces] user@host# set routing-options static route 10.10.1.2/32 next-table test.inet.0
注意:当 SRX 系列设备处于数据包模式时,无需配置静态路由,即可使隧道目标从 inet.0 到达。但是,您仍需要在 gr-0/0/0 接口下指定正确的路由实例。
结果
在配置模式下,输入 show
命令以确认设备上的配置。如果输出未显示预期的配置,请重复此示例中的配置说明以将其更正。
当隧道目标处于默认路由实例时:
interfaces { gr-0/0/0 { unit 0 { tunnel { source 172.16.0.1; destination 10.10.1.2; } family inet { address 192.168.100.1/30; } } } ge-0/0/0 { unit 0 { family inet { address 172.30.73.56/24; } } } lo0 { unit 0 { family inet { address 172.16.0.1/32; } } } ... } routing-options { static { route 10.10.1.2/32 next-hop 172.30.73.57; # Tunnel destination is reachable from default routing-instance ... } } routing-instances { test { instance-type virtual-router; interface gr-0/0/0.0; routing-options { ... } } }
当隧道目标处于非默认路由实例中时:
interfaces { gr-0/0/0 { unit 0 { tunnel { source 172.16.0.1; destination 10.10.1.2; routing-instance { destination test; # Routing-instance to reach tunnel destination } } family inet { address 192.168.100.1/30; } } } ge-0/0/0 { unit 0 { family inet { address 172.30.73.56/24; } } } lo0 { unit 0 { family inet { address 172.16.0.1/32; } } } ... } routing-options { static { route 10.10.1.2/32 next-table test.inet.0; # Tunnel destination is reachable via test.inet.0 ... } } routing-instances { test { instance-type virtual-router; interface ge-0/0/0; routing-options { static { route 10.10.1.2/32 next-hop 172.30.73.57; # Tunnel destination is reachable from non-default routing-instance ... } } } }
验证
静态路由使用验证
目的
验证是否使用了静态路由。
行动
show route forwarding table
运行 命令。
user@host> show route forwarding-table table test No Title Routing table: test.inet Internet: Enabled protocols: Bridging, Destination Type RtRef Next hop Type Index NhRef Netif default perm 0 rjct 597 1 0.0.0.0/32 perm 0 dscd 590 1 10.10.1.2/32 user 1 172.30.73.57 hold 598 4 ge-0/0/0.0 172.16.0.1.10.10.1.2.47/72 dest 0 locl 617 1 172.30.73.0/24 intf 0 rslv 588 1 ge-0/0/0.0 172.30.73.0/32 dest 0 172.30.73.0 recv 586 1 ge-0/0/0.0 172.30.73.56/32 intf 0 172.30.73.56 locl 587 2 172.30.73.56/32 dest 0 172.30.73.56 locl 587 2 172.30.73.57/32 dest 0 172.30.73.57 hold 598 4 ge-0/0/0.0 172.30.73.255/32 dest 0 172.30.73.255 bcst 585 1 ge-0/0/0.0 224.0.0.0/4 perm 0 mdsc 596 1 224.0.0.1/32 perm 0 224.0.0.1 mcst 600 1 255.255.255.255/32 perm 0 bcst 601 1