mihomo Documentation

repository·main·Indexed 41 days ago

https://github.com/metacubex/meta-docs

Documentation for mihomo, including detailed guides on the External Control API for managing proxies, policy groups, rule sets, and connections. Covers system monitoring via traffic and memory endpoints, kernel and GEO database updates, DNS query inspection, and debug profiling using pprof.

Tokens
163.3K
Snippets
536
Records
755
Agent score
50%

What's inside mihomo

  1. Overview of Terminal of Void (mihomo)

    main

    Terminal of Void (mihomo) is an open-source derivative of the Genshin Impact project, enhanced with unique features. It supports all standard Genshin Impact functions and a subset of Genshin Impact Premium functions.

    Important Usage Notes:

    • Naming Restriction: Any project not associated with MetaCubeX must not use the word mihomo in its name.
    • Version Compatibility: This documentation is based on the Alpha branch of Terminal of Void. Older versions may not support all documented features.
    • Documentation Status: The documentation is currently under development. Users are encouraged to contribute via Pull Requests.
  2. Third-party clients using the mihomo core

    main

    The following list identifies third-party tools and clients that use or include the mihomo core.

    Important Note: These tools are not directly controlled by the mihomo developers. They may lack the latest features or fixes found in the official version. For issues not related to the core itself, please contact the respective third-party project maintainers.

  3. Configure inbound connections in mihomo

    main

    mihomo accepts incoming traffic through three primary methods: Proxy Ports, TUN, and Listeners. The accessibility of these connections from the internet depends on the listening address, system routing, and firewall settings rather than the protocol category.

    Methods of Configuration

    1. Proxy Ports: Use top-level parameters like port, socks-port, mixed-port, redir-port, and tproxy-port when you only need a single fixed set of proxy ports.
    2. TUN: Use the top-level tun configuration to intercept system traffic. This is suitable for automatic routing, DNS interception, and routing specific applications.
    3. Listeners: Use the listeners field to create multiple incoming connections of different types with different addresses and ports simultaneously. Each listener can have its own independent rule and proxy settings.
    listeners:
      - name: socks5-in-1
        type: socks
        port: 10808
        # listen: 0.0.0.0 # default
        # rule: sub-rule-name1
        # proxy: proxy
        # udp: false # default is true
  4. Third-party tools and clients using mihomo kernel

    main

    This document provides a curated list of third-party tools and clients that utilize or include the mihomo kernel.

    Important Disclaimer: These tools are developed by third parties and are not directly controlled by the mihomo project. They may not always include the latest official features or bug fixes. If you encounter issues that are not related to the core kernel itself, please report them directly to the respective third-party tool/client developers.

  5. How DNS interception works in Mihomo

    main
    Mihomo utilizes DNS interception to intercept DNS queries. This mechanism allows traffic originating from incoming connections via TUN, Redirect, or TProxy to map IP addresses to their corresponding domain names. This is essential for ensuring that traffic can be correctly routed and identified based on hostnames rather than just IP addresses.
  6. Configure xhttp transport for VLESS

    main

    The xhttp transport layer is exclusively supported by the VLESS protocol. It is only active when the transport layer is explicitly set to xhttp.

    Protocol Versions (ALPN)

    By default, only h2 (HTTP/2) is supported. To use other versions, you must configure the alpn parameter:

    • HTTP/3: Set alpn: ["h3"]
    • HTTP/1.1: Set alpn: ["http/1.1"]
  7. Configure DNS resolution modes (fake-ip vs redir-host)

    main

    The enhanced-mode determines how DNS is handled for traffic interception. Supported values are fake-ip and redir-host (default).

    Fake-IP Mode

    In fake-ip mode, the system returns a virtual IP address to the client instead of the real IP. This requires configuring ranges:

    • fake-ip-range: The IPv4 range for fake IPs (e.g., 198.18.0.1/16). This is also used as a reference for the tun inbound.
    • fake-ip-range6: The IPv6 range for fake IPs.
    • fake-ip-ttl: The TTL returned for fake-ip queries. Do not change this unless necessary.

    Fake-IP Filtering

    You can prevent certain domains from receiving a fake IP using fake-ip-filter and fake-ip-filter-mode.

    • fake-ip-filter-mode:
      • blacklist (default): Domains in the filter will NOT get a fake IP.
      • whitelist: Only domains in the filter will get a fake IP.
      • rule: Uses routing rule syntax (GEOSITE, RuleSet, etc.) to decide whether to assign a fake IP or a real IP.
    • fake-ip-filter: A list of domains or patterns to exclude from fake-ip mapping.
    dns:
      enhanced-mode: fake-ip
      fake-ip-range: 198.18.0.1/16
      fake-ip-filter-mode: rule
      fake-ip-filter:
        - RULE-SET,reject-domain,fake-ip
        - GEOSITE,gfw,fake-ip
        - DOMAIN,www.baidu.com,real-ip
        - MATCH,fake-ip
  8. Configure Fake-IP mode and filtering

    main

    Fake-IP mode maps domains to a virtual IP range to speed up resolution and routing.

    Core Settings

    • enhanced-mode: Set to fake-ip to enable this mode (default is redir-host).
    • fake-ip-range: The IPv4 range for fake-ip mappings.
    • fake-ip-range6: The IPv6 range for fake-ip mappings.
    • fake-ip-ttl: The TTL returned by fake-ip queries (do not modify unless necessary).

    Filtering Logic

    fake-ip-filter defines domains that should receive real IP mappings instead of fake IPs.

    • fake-ip-filter-mode:
      • blacklist (default): Matches in fake-ip-filter get real IPs.
      • whitelist: Only matches in fake-ip-filter get fake IPs.
      • rule: Uses routing rule syntax (GEOSITE, RuleSet, DOMAIN*, MATCH).

    Rule Mode Example

    When fake-ip-filter-mode is set to rule, use the following syntax:

    dns:
      fake-ip-filter-mode: rule
      fake-ip-filter:
        - RULE-SET,reject-domain,fake-ip
        - GEOSITE,gfw,fake-ip
        - DOMAIN,www.baidu.com,real-ip
        - MATCH,fake-ip
    dns:
      enhanced-mode: fake-ip
      fake-ip-range: 198.18.0.1/16
      fake-ip-filter-mode: blacklist
      fake-ip-filter:
        - '*.lan'
  9. How to choose a network stack for TUN

    main

    The stack option determines how network protocols are handled. Choosing the right stack affects stability, security, and performance.

    • system: Uses the operating system's native network stack. It is generally more stable, provides a more comprehensive experience, and consumes fewer resources.
    • gvisor: Implements the network stack in user space. This provides higher security and isolation, and can improve performance by avoiding kernel/user-space context switching in specific scenarios.
    • mixed: A hybrid approach where TCP uses the system stack and UDP uses the gvisor stack. This often provides the best overall experience.
    • mips: Uses an IP stack specifically developed by mihomo.

    Important: Firewall Compatibility If a firewall is enabled, system and mixed stacks may not work. You must allow the core through the firewall:

    • Windows: Allow the application through Windows Defender Firewall.
    • MacOS: Allow the mihomo application in System Settings > Network > Firewall > Options.
    • Linux: Allow outgoing traffic for the TUN interface (e.g., sudo iptables -A OUTPUT -o Mihomo -j ACCEPT).
    tun:
      stack: mixed # Recommended for most users
  10. Configure Fallback Filtering

    main

    When using fallback servers, fallback-filter determines if the results from nameserver are sufficient or if fallback must be used.

    Filter Options

    • geoip: Enables GeoIP judgment. If geoip-code (default CN) is set, results from IPs outside that country are considered 'polluted' and trigger a fallback query.
    • geosite: (Deprecated) Domains in these collections are considered polluted and will force fallback resolution. Use nameserver-policy instead.
    • ipcidr: Subnets (e.g., 192.168.0.0/16) that are considered polluted.
    • domain: Specific domains that are considered polluted.
    • fallback-lazy-query: If true, the system only initiates a fallback query if the nameserver results fail the fallback-filter conditions.
    dns:
      fallback:
        - tls://8.8.4.4
      fallback-filter:
        geoip: true
        geoip-code: CN
        ipcidr:
          - 240.0.0.0/4
        domain:
          - '+.google.com'
  11. Use JSON syntax in YAML configurations

    main

    Since yaml is a superset of json, you can use JSON syntax for objects and arrays within your configuration files. This includes multi-line JSON, single-line JSON, and full JSON structures.

    # Multi-line JSON
    tun: { 
      enable: true,
      stack: system,
      auto-route: true,
      auto-detect-interface: true
    }
    
    # Single-line JSON
    tun: { enable: true, stack: system, auto-route: true, auto-detect-interface: true }