本指南说明 Cloudflare One Client(前称 WARP)如何与设备的操作系统进行交互,从而在 流量和 DNS 模式(默认) 下路由流量。
在 仅 DNS 模式 下,IP 流量信息不适用。在 仅流量模式 下,DNS 流量信息不适用。
Cloudflare One Client 允许组织对终端用户设备可以访问的应用程序进行细粒度控制。该客户端将 DNS 和网络流量从设备转发到 Cloudflare 的全球网络,并在云端应用 Zero Trust 策略。在所有操作系统上,WARP 守护程序都会在设备和 Cloudflare 之间维持三个连接:
| 连接 | 协议 | 用途 |
|---|---|---|
| WARP 隧道(通过 WireGuard 或 MASQUE) | UDP | 向 Gateway 发送 IP 数据包,以执行网络策略、HTTP 策略和专用网络访问。 |
| DoH ↗ | HTTPS | 向 Gateway 发送 DNS 请求以执行 DNS 策略。DoH 连接在 WARP 隧道内维护。 |
| 设备编排 | HTTPS | 执行用户注册、检查设备姿态、应用设备客户端配置文件设置。 |
flowchart LR
subgraph Device
W[Cloudflare One Client] -.-> D
D[DNS proxy]
W -.-> V[Virtual interface]
end
subgraph Cloudflare
A[Zero Trust account]
subgraph Gateway
N[L3/L4 firewall]
G[DNS resolver]
end
end
W<--"Device
orchestration"-->A
subgraph tunnel["WARP tunnel"]
ip@{ shape: text, label: "Network traffic" }
dns@{ shape: text, label: "DNS traffic" }
end
V --- ip-->N
D --- dns-->G
N --> O[(Application)]
您的 分割隧道(Split Tunnel) 配置决定了哪些 IP 流量会发送到 WARP 隧道中。您的 本地域回退(Local Domain Fallback) 配置决定了哪些 DNS 请求会通过 DoH 发送到 Gateway。发送到 设备编排 API 端点的流量不遵循分割隧道规则,因为该连接始终在 WARP 隧道外运行。
接下来,您将了解 Cloudflare One Client 如何配置您的操作系统以应用本地域回退和分割隧道路由规则。桌面端和移动端客户端的具体实现细节有所不同。
桌面客户端由两个组件组成:在设备上处理所有客户端功能的系统服务/守护程序,以及方便用户与守护程序进行交互的 GUI 外壳。
当您连接 Cloudflare One Client 时,客户端会在设备上创建一个本地 DNS 代理,并将其绑定(bind)至以下 IP 地址的 53 端口(指定用于 DNS 流量的端口):
- IPv4:
127.0.2.2和127.0.2.3 - IPv6:
- macOS 和 Linux:
fd01:db8:1111::2和fd01:db8:1111::3 - Windows:
::ffff:127.0.2.2
- macOS 和 Linux:
然后,Cloudflare One Client 会配置操作系统将所有 DNS 请求发送至这些 IP 地址。设备上的所有网络接口现在都将使用此本地 DNS 代理进行 DNS 解析。换句话说,所有 DNS 流量现在都将由 Cloudflare One Client 处理。
根据您的本地域回退配置,Cloudflare One Client 会将请求转发至 Gateway 以执行 DNS 策略,或者将请求转发至您的私有 DNS 解析器。
- 发送到 Gateway 的请求通过 WARP 隧道内的 DoH 连接 发送。
- 发送到您的私用 DNS 解析器的请求根据您的分割隧道配置在隧道内或隧道外发送。有关更多信息,请参阅 Cloudflare One Client 如何处理 DNS 请求。
flowchart LR
D{{DNS request}}-->L["Local DNS proxy <br> (127.0.2.2 and 127.0.2.3)"]-->R{In local domain fallback?}
R -- Yes --> F[Private DNS resolver]
R -- No --> G[Cloudflare Gateway]
您可以验证操作系统是否正在使用 Cloudflare One Client 的本地 DNS 代理:
在 macOS 上,打开终端窗口并运行 scutil --dns。DNS 服务器应设置为 Cloudflare One Client 的本地 DNS 代理 IP。
scutil --dnsDNS configuration (for scoped queries)
resolver #1
search domain[0] : <DNS-SEARCH-DOMAIN>
nameserver[0] : 127.0.2.2
nameserver[1] : 127.0.2.3
if_index : 15 (en0)
flags : Scoped, Request A records
reach : 0x00030002 (Reachable,Local Address,Directly Reachable Address)
resolver #2
nameserver[0] : 127.0.2.2
nameserver[1] : 127.0.2.3
nameserver[2] : fd01:db8:1111::2
nameserver[3] : fd01:db8:1111::3
if_index : 23 (utun3)
flags : Scoped, Request A records, Request AAAA records
reach : 0x00030002 (Reachable,Local Address,Directly Reachable Address)在 Windows 上,打开 PowerShell 窗口并运行 ipconfig。DNS 服务器应设置为 Cloudflare One Client 的本地 DNS 代理 IP。
ipconfigWindows IP Configuration
Unknown adapter CloudflareWARP:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Cloudflare WARP Interface Tunnel
Physical Address. . . . . . . . . :
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
IPv6 Address. . . . . . . . . . . : 2606:4700:110:8f79:145:f180:fc4:8106(Preferred)
Link-local IPv6 Address . . . . . : fe80::83b:d647:4bed:d388%49(Preferred)
IPv4 Address. . . . . . . . . . . : 172.16.0.2(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.255
Default Gateway . . . . . . . . . :
DNS Servers . . . . . . . . . . . : 127.0.2.2
127.0.2.3
NetBIOS over Tcpip. . . . . . . . : Enabled在 Linux 上,检查 /etc/resolv.conf 文件。DNS 服务器应设置为 Cloudflare One Client 的本地 DNS 代理 IP。
cat /etc/resolv.conf# This file was generated by cloudflare-warp.
nameserver 127.0.2.2
nameserver 127.0.2.3
nameserver fd01:db8:1111::2
nameserver fd01:db8:1111::3
search <DNS-SEARCH-DOMAIN>
options edns0
options trust-ad当您连接 Cloudflare One Client 时,它会在设备上进行三项更改,以控制流量是在 WARP 隧道内还是隧道外发送:
flowchart LR
P{{IP packet}}-->R["OS routing table"]-->F["OS firewall"] --> S{Excluded from Split Tunnels?}
S -- Yes --> A[(Application)]
S -- No --> U["Virtual interface<br> (172.16.0.2)"] --> G[Cloudflare Gateway]
虚拟接口允许操作系统在逻辑上将物理接口(如网络接口控制器 NIC)划分为不同的接口,以便路由 IP 流量。Cloudflare One Client 的虚拟接口用于维持设备与 Cloudflare 之间的 WireGuard/MASQUE 连接。默认情况下,对于使用 WireGuard 的设备,其 IPv4 地址硬编码为 172.16.0.2;而对于使用 MASQUE 的设备,则会从 CGNAT IP 空间(100.96.0.0/12)中 分配唯一的 IP。您可以使用 自定义设备 IP 覆盖默认的虚拟接口 IP。
要查看操作系统上所有网络接口的列表:
在 Windows 上,运行 ipconfig。当开启 Cloudflare One 客户端时,您将看到一个名为 CloudflareWARP 的适配器,其中包含您的设备 IP。
ipconfigWindows IP Configuration
Unknown adapter CloudflareWARP:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Cloudflare WARP Interface Tunnel
Physical Address. . . . . . . . . :
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
IPv6 Address. . . . . . . . . . . : 2606:4700:110:8f79:145:f180:fc4:8106(Preferred)
Link-local IPv6 Address . . . . . : fe80::83b:d647:4bed:d388%49(Preferred)
IPv4 Address. . . . . . . . . . . : 172.16.0.2(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.255
Default Gateway . . . . . . . . . :
DNS Servers . . . . . . . . . . . : 127.0.2.2
127.0.2.3
NetBIOS over Tcpip. . . . . . . . : Enabled在 macOS 上,运行 ifconfig。当开启 Cloudflare One 客户端时,您将看到一个包含您设备 IP 的 utun 接口。
ifconfig<redacted>
utun3: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1280
inet 172.16.0.2 --> 172.16.0.2 netmask 0xffffffff
inet6 fe80::f6d4:88ff:fe82:6d9e%utun3 prefixlen 64 scopeid 0x17
inet6 2606:4700:110:8c7d:7369:7526:a59b:5636 prefixlen 128
nd6 options=201<PERFORMNUD,DAD>在 Linux 上,运行 ifconfig 或 ip addr。当开启 Cloudflare One 客户端时,您将看到一个包含您设备 IP 的 utun 接口。
ip addr<redacted>
3: CloudflareWARP: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1280 qdisc mq state UNKNOWN group default qlen 500
link/none
inet 172.16.0.2/32 scope global CloudflareWARP
valid_lft forever preferred_lft forever
inet6 2606:4700:110:8a2e:a5f7:a8de:a1f9:919/128 scope global
valid_lft forever preferred_lft forever
inet6 fe80::117e:276b:8a79:c498/64 scope link stable-privacy
valid_lft forever preferred_lft forever在上面的示例中,设备 IPv4 地址是 172.16.0.2。
Cloudflare One Client 编辑系统路由表以控制发送到 Gateway 的 IP 流量。路由表指明哪个网络接口应该处理发送到特定 IP 地址的数据包。默认情况下,所有流量都会通过 Cloudflare One Client 的虚拟接口路由,但您的分割隧道排除列表中的 IP 和域名除外(它们使用设备上的默认接口)。
您可以验证路由表是否与您的分割隧道规则相匹配:
要查看 macOS 上的完整路由表,请运行 netstat -r。
您还可以在路由表中搜索特定的域名或 IP 地址。在此示例中,我们看到发送到 google.com 的流量通过 utun3 发送,这是此设备上 Cloudflare One Client 的虚拟接口:
route get google.com route to: lga25s81-in-f14.1e100.net
destination: 136.0.0.0
mask: 248.0.0.0
interface: utun3
flags: <UP,DONE,PRCLONING>
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1280 0相比之下,此 DHCP 地址已从 Cloudflare One Client 中排除,并使用默认接口:
route get 169.254.0.0 route to: 169.254.0.0
destination: 169.254.0.0
mask: 255.255.0.0
interface: en0
flags: <UP,DONE,CLONING,STATIC>
recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire
0 0 0 0 0 0 1500 -210842要查看 Windows 上的完整路由表,请运行 netstat -r。
您还可以在路由表中搜索特定的 IP 地址。在此示例中,我们看到发送到 1.1.1.1 的流量通过 Cloudflare One Client 的虚拟接口发送:
Find-NetRoute -RemoteIPAddress "1.1.1.1" | Select-Object InterfaceAlias -Last 1InterfaceAlias
--------------
CloudflareWARP相比之下,此 DHCP 地址已从 Cloudflare One Client 中排除,并使用默认接口:
Find-NetRoute -RemoteIPAddress "169.254.0.0" | Select-Object InterfaceAlias -Last 1InterfaceAlias
--------------
Wi-Fi要查看 Linux 上的完整路由表,请运行 ip -6 route show table all or ip -4 route show table all。
您还可以在路由表中搜索特定的 IP 地址。在此示例中,我们看到发送到 1.1.1.1 的流量通过 Cloudflare One Client 的虚拟接口发送:
ip route get 1.1.1.11.1.1.1 dev CloudflareWARP table 65743 src 172.16.0.2 uid 1000
cache相比之下,此 DHCP 地址已从 Cloudflare One Client 中排除,并使用默认接口:
ip route get 169.254.0.0169.254.0.0 dev ens18 src 172.24.8.6 uid 1000
cacheCloudflare One Client 修改操作系统防火墙以执行您的分割隧道规则。这增加了一层保护,以防某些服务绕过路由表并尝试直接通过其他接口发送流量。例如,如果发送到 203.0.113.0 的流量应该由 Gateway 进行检查,我们会创建一个防火墙规则,在除 utun 以外的所有接口上阻止 203.0.113.0。
在 iOS 和 Android/ChromeOS 上,Cloudflare One Agent 作为 VPN 客户端安装自身,以捕获并路由所有流量。该应用程序构建在 iOS 和 Android 的官方 VPN 框架之上。有关更多信息,请参阅 Apple 的 NetworkExtension 文档 ↗ 和 Google 的 Android 开发者文档 ↗。
请注意,ChromeOS 在虚拟机中运行 Android 应用程序,而不是运行原生的 Chrome 应用程序。