-
Notifications
You must be signed in to change notification settings - Fork 2
GEO Rules Basics
English | 简体中文
Geo rules let HBBS choose an ordered HBBR destination from the public addresses it observes for both clients. They do not redirect API traffic, change the client's displayed location, or modify HBBR. Start with one broad rule and two Relays; add detail only after the decision is observable and real sessions work.
For a connection that needs a Relay, Starry:
- determines the transport requirement (
native,wss, ormixed); - builds the currently eligible Relay list;
- looks up Geo facts for both observed public client addresses;
- evaluates rules from top to bottom;
- within the first usable match, chooses the first eligible Relay in the rule's ordered list; and
- falls back to the official round-robin choice among eligible Relays when no Geo rule can select one.
If a rule matches but all Relays in that rule are unavailable, evaluation can continue to a later rule. Put specific policies before broad catch-alls.
version: 1
relay_servers:
- relay-asia-1.example.com:21117
- relay-asia-2.example.com:21117
- relay-us-1.example.com:21117Every Relay later used by a rule must appear in this list. The HBBR instances may be on the centre host or separate nodes, but each address must be reachable by clients and must use the same HBBS public key.
A country-only rule can use a Country or City MMDB:
mmdb:
update_interval_hours: 168
update_on_start: true
force_update: false
download_timeout_seconds: 600
minimum_bytes: 65536
country:
path: mmdb/GeoLite2-Country.mmdb
url: https://downloads.example.com/GeoLite2-Country.mmdb
city:
path: mmdb/GeoLite2-City.mmdb
url: ""
asn:
path: mmdb/GeoLite2-ASN.mmdb
url: ""Replace the example URL with a lawful, trusted source, or leave it empty and place the file at the configured path yourself. No database is built into the image. A rule that needs city facts requires the City database; ASN and ISP rules require the ASN database.
geo:
enabled: true
rules:
- name: East Asia to Asia Relay
symmetric: true
match:
client_a: CN/JP/KR/TW
client_b: "*"
relays:
- relay-asia-1.example.com:21117
- relay-asia-2.example.com:21117
- name: Default
symmetric: true
match:
client_a: "*"
client_b: "*"
relays:
- relay-us-1.example.com:21117This says:
- when either client is in
CN,JP,KR, orTW, preferrelay-asia-1, then fail over torelay-asia-2; - otherwise use
relay-us-1while it is eligible.
symmetric: true is important here: the client that starts the connection is
not a stable way to define geography. The rule matches when the regional
client appears as A or B.
| Syntax | Meaning | Example |
|---|---|---|
* |
Any address, including one with missing MMDB facts | client_b: "*" |
/ |
OR | CN/JP/KR |
+ |
AND; evaluated before OR | country:CN+asn:AS4134 |
( ) |
Grouping | (CN/JP)+continent:AS |
XX |
Bare two-letter country code |
CN equals country:CN
|
field:value |
Match one explicit fact | city:Shanghai |
Quote YAML strings containing *, and quote expression values when they may
contain punctuation. Geo comparisons are case-insensitive. ISP matching is a
case-insensitive substring match; the other textual predicates are exact
case-insensitive matches against MMDB values.
Supported fields:
| Field | Example | Database |
|---|---|---|
continent |
continent:AS |
Country or City |
country |
country:US |
Country or City |
subdivision, region
|
region:CA |
City |
city |
city:Shanghai |
City |
geoname, city_id
|
geoname:1796236 |
City |
asn |
asn:AS4134 or asn:4134
|
ASN |
isp, asn_org
|
isp:'China Telecom' |
ASN |
GeoNames IDs and ASNs must be positive integers. City and subdivision names depend on the names present in the selected MMDB. Codes or numeric IDs are usually less ambiguous than translated names.
For initial commissioning with the supplied Compose example, restart HBBS. Use the authenticated Control Agent for later managed reloads:
docker restart rustdesk-starry-hbbs
docker logs --tail 100 rustdesk-starry-hbbsLook for an accepted Starry configuration, loaded Geo rule count, readable database paths, and no missing-database warning for fields used by the rules.
Confirm the Relay pool through authenticated Control Agent
GET /control/v1/relays.
The local control port is loopback-only, requires the independent token, and must never be exposed or reverse-proxied.
Call authenticated POST /control/v1/allocations:simulate with the two public
addresses, transport: native, the expected generation, and explain: true.
Replace the documentation-only addresses with the public source addresses that
HBBS actually observes. When both devices share one NAT, use that public
address for both arguments. The output is the selected Relay in Rust's debug
string form, or "" if none is eligible.
Allocation simulation is a decision preview. It does not register clients, open HBBR, prove that DNS or a firewall works, or measure latency.
Use two RustDesk clients and leave their Relay Server fields empty. Confirm:
- both clients register with this HBBS and use the expected public key;
- a forced-Relay or naturally relayed session reaches the expected HBBR;
- desktop control, input, and an appropriate sustained transfer work; and
- stopping the first Relay causes the next ordered Relay to be selected only after HBBS observes it as unavailable.
Record both client timestamps and the matching HBBS/HBBR logs. Continue with Operations and Verification before calling the policy production-ready.
| Symptom | Likely cause |
|---|---|
| The same Relay is always used | This may be correct: Relay order is strict priority, not load balancing. |
| The catch-all hides a regional rule | The catch-all appears too early. Move it last. |
| Country works but city never matches | The City MMDB is missing, unreadable, or does not contain the expected name. |
| Server policy seems ignored | A client has a non-empty Relay Server field. |
| An MMDB URL downloads an HTML page | The provider requires authentication or redirects to a licence page; use an authorised direct file source. |
test-geo works but remote control does not |
Geo selection was proved, but HBBR reachability/session flow was not. Test the next layer. |
- Documentation home
- Getting started
- Docker image usage
- Docker deployment
- Native deployment
- Multi-node deployment
- Reverse proxy and TLS
- Client configuration
- Account/API integration
- Configuration reference
- Connection authentication
- Control Agent
- GEO rules: basics
- GEO rules: advanced
- Operations and verification
- Troubleshooting
- Upgrade and rollback
- Architecture and build
- 文档主页
- 快速开始
- Docker 镜像使用
- Docker 部署
- 原生部署
- 中心与 Relay 多节点部署
- 反向代理与 TLS
- 客户端配置
- 账户与 API 服务接入
- 配置参数详解
- 连接认证
- Control Agent
- Geo 规则:入门
- Geo 规则:进阶
- 运维与完整验证
- 常见问题排查
- 版本升级与回滚
- 架构与构建