教程:为 BYOIP 前缀设置委派的 RPKI
本教程从头到尾介绍所有 BGP 路由保护功能。您可以在任何步骤后停止并使用到目前为止设置的内容。步骤 1 和 2 不需要 RIR 交互。步骤 3 及后续步骤需要使用 RIR 进行一次性设置。有关 BGP 路由保护概念、套餐要求和支持的 RIR 的背景,请参阅监控 BGP 路由保护。
先决条件
在高级套餐中创建的 IPAM。
向 IPAM 池预置了一个或多个 BYOIP 前缀。
可访问区域互联网注册机构账户(ARIN、RIPE、APNIC 或 LACNIC)。
步骤 1:查看 BGP 路由
向 IPAM 预置 BYOIP 前缀后,即可在集中式控制面板中查看所有广播路由。
步骤 2:查看路由保护调查发现
对于高级套餐客户,IPAM 会根据发布的 ROA 数据评估路由,并通过 get-ipam-route-protection-findings 显示调查发现。
注意
get-ipam-route-protection-findings 需要高级套餐。免费套餐客户会收到 UnsupportedOperation 错误。
列出所有调查发现。
aws ec2 get-ipam-route-protection-findings \ --ipam-id ipam-0a1b2c3d4e5f6g7h8筛选无效或缺失的 ROA。
aws ec2 get-ipam-route-protection-findings \ --ipam-id ipam-0a1b2c3d4e5f6g7h8 \ --filters "Name=rpki-status,Values=invalid,unknown"按特定区域的状态进行筛选。
aws ec2 get-ipam-route-protection-findings \ --ipam-id ipam-0a1b2c3d4e5f6g7h8 \ --filters "Name=rpki-status,Values=invalid" "Name=resource-region,Values=us-west-2"
下面是示例输出。
{ "IpamId": "ipam-0a1b2c3d4e5f6g7h8", "RouteProtectionFindings": [ { "ResourceOwnerId": "123456789012", "ResourceRegion": "us-west-2", "IpamPoolId": "ipam-pool-0da89c821626f1e4b", "Cidr": "203.0.113.0/24", "State": "advertised", "AdvertisementType": "regional", "NetworkBorderGroup": "us-west-2", "PoolId": "ipv4pool-ec2-0a1b2c3d4e5f6g7h8", "Asn": "64512", "RpkiStatus": "valid", "RpkiStrength": "strict", "Roas": [ { "Asn": "64512", "Prefix": "203.0.113.0/24", "MaxLength": 24, "Match": true, "Expiration": "2027-06-15T00:00:00Z" } ], "RouteOverlaps": [ { "Prefix": "203.0.113.128/25", "Asn": "64513", "DetectedAt": "2026-03-10T15:45:00+00:00" } ], "SampleTime": "2026-03-10T15:30:00+00:00", "RoaSampleTime": "2026-03-10T16:00:00+00:00" } ] }
有效的筛选条件名称为 cidr、account-id、resource-region、byoip-cidr-state、advertisement-type、network-border-group、ipam-pool-id、rpki-status 和 asn。这些 EC2 风格的筛选条件名称并不总是与返回的字段匹配。例如,您按 account-id 进行筛选,但响应返回 ResourceOwnerId;您按 byoip-cidr-state 进行筛选,但字段是 State。ROA 强度不可筛选。
步骤 3:设置委派的 RPKI
委派的 RPKI 允许您授权 Amazon 代表您管理 ROA。
-
创建互联网注册机构关联。
aws ec2 create-ipam-internet-registry-association --region us-east-1 \ --ipam-id ipam-0de83dba6694560a9 \ --rir ARIN --org-handle my-arin-org下面是示例输出。
{ "IpamInternetRegistryAssociation": { "IpamInternetRegistryAssociationId": "ipam-internet-registry-assoc-036486dfa6af58ee0", "State": "create-in-progress" } }运行以下命令,直到状态变为
pending-enable。aws ec2 describe-ipam-internet-registry-associations --region us-east-1 \ --ipam-internet-registry-association-ids ipam-internet-registry-assoc-036486dfa6af58ee0一旦状态为
pending-enable,ChildRequestXml 即可提交给您的 RIR。IPAM 根据公共 VRP(已验证的 ROA 有效载荷)数据暂存 ROA。它们处于待处理状态,将在启用互联网注册机构关联后激活。 -
查看暂存的 ROA。
aws ec2 get-ipam-route-origin-authorizations --region us-east-1 \ --ipam-internet-registry-association-id ipam-internet-registry-assoc-036486dfa6af58ee0下面是示例输出。
{ "Roas": [ { "prefix": "18.96.0.0/14", "asn": "77221", "maxLength": "24", "state": "pending-activate" } ] } -
启用互联网注册机构关联。
将 ChildRequestXML 带到您的 RIR 门户并提交委派请求。RIR 返回父响应 XML。从该响应提取下面的字段:RpkiVersion、ServiceUri、ChildHandle、ParentHandle 和 ParentBpkiTa。然后调用以下命令。
aws ec2 enable-ipam-internet-registry-association --region us-east-1 \ --ipam-internet-registry-association-id ipam-internet-registry-assoc-036486dfa6af58ee0 \ --rpki-version "..." \ --service-uri "..." \ --child-handle "..." \ --parent-handle "..." \ --parent-bpki-ta "..."下面是示例输出。
{ "IpamInternetRegistryAssociation": { "IpamInternetRegistryAssociationId": "ipam-internet-registry-assoc-036486dfa6af58ee0", "State": "enable-in-progress" } }运行以下命令,直到状态变为
enable-complete。aws ec2 describe-ipam-internet-registry-associations --region us-east-1 \ --ipam-internet-registry-association-ids ipam-internet-registry-assoc-036486dfa6af58ee0一旦状态为
enable-complete,暂存的 ROA 将转换为create-complete。Amazon 现在管理此关联下所有 CIDR 的 ROA 生命周期。 -
查看关联的 CIDR。
aws ec2 get-ipam-internet-registry-association-cidrs --region us-east-1 \ --ipam-internet-registry-association-id ipam-internet-registry-assoc-036486dfa6af58ee0下面是示例输出。
{ "IpamInternetRegistryAssociationCidrs": [ { "Cidr": "18.96.0.0/14", "LastObservedAt": "2026-07-30T18:00:00.000Z" } ] } -
查看关联的 ASN。
aws ec2 get-ipam-internet-registry-association-asns --region us-east-1 \ --ipam-internet-registry-association-id ipam-internet-registry-assoc-036486dfa6af58ee0下面是示例输出。
{ "IpamInternetRegistryAssociationAsns": [ { "Asn": "77221", "LastObservedAt": "2026-07-30T18:00:00.000Z" } ] }
步骤 4:预置 BYOIP 并自动创建 ROA
通过激活委派的 RPKI,可以简化预置。
| 之前(没有委派的 RPKI) | 之后(具有委派的 RPKI) |
|---|---|
必须提供 --cidr-authorization-context |
仍然传递 --cidr-authorization-context,但具有 Message="CoveredByInternetRegistryAssociation",Signature="",无需签名消息 |
| 必须通过 WHOIS 或 DNS TXT 记录进行验证 | 不需要:IPAM 根据关联 CIDR 进行验证 |
| 广播之前必须在 RIR 手动创建 ROA | 预置时自动创建 ROA |
| 到期之前必须手动续订 ROA | Amazon 自动续订:无需任何操作 |
aws ec2 provision-ipam-pool-cidr \ --cidr 18.97.16.0/24 \ --ipam-pool-id ipam-pool-0da89c821626f1e4b \ --cidr-authorization-context Message="CoveredByInternetRegistryAssociation",Signature="" \ --region us-east-1
IPAM 通过互联网注册机构关联验证所有权,并创建与池的区域设置和 ASN 匹配的严格 ROA。没有手动 ROA 步骤。
步骤 5:管理本地前缀的 ROA
对于未引入 Amazon 的 IP 空间,请使用路由策略注册(RPR)。
-
创建 RPR。
aws ec2 create-ipam-routing-policy-registration --region us-east-1 \ --ipam-id ipam-0de83dba6694560a9 \ --ipam-internet-registry-association-id ipam-internet-registry-assoc-036486dfa6af58ee0 \ --cidr 18.96.0.0/14 --asns 77221,13446 \ --permit-more-specific-announcements下面是示例输出。
{ "deltaId": "0130c368-1f8c-4283-8f16-66e67e633086", "state": "PENDING" } -
检查增量状态。如果更改会使现有路由失效,则会失败并出现错误。请使用
--force进行覆盖。aws ec2 get-ipam-routing-policy-registration-deltas --region us-east-1 \ --ipam-id ipam-0de83dba6694560a9 \ --ipam-internet-registry-association-id ipam-internet-registry-assoc-036486dfa6af58ee0 \ --delta-id 0130c368-1f8c-4283-8f16-66e67e633086 -
批量更新(原子)。批量更新以原子方式成功或失败。不会部分应用。
aws ec2 batch-modify-ipam-routing-policy-registrations --region us-east-1 \ --ipam-id ipam-0de83dba6694560a9 \ --ipam-internet-registry-association-id ipam-internet-registry-assoc-036486dfa6af58ee0 \ --delta-json file://delta.json其中
delta.json包含以下内容。{ "Add": [ { "prefix": "18.96.0.0/14", "asns": ["77221", "13446"], "permit-more-specific-announcements": "false" } ], "Delete": [ { "prefix": "18.97.16.0/24", "asns": ["77221", "13446"], "permit-more-specific-announcements": "false" } ] } -
查看关联的所有注册。
aws ec2 get-ipam-routing-policy-registrations --region us-east-1 \ --ipam-internet-registry-association-id ipam-internet-registry-assoc-036486dfa6af58ee0下面是示例输出。
{ "IpamRoutingPolicyRegistrations": [ { "Cidr": "18.96.0.0/14", "Asns": ["77221", "13446"], "PermitMoreSpecificAnnouncements": false, "MaxLength": 14, "LatestDeltaId": "0130c368-1f8c-4283-8f16-66e67e633086", "State": "create-complete" }, { "Cidr": "18.97.16.0/24", "Asns": ["77221", "13446"], "PermitMoreSpecificAnnouncements": false, "MaxLength": 24, "LatestDeltaId": "0130c368-1f8c-4283-8f16-66e67e633086", "State": "create-complete" } ] } -
筛选到特定前缀。
aws ec2 get-ipam-routing-policy-registrations --region us-east-1 \ --ipam-internet-registry-association-id ipam-internet-registry-assoc-036486dfa6af58ee0 \ --cidr 18.96.0.0/14
步骤 6:为路由异常设置 CloudWatch 警报
IPAM 针对每个 BYOIP 路由向全局 IPAM 账户发布 CloudWatch 指标。RoaExpiration 指标将发布到 AWS/IPAM 命名空间,包含 Cidr、RoaPrefix、Asn 和 MaxLength 维度。
| 类型 | 名称 | 描述 |
|---|---|---|
| 指标 | RoaExpiration | ROA 到期前的天数 |
| 维度 | Asn | 前缀的 ASN |
| 维度 | Cidr | 通过 BYOIP 引入的 CIDR |
| 维度 | MaxLength | 来自 ROA 的 MaxLength |
| 维度 | RoaPrefix | 来自 ROA 的前缀 |
由于 RoaExpiration 会报告 ROA 到期前的剩余天数,因此当该值降至阈值或低于阈值时,应触发警报。指定全部四个维度以针对单个 ROA。请在发布该指标的同一账户和区域内创建警报。
aws cloudwatch put-metric-alarm --region us-east-1 \ --alarm-name "IPAM-RoaExpiration-203.0.113.0-24" \ --alarm-description "Alert when the ROA for 203.0.113.0/24 is within 30 days of expiration" \ --namespace "AWS/IPAM" \ --metric-name RoaExpiration \ --dimensions Name=Cidr,Value=203.0.113.0/24 Name=RoaPrefix,Value=203.0.113.0/24 Name=Asn,Value=64512 Name=MaxLength,Value=24 \ --statistic Minimum \ --period 86400 \ --evaluation-periods 1 \ --threshold 30 \ --comparison-operator LessThanOrEqualToThreshold \ --treat-missing-data notBreaching \ --alarm-actions arn:aws:sns:us-east-1:123456789012:roa-expiry-notifications
资源清理
要移除委派的 RPKI 资源,请执行下面的操作:
删除所有路由策略注册。
取消与互联网注册机构关联的关联。
(可选)在 RIR 门户中移除授权。
重要
删除互联网注册机构关联会移除该关联的所有 Amazon 托管 ROA。在取消关联之前,请确保路由具有备用 ROA 覆盖范围。