Feature: Add configurable interface and route metrics
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 237
- Forks
- 228
- PR merge metrics
- No merged PRs in 30d
Description
Problem
Currently, interface and route metrics are hardcoded in the TUN implementation:
- Windows: Interface metric is set to 0 when AutoRoute is enabled
- Routes: Always use metric 0 (highest priority)
This creates issues when users need different routing priorities on different devices while using the same configuration file.
Proposed Solution
Add two new fields to the Options struct:
InterfaceMetric uint32- Sets the metric for the TUN interface (Windows only)RouteMetric uint32- Sets the metric for routes through the TUN interface (Windows and Linux)
Behavior:
- InterfaceMetric = 0 (default):
- When
AutoRoute=true: metric is set to 0 (highest priority) - When
AutoRoute=false: Windows automatic metric is used
- When
- InterfaceMetric > 0: Explicitly specified metric (lower value = higher priority)
- RouteMetric = 0 (default): Metric 0 (highest priority)
- RouteMetric > 0: Explicitly specified metric
- On Linux,
RouteMetricmaps to thePriorityfield in netlink routes
Implementation
Changes required in:
tun.go: AddInterfaceMetricandRouteMetricfields toOptionstun_windows.go: Implement interface metric logic for IPv4/IPv6, update route metrictun_linux.go: MapRouteMetrictoPriorityfield
Backward Compatibility
Fully backward compatible - when both fields are 0 (default), behavior remains unchanged.
Use Case
Users running the same configuration on multiple devices (e.g., desktop and mobile) can now set different routing priorities without maintaining separate config files.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Options struct and current metric handling in tun.go, tun_windows.go, and tun_linux.go. Trace the existing IPv4/IPv6 interface and route setup, then verify that nonzero InterfaceMetric and RouteMetric values are applied while both zero values preserve the documented behavior on Windows and Linux.
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
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100