配置 GRE 激活时间
通用路由封装 (GRE) 隧道接口没有用于检测隧道何时关闭的内置机制。激活消息可帮助 GRE 隧道接口检测隧道何时关闭。以下主题讨论 GRE 激活时间的工作和配置。
了解 GRE 激活时间
通用路由封装 (GRE) 隧道接口没有用于检测隧道何时关闭的内置机制。您可以启用激活消息作为检测机制。
激活时间只能针对 ATM-over-ADSL 接口进行配置,从 Junos OS 版本 15.1X49-D10 开始,SRX300、SRX320、SRX340、SRX345、SRX380 和 SRX550HM 将不再支持该接口。默认情况下,为其他接口启用激活时间。
可以在物理 接口或逻辑接口上配置激活。如果在物理接口上配置,则会在属于物理接口的所有逻辑接口上发送激活。如果在单个逻辑接口上配置,则激活仅发送到该逻辑接口。除了配置激活之外,还必须配置保持时间。
通过在层次结构级别包含keepalive-time
[edit protocols oam gre-tunnel interface interface-name]
语句和hold-time
语句,可以在通用路由封装 (GRE) 隧道接口上配置激活。
为了在 GRE 接口上正确操作激活,还必须在[edit interfaces interface-name unit unit]
层次结构级别包含family inet
该语句。如果未包含此语句,则接口将标记为关闭。
参见
配置 GRE 激活时间
激活时间只能针对 ATM-over-ADSL 接口进行配置,从 Junos OS 版本 15.1X49-D10 开始,SRX300、SRX320、SRX340、SRX345、SRX380 和 SRX550HM 将不再支持该接口。
配置 GRE 隧道接口的激活时间和保持时间
通过在层次结构级别包含keepalive-time
[edit protocols oam gre-tunnel interface interface-name]
语句和hold-time
语句,可以在通用路由封装 (GRE) 隧道接口上配置激活。
为了在 GRE 接口上正确操作激活,还必须在[edit interfaces interface-name unit unit]
层次结构级别包含family inet
该语句。如果未包含此语句,则接口将标记为关闭。
要配置 GRE 隧道接口,请执行以下操作:
要为 GRE 隧道接口配置激活时间,请执行以下操作:
在 GRE 隧道接口的层次结构级别配置
[edit protocols]
操作、管理和维护 (OAM) 协议。[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
操作命令。
显示接口 gr-3/3/0.3 简洁
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
显示接口 GR-3/3/0.3 广泛
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
状态将是 和Gre keepalives adjacency state
Down
将是Up
。
意义
保留时间到期时,具有激活时间和保留时间参数的 GRE 隧道接口的当前状态信息将按预期显示。
示例:配置 GRE 隧道
通用路由封装 (GRE) 是一种 IP 封装协议,用于通过网络传输数据包。信息通过 GRE 隧道从一个网络发送到另一个网络。GRE 将有效负载封装为 GRE 数据包。此 GRE 数据包封装在外部协议(传递协议)中。GRE 隧道端点将有效负载转发到 GRE 隧道中,以便将数据包路由到目标。到达终点后,GRE 封装将被删除,有效负载将传输到其最终目的地。GRE 的主要用途是通过 IP 网络传输非 IP 数据包;但是,GRE 也用于通过 IP 云传输 IP 数据包。
要求
-
配置 GRE (gr-) 接口。gr- 接口包含本地地址和目标地址。配置完成后,它会立即启动。您甚至可以在 gr- 接口上配置 IP 地址。
-
配置路由以到达目标子网(端到端连接)。您可以通过 gr- 接口配置静态路由,也可以使用内部网关协议 (IGP),例如 OSPF。
概述
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 系列防火墙上隧道接口之间的默认配置。
配置被测设备 (DUT)
分步过程
您可以通过 gr- 接口或使用 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
-
配置目标子网。
[edit interfaces] user@host# set interfaces ge-0/0/1 unit 0 family inet address 10.1.12.1/24
-
配置 gr- 隧道端点,并将源地址、目标地址和族指定为隧道端点的 inet。
[edit interfaces] user@host# set interfaces gr-0/0/0 unit 0 tunnel source 192.168.1.1 destination 192.168.1.2 user@host# set interfaces gr-0/0/0 unit 0 family inet address 192.168.255.1
-
将 GRE 隧道接口 gr-0/0/0 绑定到安全区域。
[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
-
配置到目标子网的静态路由,并将 GRE 隧道接口作为下一跃点。
[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] user@host# set protocols ospf area 0.0.0.0 interface gr-0/0/0.0 user@host# set protocols ospf area 0.0.0.0 interface ge-0/0/0.0 passive
CLI 快速配置
set interfaces ge-0/0/0 unit 0 family inet address 10.10.11.1/24 set interfaces gr-0/0/0 unit 0 tunnel source 192.168.1.1 set interfaces gr-0/0/0 unit 0 tunnel destination 192.168.1.2 set interfaces gr-0/0/0 unit 0 family inet address 192.168.255.1/30 set interfaces ge-0/0/1 unit 0 family inet address 10.1.12.1/24 set protocols ospf area 0.0.0.0 interface gr-0/0/0.0 set protocols ospf area 0.0.0.0 interface ge-0/0/0.0 passive set routing-options static route 10.10.10.0/24 next-hop gr-0/0/0.0 set security zones security-zone trust host-inbound-traffic system-services all set security zones security-zone trust host-inbound-traffic protocols all set security zones security-zone trust interfaces 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 192.168.1.1; destination 192.168.1.2; } family inet { address 192.168.255.1/30; } } } 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; }
[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
运行命令:
user@SRX-1>show interfaces gr-0/0/0 terse Interface Admin Link Proto Local Remote gr-0/0/0 up up gr-0/0/0.0 up up inet 192.168.255.1/30
意义
GRE 接口已打开。
验证到目标子网的可访问性
目的
验证目标网络的路由是否可通过 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 隧道接口访问目标网络。
使用 ping 命令验证端到端可访问性
user@SRX-1> ping 10.10.10.2 source 10.10.11.1 rapid count 100 PING 10.10.10.2 (10.10.10.2): 56 data bytes !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --- 10.10.10.2 ping statistics --- 100 packets transmitted, 100 packets received, 0% packet loss round-trip min/avg/max/stddev = 0.831/1.033/10.033/1.286 ms
通过 IPsec 隧道配置 GRE
概述
GRE 隧道提供最低的安全性,而 IPsec 隧道在机密性、数据身份验证和完整性保证方面提供增强的安全性。此外,IPsec 不能直接支持组播数据包。但是,如果首先使用封装的 GRE 隧道,则可以使用 IPsec 隧道为组播数据包提供安全性。在 GRE over IPsec 隧道中,所有路由流量(IP 和非 IP)都可以通过。当原始数据包(IP/非 IP)被 GRE 封装时,它具有由 GRE 隧道定义的 IP 报头,通常是隧道接口 IP 地址。IPsec协议可以理解IP数据包;因此,它会封装 GRE 数据包,使其成为通过 IPsec 的 GRE。
通过 IPsec 配置 GRE 所涉及的基本步骤如下:
-
配置基于路由的 IPsec 隧道。
-
配置 GRE 隧道。
-
通过 gr- 接口配置静态路由,目标作为远程子网。
-
将 GRE 端点的静态路由配置为下一跃点,并将 st0 接口配置为下一跃点。
配置
在此示例中,默认配置的本地子网接口为 ge-0/0/0,IPv4 地址为 10.10.11.1/24。目标子网为 10.10.10.0/24。gr-0/0/0 接口隧道端点是两端的环路地址,本地环路 IPv4 地址为 192.168.0.1,远程环路 IPv4 地址为 192.168.0.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- 隧道端点,并将源地址、目标地址和族指定为隧道端点的 inet。
[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
同样,配置 lo0 和 st0 接口,并将家族设置为 inet。
[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- 接口之间配置 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- 接口和 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 接口。
分步过程
配置 GRE 隧道,并将 gr-0/00 接口和家族设置为 inet。
[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- 接口和 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