在此页面上
RSH ALG
远程外壳 (RSH) 提供在远程主机上执行命令的管道。与在远程系统上创建终端外壳会话的 Telnet 或 SSH 不同,RSH 通过命令和认证数据。协议使用 514 TCP 端口传递认证数据和命令。服务器将命令的螺柱返回到客户端的源端口。RSH 要求 ALG 将第二个客户端端口传递至服务器,以便传输接线器流。
了解 RSH ALG
远程外壳 (RSH) 应用层网关 (ALG) 处理 RSH 数据包,这些数据包可启动请求并打开两个门,以允许数据包从反向返回至客户端。一个门用于识别(标识)会话以应用授权,另一个门用于标准错误 (stderr) 会话以传输错误消息。
如果配置了端口地址转换 (PAT),RSH ALG 将无法工作。RSH 要求端口范围在 512 到 1024 之间。源 NAT 模块无法匹配此端口范围。
另请参阅
示例:配置 RSH ALG
此示例说明如何在路由或 NAT 模式下配置 RSH ALG。该配置允许 RSH 流量通过设备,并在位于瞻博网络设备对面的客户端和服务器之间传输远程命令和结果。
要求
此示例使用以下硬件和软件组件:
SRX 系列设备
两个 PC(服务器和客户端)
开始之前:
了解 ALG 背后的概念。请参阅 ALG 概述
了解 RSH ALG 的基础知识。查看 了解 RSH ALG
概述
在此示例中,首先在设备上配置网络接口。创建安全区域并将接口分配给这些区域,并配置策略以允许 RSH 流量通过 SRX 系列设备。
然后,您将创建一个静态 NAT 规则集 rs1,其中包含一个规则 r1,以与目标地址 40.0.172.10/32 匹配,然后创建具有地址 40.0.172.45/32 的静态 NAT 前缀。
接下来,您将创建一个源 NAT 池 src-p1,并使用源规则集 src-rs1 将数据包从接口 fe-3/0/0.0 转换为接口 fe-3/0/1.0。对于匹配的数据包,源地址将转换为 src-p1 池中的 IP 地址。
然后,您将创建带有目标规则集 des-rs1 的目标 NAT 池,将数据包从区域信任转换为目标地址 40.0.172.10/32。对于匹配的数据包,目标地址将转换为 des-p1 池中的 IP 地址。最后,您可启用 RSH ALG 追踪选项。
配置
要配置 RSH ALG,请执行以下任务:
配置路由模式
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,移除任何换行符,更改与网络配置匹配所需的任何详细信息,将命令复制并粘贴到层级的 CLI 中 [edit]
,然后从配置模式进入 commit
。
set interfaces ge-0/0/0 unit 0 family inet address 10.208.172.58/21 set interfaces fe-3/0/0 unit 0 family inet address 30.3.3.149/8 set interfaces fe-3/0/1 unit 0 family inet address 40.4.4.149/8 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 fe-3/0/0.0 set security zones security-zone untrust host-inbound-traffic system-services all set security zones security-zone untrust host-inbound-traffic protocols all set security zones security-zone untrust interfaces fe-3/0/1.0 set security policies from-zone trust to-zone untrust policy rsh match source-address any set security policies from-zone trust to-zone untrust policy rsh match destination-address any set security policies from-zone trust to-zone untrust policy rsh match application junos-rsh set security policies from-zone trust to-zone untrust policy rsh then permit
逐步过程
以下示例要求您在配置层次结构中导航各个级别。有关如何执行此操作的说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器。
要配置路由模式:
配置接口。
[edit interfaces] user@host#set ge-0/0/0 unit 0 family inet address 10.208.172.58/21 user@host#set fe-3/0/0 unit 0 family inet address 30.3.3.149/8 user@host#set fe-3/0/1 unit 0 family inet address 40.4.4.149/8
配置区域并将接口分配给各区域。
[edit security zones security-zone] user@host#set trust host-inbound-traffic system-services all user@host#set trust host-inbound-traffic protocols all user@host#set trust interfaces fe-3/0/0.0 user@host#set untrust host-inbound-traffic system-services all user@host#set untrust host-inbound-traffic protocols all user@host#set untrust interfaces fe-3/0/0.1
配置 RSH 策略,允许从信任区域到不信任区域的 RSH 流量。
[edit security policies from-zone trust to-zone untrust] user@host#set policy rsh match source-address any user@host#set policy rsh match destination-address any user@host#set policy rsh match application junos-rsh user@host#set policy rsh then permit
结果
在配置模式下,输入 show interfaces
、 show security zones
和 show security policies
命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的配置说明以进行更正。
简洁性,此 show
输出仅包含与此示例相关的配置。系统上的任何其他配置都已替换为椭圆 (...)。
[edit] user@host# show interfaces ge-0/0/0 { unit 0 { family inet { address 10.208.172.58/21; } } } fe-3/0/0 { unit 0 { family inet { address 30.3.3.149/8; } } } fe-3/0/1 { unit 0 { family inet { address 40.4.4.149/8; } } }
[edit] user@host# show security zones .. security-zone trust { host-inbound-traffic { system-services { all; } protocols { all; } } interfaces { fe-3/0/0.0; } } security-zone untrust { host-inbound-traffic { system-services { all; } protocols { all; } } interfaces { fe-3/0/1.0; } } ...
[edit] user@host# show security policies from-zone trust to-zone untrust { policy rsh { match { source-address any; destination-address any; application junos-rsh; } then { permit; } } }
如果完成设备配置,请在配置模式下输入 commit
。
配置静态 NAT 规则集
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,移除任何换行符,更改与网络配置匹配所需的任何详细信息,将命令复制并粘贴到层级的 CLI 中 [edit]
,然后从配置模式进入 commit
。
set security nat static rule-set rs1 from zone trust set security nat static rule-set rs1 rule r1 match destination-address 40.0.172.10/32 set security nat static rule-set rs1 rule r1 then static-nat prefix 40.0.172.45/32
逐步过程
以下示例要求您在配置层次结构中导航各个级别。有关如何执行此操作的说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器。
要配置静态 NAT 规则集:
创建静态 NAT 规则集。
[edit security nat static rule-set rs1] user@host#set from zone trust
定义与目标地址匹配的规则。
[edit security nat static rule-set rs1] user@host# set rule r1 match destination-address 40.0.172.10/32
定义设备的静态 NAT 前缀。
[edit security nat static rule-set rs1] user@host# set rule r1 then static-nat prefix 40.0.172.45/32
结果
在配置模式下,输入 show security nat
命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的配置说明以将其更正。
[edit] user@host# show security nat static { rule-set rs1 { from zone trust; rule r1 { match { destination-address 40.0.172.10/32; } then { static-nat { prefix { 40.0.172.45/32; } } } } } }
如果完成设备配置,请在配置模式下输入 commit
。
在不使用 PAT 的情况下配置源 NAT 池和规则集
CLI 快速配置
RSH ALG 不支持 PAT 配置。RSH ALG 要求接线器端口范围在 512 到 1024 之间。源 NAT 模块无法匹配此端口范围。
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,移除任何换行符,更改与网络配置匹配所需的任何详细信息,将命令复制并粘贴到层级的 CLI 中 [edit]
,然后从配置模式进入 commit
。
set security nat source pool src-p1 address 40.0.172.100/32 to 40.0.172.101/32 set security nat source pool src-p1 port no-translation set security nat source rule-set src-rs1 from interface fe-3/0/0.0 set security nat source rule-set src-rs1 to interface fe-3/0/1.0 set security nat source rule-set src-rs1 rule r1 match source-address 30.0.0.0/8 set security nat source rule-set src-rs1 rule r1 match destination-address 40.0.0.0/8 set security nat source rule-set src-rs1 rule r1 then source-nat pool src-p1
逐步过程
以下示例要求您在配置层次结构中导航各个级别。有关如何执行此操作的说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器。
要配置源 NAT 池和规则集:
创建源 NAT 池。
[edit security nat source] user@host#set pool src-p1 address 40.0.172.100/32 to 40.0.172.101/32
创建无端口转换的源 NAT 池。
[edit security nat source ] set pool src-p1 port no-translation
创建源 NAT 规则集。
[edit security nat source] user@host# set rule-set src-rs1 from interface fe-3/0/0.0 user@host# set rule-set src-rs1 to interface fe-3/0/1.0
配置匹配数据包的规则,并将源地址转换为源池中的地址。
[edit security nat source] user@host# set rule-set src-rs1 rule r1 match source-address 30.0.0.0/8
配置匹配数据包的规则,并将目标地址转换为源池中的地址。
[edit security nat source] user@host# set rule-set src-rs1 rule r1 match destination-address 40.0.0.0/8
在规则中配置源 NAT 池。
[edit security nat source] user@host# set rule-set src-rs1 rule r1 then source-nat pool src-p1
结果
在配置模式下,输入 show security nat
命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的配置说明以将其更正。
[edit] user@host# show security nat source { pool src-p1 { address { 40.0.172.100/32 to 40.0.172.101/32; } port no-translation; } rule-set src-rs1 { from interface fe-3/0/0.0; to interface fe-3/0/1.0; rule r1 { match { source-address 30.0.0.0/8; destination-address 40.0.0.0/8; } then { source-nat { pool { src-p1; } } } } } }
如果完成设备配置,请在配置模式下输入 commit
。
配置目标 NAT 池和规则集
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,移除任何换行符,更改与网络配置匹配所需的任何详细信息,将命令复制并粘贴到层级的 CLI 中 [edit]
,然后从配置模式进入 commit
。
set security nat destination pool des-p1 address 40.0.172.45/32 set security nat destination rule-set des-rs1 from zone trust set security nat destination rule-set des-rs1 rule des-r1 match source-address 30.0.172.12/32 set security nat destination rule-set des-rs1 rule des-r1 match destination-address 40.0.172.10/32 set security nat destination rule-set des-rs1 rule des-r1 then destination-nat pool des-p1
逐步过程
以下示例要求您在配置层次结构中导航各个级别。有关如何执行此操作的说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器。
要配置目标 NAT 池和规则集:
创建目标 NAT 池。
[edit security nat destination] user@host#set pool des-p1 address 40.0.172.45/32
创建目标 NAT 规则集。
[edit security nat destination] user@host# set rule-set des-rs1 from zone trust
配置匹配数据包并将源地址转换为池中地址的规则。
[edit security nat destination] user@host# set rule-set des-rs1 rule des-r1 match source-address 30.0.172.12/32
配置匹配数据包并将目标地址转换为池中地址的规则。
[edit security nat destination] user@host# set rule-set des-rs1 rule des-r1 match destination-address 40.0.172.10/32
在规则中配置源 NAT 池。
[edit security nat destination] user@host# set rule-set des-rs1 rule des-r1 then destination-nat pool des-p1
结果
在配置模式下,输入 show security nat
命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的配置说明以将其更正。
[edit] user@host# show security nat destination { pool des-p1 { address { 40.0.172.45/32; } } rule-set des-rs1 { from zone trust; rule des-r1 { match { source-address 30.0.172.12/32; destination-address 40.0.172.10/32; } then { destination-nat { pool { des--p1; } } } } } }
如果完成设备配置,请在配置模式下输入 commit
。
启用 RSH ALG 追踪选项
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,移除任何换行符,更改与网络配置匹配所需的任何详细信息,将命令复制并粘贴到层级的 CLI 中 [edit]
,然后从配置模式进入 commit
。
set security alg rsh traceoptions flag all set security alg traceoptions file trace set security alg traceoptions file size 1g set security alg traceoptions level verbose
逐步过程
以下示例要求您在配置层次结构中导航各个级别。有关如何执行此操作的说明,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器。
要启用 RSH ALG 追踪选项:
启用 RSH ALG 追踪选项。
[edit security alg] user@host#set sql traceoptions flag all
配置文件名以接收跟踪操作的输出。
[edit security alg] user@host#set traceoptions file trace
指定最大追踪文件大小。
[edit security alg] user@host#set traceoptions file size 1g
指定追踪输出级别。
[edit security alg] user@host#set traceoptions level verbose
结果
在配置模式下,输入 show security alg
命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的配置说明以将其更正。
[edit] user@host# show security alg traceoptions { file trace size 1g; level verbose; } rsh traceoptions flag all;
如果完成设备配置,请在配置模式下输入 commit
。
验证
确认配置工作正常。
验证 RSH ALG 控制会话
目的
验证 RSH 命令是否已执行,以及是否已创建所有 RSH 控制和数据会话。
行动
在操作模式下,输入 show security flow session
命令。
user@host>show security flow session Session ID: 2924, Policy name: rsh/6, Timeout: 2, Valid Resource information : RSH ALG, 2, 0 In: 30.0.172.12/1023 --> 40.0.172.45/514;tcp, If: fe-3/0/0.0, Pkts: 7, Bytes: 320 Out: 40.0.172.45/514 --> 30.0.172.12/1023;tcp, If: fe-3/0/1.0, Pkts: 7, Bytes: 314 Session ID: 2925, Policy name: rsh/6, Timeout: 2, Valid Resource information : RSH ALG, 2, 24 In: 40.0.172.45/44864 --> 30.0.172.12/113;tcp, If: fe-3/0/1.0, Pkts: 5, Bytes: 278 Out: 30.0.172.12/113 --> 40.0.172.45/44864;tcp, If: fe-3/0/0.0, Pkts: 5, Bytes: 345 Session ID: 2926, Policy name: rsh/6, Timeout: 2, Valid Resource information : RSH ALG, 2, 23 In: 40.0.172.45/1023 --> 30.0.172.12/1022;tcp, If: fe-3/0/1.0, Pkts: 4, Bytes: 216 Out: 30.0.172.12/1022 --> 40.0.172.45/1023;tcp, If: fe-3/0/0.0, Pkts: 3, Bytes: 164 Total sessions: 3
意义
Session ID—用于标识会话的编号。使用此 ID 获取有关会话的更多信息,例如策略名称、进出的数据包数。
Policy name—允许信息流的策略名称。
In— 传入流量(源和目标 IP 地址及其相应的源和目标端口号、会话为 TCP,且此会话的源接口为 fe-3/0/0.0)。
Out— 反向流量(源和目标 IP 地址及其相应的源和目标端口号,会话为 TCP,此会话的目标接口为 fe-3/0/1.0)。
验证 RSH ALG
目的
验证 RSH ALG 是否启用。
行动
在操作模式下,输入 show security alg status
命令。
user@host>show security alg status ALG Status : PPTP : Enabled RSH : Disabled RTSP : Enabled SCCP : Enabled SIP : Enabled TALK : Enabled TFTP : Enabled IKE-ESP : Disabled
默认情况下,RSH ALG 禁用。要启用 RSH ALG,请在配置模式下输入 set security alg rsh
命令。
意义
输出显示以下 RSH ALG 状态:
启用 — 显示已启用 RSH ALG。
禁用 — 显示 RSH ALG 已禁用。
验证 RSH ALG 资源管理器组
目的
验证 RSH ALG 使用的资源管理器组和活动组的总数。
行动
在操作模式下,输入 show security resource-manager group active
命令。
user@host>show security resource-manager group active Group ID 1: Application - RSH ALG Total groups 677, active groups 1
验证 RSH ALG 资源信息
目的
验证 RSH ALG 使用的资源和活动资源总数。
行动
在操作模式下,输入 show security resource-manager resource active
命令。
user@host>show security resource-manager resource active Resource ID 2: Group ID - 1, Application - RSH ALG Resource ID 1: Group ID - 1, Application - RSH ALG Total Resources 4044, active resources 2