40 lines
2.4 KiB
Markdown
40 lines
2.4 KiB
Markdown
# NSC Routing Overview
|
|
|
|
NSC transparently routes local application traffic by domain/geosite, destination
|
|
IP/geoip, and overlay namespace. The normative behavior is defined in the
|
|
[NSC Routing Specification](ROUTING_DEV.md), including its
|
|
[architecture diagram](ROUTING_DEV.md#22-architecture-diagram).
|
|
|
|
The NSC DNS service is called FakeDNS, but its default mode is **REAL**: it returns
|
|
answers from an authorized resolver without substituting synthetic addresses.
|
|
Rules can explicitly select **FAKE** or **BLOCK** for matching names. This keeps
|
|
ordinary DNS compatible with applications that reject synthetic answers.
|
|
|
|
With a `.i2p -> FAKE + i2pd` routing rule, opening `http://example.i2p` works as follows:
|
|
|
|
1. The application sends an ordinary DNS query. FakeDNS recognizes the I2P namespace,
|
|
allocates an address from `198.18.0.0/15`, and records the original domain.
|
|
2. Before replying, FakeDNS publishes the mapping, I2P classification, and route
|
|
hint to kernel-visible BPF maps. No SOCKS CONNECT is sent at DNS time.
|
|
3. The application connects to the fake address and destination port. OUTPUT policy
|
|
routing, TC ingress, and TPROXY deliver the flow to an NSC transparent listener.
|
|
4. The daemon recovers `example.i2p`, checks the current policy and killswitch, and
|
|
sends SOCKS5 CONNECT with the original domain and actual destination port.
|
|
5. After proxy success, the daemon relays bytes in both directions. UDP uses a
|
|
separate SOCKS5 UDP ASSOCIATE lifecycle. HTTP proxies use an explicit CONNECT
|
|
or cleartext HTTP forward mode.
|
|
|
|
TC performs compact packet and flow checks; complex domain/geodata policy remains
|
|
in userspace. TPROXY supplies local delivery, while the base payload relay runs
|
|
in userspace. Kernel payload relay is an optional extension.
|
|
|
|
When the killswitch is enabled, **full** permits only overlay application
|
|
destinations; **allow-proxy** additionally permits clearnet through proxies
|
|
configured in NSC. Narrow trusted service exceptions cover required proxy/overlay
|
|
transports and explicitly configured DNS upstreams, including in full mode.
|
|
Overlay names are never sent to a public DNS upstream. A direct application
|
|
exception must be explicit in a routing rule.
|
|
|
|
Mappings survive SIGHUP reloads. The supported lifecycle is one daemon process
|
|
from system boot until reboot, with no live-session restart. After reboot the
|
|
in-memory journal is discarded and allocation starts from scratch.
|