> For the complete documentation index, see [llms.txt](https://www.axisnow.io/zh/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.axisnow.io/zh/docs/guide/dns-routing-gtm.md).

# DNS 优选和故障切换

使用 AxisNow 实现基于策略的流量调度，确保应用服务的访问速度和高可用。

## 前言 <a href="#preface" id="preface"></a>

传统的 CDN 提供商需要您将域名指向到其 CNAME 或进行 DNS 托管。**AxisNow 不同的是将 DNS 和 Proxy 进行松耦合设计。**&#x5B83;们之间的工作流互不干扰。这意味着：

* 您可以独立使用 AxisNow 边缘代理。AxisNow 的 边缘代理配置是在您的租户内所有边缘同步生效。您将流量路由至任意的 EIP 都可提供服务。如何将您的流量路由至 EIP 取决于您的用例。
* 您也可以独立使用 AxisNow 的 DNS 路由无需部署边缘代理。通过 AxisNow 托管服务或与您的 DNS 提供商集成，提供强大的全局流量管理。实现基于策略的流量调度，确保应用服务的**访问速度和高可用**。

## 先决条件 <a href="#prerequisites" id="prerequisites"></a>

* [创建 AxisNow 租户](https://dashboard.axisnow.io/signup)。
* 订阅 DNS 路由插件和边缘拨测插件。
* 使用 AxisNow 免费的托管调度域可快速开始（本文示例）。
* 如果您希望使用自己的调度域则需要[集成 DNS 提供商](/zh/docs/edge/integration/dns-provider.md)。

## 多 IP 优选和故障切换 <a href="#multi-ip-failover" id="multi-ip-failover"></a>

<figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-9aa485eb310d8a765a81d72b1f9e4fe9827f3ade%2Fimage%20(203).png?alt=media" alt=""><figcaption></figcaption></figure>

### 步骤指引 <a href="#ip-steps" id="ip-steps"></a>

{% stepper %}
{% step %}

#### 创建 A 记录类型调度域 <a href="#create-a-record-routing-domain" id="create-a-record-routing-domain"></a>

进入 DNS 路由单击右上角新增按钮，出现创建调度域的弹窗选择页面。图例中我们创建了 `8e810139.alidns-2.com`。

<figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-da906d6a59846e557331ebe221b44b18913f6d6e%2Fimage%20(241).png?alt=media" alt=""><figcaption></figcaption></figure>

AxisNow 免费提供了两个托管的调度域，托管在**阿里云和 AWS** 供您选择。若您希望覆盖中国大陆，阿里云具备更精细的中国大陆线路和地理位置。若您希望覆盖国际业务，我们建议 AWS 是一个更好的选择。
{% endstep %}

{% step %}

#### 创建路由规则 <a href="#ip-create-routing-rule" id="ip-create-routing-rule"></a>

单击域名进入路由规则列表，我们来基于**线路/地理**创建路由规则。

<div><figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-64f07725a38ae558b188b96ae42cd7d77f878135%2Fimage%20(242).png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-bdae2bc14080bfd33b6b2a85fca27cdec3134f03%2Fimage%20(243).png?alt=media" alt=""><figcaption></figcaption></figure></div>

* 您必须先创建一条**默认线路。**
* 配置对应的候选地址池，关联地址监控可自动剔除异常地址。
* 基于**优选策略**可以自动的依据监控数据优选速度**最快和最稳**定的 IP 地址。

{% hint style="info" %}
AxisNow 系统预设了两个拨测任务模版：

* Default Intl Network 配置了 3 个国际拨测点，可用于监控国际链路。
* Default China Network 配置了 3 个中国大陆拨测点，可用于监控中国大陆方向链路。
  {% endhint %}

{% hint style="info" %}
由于 BGP 多播的特点，使用国际拨测点监控一个覆盖中国大陆优化的 EIP 可能会不准确。

正确的做法是将拨测点和最终用户地区/线路保持一致。
{% endhint %}

{% hint style="info" %}
默认模版配置的请求协议和参数都为：`https://拨测目标:443/aegis_node_ping/`

**请注意：**&#x5982;果地址池的 IP 是 AxisNow Edge，那么采用默认配置参数即可。若地址池并不是 AxisNow Edge。您需要配置**正确的拨测 URL**（创建新的模版或修改默认模版）以正确探测和评估。
{% endhint %}
{% endstep %}

{% step %}

#### 查看解析情况 <a href="#ip-check-resolution" id="ip-check-resolution"></a>

<figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-26df0dec86704d8b719edd5524a48f090ccc002d%2Fimage%20(244).png?alt=media" alt=""><figcaption></figcaption></figure>

基于监控的路由规则会有**首次初始化**过程，因为监控数据需要一段时间的拨测和评估，所以**首次地址选取策略将忽略监控**。地址池会在几分钟后呈现<mark style="color:green;">绿色（正常）</mark>或<mark style="color:red;">红色（异常）</mark>。如地址状态持续红色可能是上述原因导致的，您需要配置**正确的拨测 URL**。

**展开后单击地址**可跳转查看关联的边缘拨测任务。

<div><figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-1b71207cdcc0d50dcb01a3f3216777b58449bb96%2Fimage%20(246).png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-30af2e789119a8da652426fe4b29da340b66281d%2Fimage%20(245).png?alt=media" alt=""><figcaption></figcaption></figure></div>

<figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-79d23033adf0085cdac2f1acecce4b622c7e1ffc%2Fimage%20(248).png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

## 多家 CDN/CNAME 的流量调度 <a href="#multi-cdn-cname-routing" id="multi-cdn-cname-routing"></a>

您可以管理解析到多个域名地址池，实现多云 CDN 的延迟优选和故障切换，如图示例。

<figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-fa9685485bb93330708cee75f03b0665db12cef2%2Fimage%20(204).png?alt=media" alt=""><figcaption></figcaption></figure>

### 步骤指引 <a href="#cname-steps" id="cname-steps"></a>

{% stepper %}
{% step %}

#### 创建 CNAME 记录类型调度域 <a href="#create-cname-routing-domain" id="create-cname-routing-domain"></a>

进入 DNS 路由插件单击右上角新增按钮，出现创建调度域的弹窗选择页面。

AxisNow 免费提供了两个托管的调度域，托管在**阿里云和 AWS** 供您选择。若您希望覆盖中国大陆，阿里云具备更精细的中国大陆线路和地理位置。若您希望覆盖国际业务，我们建议 AWS 是一个更好的选择。

<figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-a47d8bf34dc5f4299389b9c87af8350eaa6e4540%2Fimage%20(249).png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### 创建路由规则 <a href="#cname-create-routing-rule" id="cname-create-routing-rule"></a>

单击域名进入路由规则列表，基于**线路/地理**创建路由规则。

<figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-9c211ebe274d023f90c325706c3f728cfd9763e6%2Fimage%20(250).png?alt=media" alt=""><figcaption></figcaption></figure>

* 您必须先创建一条**默认线路。**
* 配置对应的候选地址池，关联地址监控可自动剔除异常地址。
* 基于**最小延迟的选取策略**可以自动的依据监控数据优选速度最快的 CNAME 地址。

{% hint style="info" %}
AxisNow 系统预设了两个拨测任务模版：

* Default Intl Network 配置了 3 个国际拨测点，可用于监控国际链路。
* Default China Network 配置了 3 个中国大陆拨测点，可用于监控中国大陆方向链路。
  {% endhint %}

{% hint style="info" %}
由于 BGP 多播的特点，使用国际拨测点监控一个覆盖中国大陆优化的 EIP 可能会不准确。

正确的做法是将拨测点和最终用户地区/线路保持一致。
{% endhint %}

{% hint style="info" %}
默认模版配置的请求协议和参数都为：`https://拨测目标:443/aegis_node_ping/`

**请注意：**&#x5982;果地址池是 AxisNow Edge，那么采用默认配置参数即可。若地址池并不是 AxisNow Edge。您需要配置**正确的拨测 URL**（创建新的模版或修改默认模版）以正确探测和评估。
{% endhint %}
{% endstep %}

{% step %}

#### 查看解析情况 <a href="#cname-check-resolution" id="cname-check-resolution"></a>

基于监控的路由规则会有首次初始化过程，因为监控数据需要一段时间的拨测和评估，所以**首次地址选取策略将忽略监控**。地址池会在几分钟后呈现<mark style="color:green;">绿色（正常）</mark>或<mark style="color:red;">红色（异常）</mark>。如地址状态持续红色可能是上述原因导致的，您需要配置**正确的拨测 URL**。

下图为 AxisNow 官网在生产环境配置示例：

<figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-c93473016d93b33d9e9b2ac9651d6d376872bea1%2Fimage%20(254).png?alt=media" alt=""><figcaption></figcaption></figure>

**单击展开后的地址可以跳转至边缘拨测任务**查看相关数据。

<figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-0f0f4468279af2ad156e241b7a63873634b2d1de%2Fimage%20(252).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3062891322-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKDgGNU6JXG7cqYCk2aCz%2Fuploads%2Fgit-blob-fa606f3723c20952ee341521badc694dccd933ca%2Fimage%20(253).png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

## 后续步骤 <a href="#next-steps" id="next-steps"></a>

恭喜！现在您已启动并运行。

我们非常乐意听取您对产品和体验的反馈，您可以加入[社区电报群组](https://t.me/AxisNowGroupZh)。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.axisnow.io/zh/docs/guide/dns-routing-gtm.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
