mihomo-tun-user-systemd

mihomo-tun-user-systemd is a skill for Claude Code, Codex from magic3007/dotfiles. It costs 172 tokens per session (1,256 once invoked), scanned B, original, MIT.

A Linux troubleshooting guide for running mihomo, a proxy client, in TUN mode as a user-level systemd service. TUN mode lets the client handle network traffic through a virtual network interface.

In plain words
What is it for?
Use it to diagnose TUN startup errors and configure file capabilities and user-service settings when sudo systemctl is unavailable.
Why use it?
It addresses failures caused by service hardening, missing network capabilities, and restrictions on using system-level systemd commands.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions Claude Code.

Good fit Use it to diagnose TUN startup errors and configure file capabilities and user-service settings when sudo systemctl is unavailable.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/magic3007/dotfiles/mihomo-tun-user-systemd
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add magic3007/dotfiles --skill mihomo-tun-user-systemd
Clone the repo
git clone --depth 1 https://github.com/magic3007/dotfiles

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mihomo-tun-user-systemd

README.md
[![agentmods](https://agentmods.dev/badge/skills/magic3007/dotfiles/mihomo-tun-user-systemd/github.svg)](https://agentmods.dev/skills/magic3007/dotfiles/mihomo-tun-user-systemd)
Your own site
<a href="https://agentmods.dev/skills/magic3007/dotfiles/mihomo-tun-user-systemd"><img src="https://agentmods.dev/badge/skills/magic3007/dotfiles/mihomo-tun-user-systemd/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mihomo-tun-user-systemd

Your own site · 80×15
<a href="https://agentmods.dev/skills/magic3007/dotfiles/mihomo-tun-user-systemd"><img src="https://agentmods.dev/badge/skills/magic3007/dotfiles/mihomo-tun-user-systemd.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 172 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,256 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 2 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00172 $0.01256
Opus 5.5 $0.00069 $0.00502
Sonnet 5.5 $0.00034 $0.00251
Haiku 4.5 $0.00017 $0.00126

Measured 4d ago against content hash b4cd64b607da, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

mihomo-tun-user-systemd scanned grade B with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

on a box where sudo works but `sudo systemctl` / `iptables` are forbidden. Use when:

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl -s -o /dev/null -w "%{http_code}\n" https://www.google.com # 302 without -x
skills/mihomo-tun-user-systemd/SKILL.md · 95 lines

How it starts

The opening of the file, as written. The whole thing — 95 lines — stays where its author put it; the contents beside it link to each section on GitHub.

mihomo TUN mode under a systemd user service

Problem

A user-level mihomo service with the usual hardening can't create a TUN device. File capabilities are silently dropped, and the obvious fixes either fail or need sudo systemctl, which isn't allowed here.

Context / Trigger Conditions

  • The unit has hardening such as NoNewPrivileges=true, RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX, RestrictSUIDSGID, PrivateTmp, ProtectSystem or ProtectHome.
  • grep CapEff /proc/$(pgrep -x mihomo)/status shows 0000000000000000 and NoNewPrivs: 1 even though getcap shows caps on the binary.
  • sudo -l excludes /usr/bin/systemctl, so a system unit can't be installed.

Solution

  1. Give the binary file capabilities. setcap itself is allowed under sudo:
    sudo setcap cap_net_admin,cap_net_bind_service,cap_net_raw+ep ~/.local/bin/mihomo
    
    Don't use AmbientCapabilities= in a user unit. The user manager has no caps to grant, so the unit fails with status 218/CAPABILITIES.
  2. Add a drop-in that turns off every option that implies no-new-privileges or a user namespace. In a user manager, any seccomp-based option such as RestrictAddressFamilies silently forces NNP, and NNP disables file caps:
    # ~/.config/systemd/user/mihomo.service.d/tun.conf
    [Service]
    NoNewPrivileges=false
    PrivateTmp=false
    ProtectSystem=false
    ProtectHome=false
    RestrictSUIDSGID=false
    RestrictAddressFamilies=
    
    The empty RestrictAddressFamilies= resets the list. You need AF_NETLINK for mihomo's route monitor.
  3. Write the TUN config, and keep the intranet and SSH out of the tunnel. If the config is regenerated from a subscription, put this in the normalizer, not in the file:
    interface-name: eth0
    tun:
      enable: true
      stack: mixed
      device: mihomo0
      auto-route: true
      auto-detect-interface: false
      strict-route: false
      dns-hijack: []          # keep system DNS; sniffer recovers domains
      route-exclude-address: [10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16,
                              100.64.0.0/10, 127.0.0.0/8, 169.254.0.0/16]
    
    Keep sniffer.enable: true so domain rules still work without DNS hijack.
  4. Restart and check: systemctl --user daemon-reload && systemctl --user restart mihomo.

Read the full file on GitHub · 95 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago Changed b4cd64b607da
  2. 18d ago First seen · 95 lines · 172 tokens per session scan B 7f2e4805d940

Subscribe to this mod's changes

mihomo-tun-user-systemd is a skill published in the GitHub repository magic3007/dotfiles (11 stars, last pushed 5d ago), licensed MIT. It adds 172 tokens to every session and 1,256 once invoked, about $0.0007 per session on Opus 5.5. A static security scan graded it B with 2 findings (asks for root, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-12.

Related

mihomo-tun-user-systemd compared with skills from other repositories

mihomo-tun-user-systemd next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
mihomo-tun-user-systemdmagic3007/dotfilesSkill115d agoMITB172Claude Code, Codex
assess-qualityurmzd/dotfilesSkill64d agoApache-2.0A120Claude Code
create-oss-skillurmzd/dotfilesSkill64d agoApache-2.0A63Claude Code
extend-oss-skills-to-claudeurmzd/dotfilesSkill64d agoApache-2.0A74Claude Code
scaffold-nodeurmzd/dotfilesSkill64d agoApache-2.0A119Claude Code
test-codeurmzd/dotfilesSkill64d agoApache-2.0A101Claude Code
scaffold-docsurmzd/dotfilesSkill64d agoApache-2.0A196Claude Code