Halaman ini belum diterjemahkan ke bahasa Indonesia; ditampilkan dalam bahasa lain.
Configuration
Named egress (hand certain subnets to an existing tunnel)
First, when not to use it: if you can use Tailscale, use Tailscale — just enable a subnet router on the internal machine (or the VPS), and bx does not get in its way (private addresses are not bound to the physical interface and follow the system routing table; the /16 a subnet router advertises is also more specific than bx's /8). That route is configured once, benefits every device, and needs not a single line changed in bx.
Use this only when a mesh is not an option (the internal network cannot reach out):
Commands (no need to edit YAML by hand):
bx egress add office 127.0.0.1:1080 # opened by ssh -D 1080 -J <vps> <internal-host>
bx egress route office 10.84.0.0/16 # allowlist: only the subnets listed go through it
bx egress ls
bx egress rm office # also removes the subnets assigned to it
In the config file it looks like this:
egress:
- name: office
socks5: 127.0.0.1:1080
rules:
- via: office
cidr: ['10.84.0.0/16']
A few fixed semantics:
- Allowlist, and only the allowlist. Subnets not listed are not affected in the slightest — docker, LAN and SSH all keep going through "private networks always direct" as before.
- Overrides "private networks always direct", which is exactly why it exists:
10.84.3.239falls inside10/8, and without the override it would be sent to the local interface. - When the egress is unreachable, traffic is blocked, never falls back to direct. The reason is not leak prevention but preventing connections to the wrong machine: with a fallback, opening that address on someone else's Wi-Fi would connect to a different machine with the same IP on that network.
- Not subject to the kill-switch: the egress is on loopback and unrelated to the main tunnel; the main tunnel going down should not take it down too.
- socks5 accepts only loopback addresses, validated at load time — a non-loopback address would be captured by bx itself.
- The first version matches by subnet only, not by domain (internal domain names can usually
be answered only by the internal DNS, which is the job of
dns.split).
Default client config path:
/etc/bx/config.yaml
Default server config path:
/etc/bx/server.yaml
You usually do not need to write a config by hand. bx server install and bx setup generate
the required files automatically.
Common client settings (below is an explanation of the keys, not the file bx setup writes —
it writes only server (or transports), global: true, killswitch: true, plus owner_uid
under sudo and the udp.transport given by --udp; it writes no other key, relying on
config.Parse to fill in defaults):
server: "bx://..."
killswitch: true
global: true # setup writes true here; change it to false to use the china split
dns:
china: 223.5.5.5
fakeip_cidr: 198.18.0.0/15
# Hand internal domain names to the internal DNS for resolution, and force them direct. On
# Windows you usually do not need to write this yourself: bx automatically hands this machine's
# internal DNS suffixes (AD domain, the adapter's connection-specific suffix, the DNS suffix
# search list pushed by Group Policy/the system) to the internal DNS on the adapter (otherwise
# the domain controller cannot be found, internal services do not open, and domain account
# logins fail)
split:
- domains: ["*.corp.example"]
servers: ["10.0.0.23", "10.0.0.24"]
bypass:
- 10.0.0.0/16
hosts: # pin a domain to a fixed IPv4 (while bx is on, /etc/hosts has no effect on apps)
nas.home.example: 192.168.1.20
rules:
- direct: ["*.corp.internal", "10.0.0.0/8"]
- proxy: ["*.openai.com"]
Notes:
killswitch: true: block proxied connections when the tunnel is unhealthy.global: true: all traffic goes through the bx tunnel except internal networks and the user's direct rules.bypass: subnets that bypass bx at the routing layer; suitable for management networks, SSH and internal networks.- Private networks, Docker, loopback and link-local are built-in direct by default and usually need no manual configuration.
transports: [link1, link2, ...](instead ofserver:): automatic multi-transport failover with ordered priority; when the primary fails it switches to a backup automatically. After switching away, once the primary recovers it switches back automatically (first try after 5 minutes, the interval doubling on failure up to 30 minutes; a transport you switched manually will not be changed back).udp.transport: "hysteria2://...": split by traffic class — UDP/QUIC goes through it for speed, TCP goes through the main transport. If it fails, UDP falls back to the main transport automatically (same VPS, same encrypted tunnel, no leak, just without the speed boost); only if the main transport also fails does it block, fail-closed.dns.split: resolution of internal domain names is handed to the internal DNS (public DNS cannot answer them). Matching domains get no fake IP; the query is forwarded toserversfor the real address, and the address obtained is registered as forced direct — so internal access does not detour into the tunnel.serverscan list several machines (AD domain controllers usually come in pairs); the semantics are query concurrently, use the first answer, so one going down does not slow down the other. The single-server formserver: 10.0.0.23is still supported, but the two keys cannot be written together (error at load time).:53is added when no port is given. The total budget for one round of queries is 2 seconds: when you leave the internal network, these domains fail clearly within 2 seconds instead of hanging. After changing it, runbx down && bx up(split is not hot-reloaded; only direct/proxy rules take effect live).hosts: domain → fixed IPv4. bx takes over system DNS, so while bx is on/etc/hostshas no effect on apps; pinned addresses go here. IPv4 only; the transport servers' domain names cannot be overridden (on conflict the server wins, andbx statuswill say so). After changing it, runbx down && bx up(hosts is not hot-reloaded).- For multiple transports / traffic splitting see multi-transport-guide.md.
Router mode (mode: router)
Install bx on a gateway/router and it proxies the LAN clients' forwarded traffic and the router's
own traffic (the catch-all policy rule does not match on source address). bx's own outbound
traffic, the bx servers and bypass, Tailscale's 100.64/10 and private ranges stay direct;
tailscaled's own rules sit ahead of bx's, so its traffic also goes direct.
mode: router
killswitch: true
router:
lan_cidrs: [192.168.8.0/24] # LAN subnets to proxy; leave empty to auto-detect br-* private bridges
lan_cidrsdecides which LAN subnets the firewall lets through bx and which have IPv6 forwarding blocked; it does not limit whether the router's own traffic is captured.- Fail-closed: LAN traffic can leave only through bx; as soon as bx/the tunnel goes down it is
dropped, never leaking the real IP (routing-layer blackhole + firewall).
While protection is on there is an extra floor (fw4 rules, in effect from boot): before bx starts,
or while bx is stopped or has crashed, the LAN still cannot go out directly — only private
ranges,
bypassand bx's own servers are reachable. The cost is that the whole LAN has no internet while bx cannot start, untilbx downturns protection off (only turning protection off or uninstalling removes this floor). - Leak prevention: any DNS (port 53) that reaches bx is answered with a fake IP — LAN clients' queries are forwarded by the router's dnsmasq, which is captured when its upstream is a public address and goes direct, bypassing bx, when its upstream is a private address; LAN IPv6 forwarding is blocked (prevents WebRTC/ICE v6 leaks); UDP (including STUN) is proxied or blocked, never direct.
- Before deploying, use
bx router-plan -c /etc/bx/config.yamlto preview theip+nftcommands that will be applied (does not change the system). - Currently requires OpenWrt 22.03 or later (fw4 / nftables), arm64 and x86-64 are fully supported, armv7 / mipsel are experimental. For installing and day-to-day use see OpenWrt routers.