SagerNet / SagerNet/sing-box

[Feature Request] Route rules: match DSCP (IP DS field)

Open
#3,732 1 comment 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
38.2k
Forks
4.6k
Avg merge
19d 15h
Merged PRs (30d)
1

Description

Summary

DSCP is a standard L3 header field and can be used as a lightweight traffic classification tag.
Application-level routing via process_name / process_path often requires looking up process info via system APIs , which can be racy (especially for UDP or early packets of a flow).

I verified the following on Windows 11:

1. Set DSCP for a specific process using native Windows QoS Policy
New-NetQosPolicy -Name "Test_DSCP_Routing" -AppPathNameMatchCondition "C:\Program Files\Google\Chrome\Application\chrome.exe" -DSCPAction 49

# Get-NetQosPolicy
# Remove-NetQosPolicy -Name  "Test_DSCP_Routing"
2. Capture on the TUN interface with Wireshark and filter by DSCP
ip.dsfield.dscp == 49
3. Packets on the TUN interface carry the DSCP mark
Internet Protocol Version 4
 └─ Differentiated Services Field
     └─ Differentiated Services Codepoint: Unknown (49)
Proposal

Add an optional matcher to route rules (and optionally DNS rules), e.g.:

  • dscp: 0-63 or dscp: [46, 48]
  • Support both IPv4 DS field and IPv6 Traffic Class (DSCP bits)

Using DSCP as an internal routing tag may provide a practical alternative (or complement) to process-based routing on Windows.

I would be very grateful if you could evaluate this or point out why it's not working.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files, tests, or entry points are identified in the issue. Start by locating the existing route-rule and DNS-rule matchers, then trace how IPv4 DS fields and IPv6 traffic-class data are exposed to them. Done means an optional DSCP matcher supports the proposed scalar or list forms for both IP versions, with coverage for matching and non-matching packets.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.