Repository navigation
feat(ns-api): add live trace troubleshooting API - #2007
Open
gsanchietti wants to merge 5 commits into
Open
gsanchietti wants to merge 5 commits into
gsanchietti wants to merge 5 commits into
Conversation
gsanchietti
force-pushed
the
live_trace
branch
2 times, most recently
from
November 10, 2026 13:16
7534d85 to
9142609
Compare
gsanchietti
force-pushed
the
live_trace
branch
2 times, most recently
from
November 10, 2026 13:53
3bf2808 to
2dd83af
Compare
Tbaile
force-pushed
the
release-8.9.0
branch
from
November 10, 2026 16:51
47c67d2 to
b88f978
Compare
gsanchietti
force-pushed
the
live_trace
branch
2 times, most recently
from
November 17, 2026 10:10
a63a1c5 to
bbcb360
Compare
Tbaile
force-pushed
the
release-8.9.0
branch
2 times, most recently
from
November 24, 2026 14:56
75af8bc to
4465517
Compare
gsanchietti
force-pushed
the
live_trace
branch
9 times, most recently
from
November 26, 2026 08:43
058edd4 to
d16bf51
Compare
gsanchietti
marked this pull request as ready for review
November 26, 2026 08:45
Tbaile
reviewed
Nov 26, 2026
Tbaile
left a comment
Collaborator
There was a problem hiding this comment.
Everything checks out, turned out that the libexec script is way more readable than the APIs.
If you feel that is too much, feel free to ignore.
Comment on lines
+103
to
+104
| if any(r.get("type") in ("local", "broadcast") for r in json.loads(route or "[]")): | ||
| return validation_error("ip", "not_a_client_address", ip) |
Collaborator
There was a problem hiding this comment.
Not so sure this will help, couldn't we figure out what is going on with the traffic coming from outside?
| "truncated": False, | ||
| } | ||
| running = running_pid() is not None | ||
| flows, start = state.pop("flows"), state.pop("start") |
Collaborator
There was a problem hiding this comment.
This works? Yes
Doesn't explain what is going on? Also yes
Please make the agent avoid this monstrosities, multiple lines to do stuff are appreciated
Comment on lines
+269
to
+285
| return { | ||
| **state, | ||
| "running": running, | ||
| "remaining": max(0, int(start + state["duration"] - time.time())) | ||
| if running | ||
| else 0, | ||
| "connections": connections, | ||
| "allowed": [ | ||
| { | ||
| **dict(zip(ALLOWED_FIELDS, k)), | ||
| "destination_name": names.get(k[2], ""), | ||
| "count": len(p), | ||
| "source_ports": p, | ||
| } | ||
| for k, p in sorted(allowed.items(), key=lambda i: len(i[1]), reverse=True) | ||
| ], | ||
| } |
Collaborator
There was a problem hiding this comment.
This 100% supports my cause, I have no clue what this does, multi pointer stuff in python, just "what?"
gsanchietti
force-pushed
the
live_trace
branch
from
November 26, 2026 12:07
dce664c to
c7973ca
Compare
Live trace lists the connections of one client only, and administrators need to see where a translated connection really goes. list_connections() accepts extra conntrack arguments to filter the listing, returns an empty list when conntrack prints nothing, and each connection reports its translated source and destination when NAT applies. Assisted-by: Claude Code:Fable 5.2
Administrators cannot tell which firewall layer blocks a client. ns.livetrace traces one client, or the firewall's own address for incoming traffic, for a limited time and reports the blocking layer and rule, DNS queries, live connections and routing hints, using nftables tracing and tcpdump. Each device is reported with its network interface name. Results exist only while the session runs: the collector removes its state file on exit and collector errors go to the system log. Assisted-by: Claude Code:claude-sonnet-5-5 Assisted-by: Claude Code:claude-opus-5-5
Build the kernel with CONFIG_NF_CONNTRACK_TIMESTAMP and turn on net.netfilter.nf_conntrack_timestamp at boot, so every tracked connection carries its start time, shown by conntrack as delta-time. Assisted-by: Claude Code:claude-opus-5-5
gsanchietti
force-pushed
the
live_trace
branch
from
November 27, 2026 14:13
2f324d9 to
856ade3
Compare
Build the UI from the nethsecurity-ui firewall_debug branch to test the live trace page. Drop this commit before merging. Assisted-by: Claude Code:claude-opus-5-5
A session should show what the client does after the trace starts, not what was already open. With conntrack timestamps the parser reports each connection's age (deltatime) and live trace skips the connections started before the session; without timestamps all current connections of the client are listed, as before. Assisted-by: Claude Code:claude-opus-5-5
gsanchietti
force-pushed
the
live_trace
branch
from
November 27, 2026 15:39
c9c5314 to
6fab8ea
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a client cannot reach something, administrators have to guess which part of the firewall is blocking it. Live trace follows one client IP address for a limited time and reports which layer stopped each new connection: a firewall rule or zone policy, Threat Shield IP (banIP) block lists, DPI (deep packet inspection) rules, the DNS filter or MAC binding. It also lists the client's DNS queries with their result and whether the DNS filter blocks them, its live connections, and routing hints such as a private address sent out to the WAN or a destination with no route.
The new
ns.livetraceAPI (start,stop,status) starts a background collector that marks the first packet of each new connection of the client with nftables tracing, reads the verdicts fromnft monitor traceand DNS traffic fromtcpdump, and writes the results to a state file. Sessions last 10 to 600 seconds, can be filtered by port and protocol, are rate limited, and clean up their nft table and helper processes when they end. The collector reloads its view of the rules when the firewall, banIP or DPI configuration changes during a session. Methods and limitations are documented inpackages/ns-api/README.md.The commit
chore(ns-ui): TEMP build UI from live trace branchbuilds the UI from the nethsecurity-uifirewall_debugbranch, which holds the live trace page, so the image can be tested end to end. It must be dropped before merging.How to test
api-cli ns.livetrace start --data '{"ip": "192.168.100.238", "duration": 120}'api-cli ns.livetrace statuslists each blocked connection with its layer, chain and rule name, the DNS queries withfilteredset for the blocked domain, and the open connectionsfw4 reload) or restart banIP during the session: connections opened afterwards still show the right rule nameapi-cli ns.livetrace stop, thenstatuslists the allowed connections of the session with the rule that accepted them; nons_livetracenft table,nft monitorortcpdumpprocess is leftSee also
Generated by Claude Code:claude-opus-5-5 with nethserver-pr