# 在 RIR 中注册 ROA/RPKI

要在 zenConsole 上启用 BYOIP (Bring Your Own IP)，需要在 RIR (Regional Internet Registry，区域互联网注册机构) 中注册 ROA/RPKI (Route Origin Authorization / Resource Public Key Infrastructure)。这要求您验证 IP 归属并发布 ROA (Route Origin Authorization)。

## 前提条件

1. 确认您的 IP 地址是由 RIR（ARIN、RIPE NCC、APNIC、LACNIC 或 AFRINIC）分配给您的。
2. 准备将用于宣告 IP 地址块的 ASN（自治系统号），Zenlayer 弹性算力的 ASN 为 **`62610`**。
3. 需要进行 RPKI/ROA 验证，以防止路由劫持。

## 操作步骤

{% stepper %}
{% step %}

#### **生成 RSA 私钥和自签名 X.509 证书**

使用以下 OpenSSL 命令生成 RSA 私钥和自签名 X.509 证书：

```bash
openssl genpkey -aes256 -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private-key.pem
openssl req -new -x509 -key private-key.pem -out certificate.pem -days 365
```

执行过程中，系统会提示您为私钥设置密码，并填写证书信息，包括：

* Country Name (C)：国家代码（如美国为 `US`）
* State or Province Name (ST)：州/省全名
* Locality Name (L)：城市名称
* Organization Name (O)：组织名称
* Organizational Unit Name (OU)：部门名称
* Common Name (CN)：证书对应的完整域名（如 `www.example.com`）

生成的文件包括：

* `private-key.pem`：RSA 私钥
* `certificate.pem`：自签名 X.509 证书
  {% endstep %}

{% step %}

#### **将证书上传至 RIR 的 RDAP 记录**

1. 登录到您的 RIR 成员门户（例如 ARIN、RIPE NCC、APNIC 等）：
   * ARIN Online: <https://account.arin.net>
   * RIPE NCC Access: <https://access.ripe.net>
   * MyAPNIC: <https://my.apnic.net>
   * MiLACNIC: <https://milacnic.lacnic.net>
   * MyAFRINIC: <https://my.afrinic.net>
2. 找到您要更新的 IP 前缀对象。
3. 编辑该对象的 **remarks** 字段。
4. 将 `certificate.pem` 文件内容粘贴到 **remarks** 字段中。
5. 提交修改。

这样会将您的自签名证书与 IP 前缀关联到 RIR 的 RDAP 记录。
{% endstep %}

{% step %}

#### **创建 ROA**

ROA 是一种加密声明，证明某个 ASN 有权公告指定的 IP 前缀。

1. 确认将公告 IPv4 地址块的 ASN。
2. 进入 RIR 门户的 RPKI/ROA 管理页面，例如：
   * ARIN: “Resource Certificates / ROA”
   * RIPE NCC: “RPKI” → “Create ROA”
   * APNIC: “RPKI Manager”
3. 创建 ROA：
   * Prefix：要在 zenConsole 使用的 IP 前缀
   * Max length：通常与前缀长度一致（如 IPv4 的 `/24`）
   * Origin ASN：用于公告前缀的 ASN，可为您的 ASN 或云服务商提供的 ASN（Zenlayer 的 ASN 为 `62610`）
     {% endstep %}

{% step %}

#### **发布 ROA**

ROA 创建后将被数字签名并发布到 RPKI 仓库。大多数云服务商会定期在全球 RPKI 仓库中验证 ROA。
{% endstep %}

{% step %}

#### **验证 ROA 传播情况**

可使用以下工具进行验证：

* [RIPEstat](https://stat.ripe.net/)
* [RPKI Validator](https://rpki-validator.ripe.net/ui/)

确认 ROA 状态为 **valid**，且前缀和 ASN 匹配。
{% endstep %}
{% endstepper %}

{% hint style="info" %} <mark style="color:blue;">**注意**</mark>

* <mark style="color:blue;">确保 ROA 覆盖的前缀长度与计划公告的长度完全一致，否则会导致验证失败。</mark>
* <mark style="color:blue;">ROA 的创建可能需要数分钟至数小时才能在 RPKI 缓存中生效。</mark>
  {% endhint %}

## 下一步操作

建议在启用 BYOIP 前，在 IRR（Internet Routing Registry）中[注册对应的 route object](/welcome/cn/elastic-compute/get-started/manage-networking/advertise-byoip/register-a-route-object-in-the-irr.md)。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.console.zenlayer.com/welcome/cn/elastic-compute/get-started/manage-networking/advertise-byoip/register-roa-rpki-with-rir.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
