| doc | ||
| src | ||
| tests | ||
| .envrc | ||
| .gitignore | ||
| .woodpecker.yaml | ||
| build.rs | ||
| Cargo.lock | ||
| Cargo.toml | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE | ||
| README.md | ||
NSC
NSC (Network Security Control) is a Rust prototype for policy-based routing of local IPv4 TCP and UDP traffic, with planned DNS and overlay proxy integration on Linux. The routing contract is described in the v0.1 specification and its architecture overview.
Project status: NSC is not yet a usable traffic-routing or killswitch implementation. The current executable reads packets from a hard-coded TUN device and calls the packet-header parser. It does not install the specified OUTPUT → TC → TPROXY path, enforce routing policy, or relay application flows.
Current implementation
| Area | Present in the repository | Status |
|---|---|---|
| Packet handling | TUN read loop and raw packet-header parsing | Prototype sniffer only |
| Configuration | Basic TOML parsing for rules, proxies, and policy values | Not loaded by the running executable; full v0.1 validation is pending |
| Geodata | GeoIP2 MMDB and V2Ray geodata parsing components | Rule matching and routing integration are incomplete |
| FakeDNS | UDP/TCP DNS server and fake-address resolver components | Prototype; v0.1 DNS policy and publication contract is not implemented end to end |
| Interception and enforcement | No complete OUTPUT → TC → TPROXY backend or independent egress guard | Planned |
| Proxying and lifecycle | No integrated transparent relay, reload path, or boot-only service integration | Planned |
The current executable must not be treated as a protected networking profile. The component-level work does not yet provide an end-to-end routing guarantee.
Routing v0.1 configuration examples
These examples show the target configuration contract from
specification §5. They are not
currently runnable profiles: the executable does not load a routing config, and
the parser does not yet support every field shown here. Replace
192.0.2.53 with an IPv4 DNS resolver authorized for your host; it is a
documentation-only address.
REAL DNS by default
Ordinary DNS uses the configured upstream. No synthetic answers are requested.
[policy]
clearnet = "allowed"
dns_mode = "real"
[dns]
upstreams = ["udp://192.0.2.53:53"]
Clearnet through a configured proxy
allow-proxy blocks direct clearnet access while permitting application traffic
through the configured proxy. The rule selects that proxy for clearnet names.
[policy]
clearnet = "killswitched"
killswitch_mode = "allow-proxy"
dns_mode = "real"
[dns]
upstreams = ["udp://192.0.2.53:53"]
[[proxy]]
alias = "socks-exit"
url = "socks5://127.0.0.1:1080"
[[rule]]
target = "clearnet"
action = "proxy"
proxy_name = "socks-exit"
Full killswitch with FAKE DNS for .i2p
Full mode blocks clearnet application destinations, including destinations that
would otherwise use a proxy. The .i2p rule explicitly selects FAKE DNS and the
configured i2pd SOCKS endpoint; other DNS remains REAL.
[policy]
clearnet = "killswitched"
killswitch_mode = "full"
dns_mode = "real"
[dns]
upstreams = ["udp://192.0.2.53:53"]
[[proxy]]
alias = "i2pd"
url = "socks5://127.0.0.1:1080" # Use the SOCKS port configured in i2pd.
[[rule]]
target = "suffix:i2p"
action = "proxy"
proxy_name = "i2pd"
dns_mode = "fake"
The examples follow the normative v0.1 defaults and constraints. In particular, DNS mode is independent of transport action, overlay names are not sent to the clearnet resolver, and a DNS answer alone does not authorize a connection.
Runtime and lifecycle contract
The lifecycle below is specified for the future v0.1 runtime; it is not yet implemented by the current executable:
- Run one NSC process from system boot until reboot. The planned systemd unit uses
Restart=no. - Apply configuration changes through SIGHUP. A successful reload keeps the runtime identity and existing fake-address mappings; a failed reload leaves the active policy unchanged.
- Do not stop or restart NSC during a live client session. Binary upgrades take effect after the next system boot.
- After a crash, retain the independent firewall guard and recover by rebooting. A reboot starts a new runtime epoch and clears in-memory fake-address mappings.
See specification §10 for the startup, readiness, reload, failure, and init requirements.
Backend and implementation work
There is no published backend deployment descriptor yet. The descriptor contract lists the required kernel, hook, mark, route, listener, ABI, and resource-limit details; implementation is tracked in issue #8.
Related work:
- Complete the configuration schema and implement routing and killswitch decisions.
- Implement TC admission and the local OUTPUT → TC → TPROXY path.
- Add transparent listeners, TCP relay, UDP relay, and HTTP proxy modes.
- Integrate the runtime startup path, reload, and boot-only packaging.
Browse all open issues for the current implementation plan.