# mihomo

### 官网

> **mihomo:**
>
> <https://github.com/MetaCubeX/mihomo>
>
> <https://hub.docker.com/r/metacubex/mihomo/tags>
>
> **yacd:**
>
> <https://github.com/haishanh/yacd/>
>
> <https://hub.docker.com/r/haishanh/yacd/tags>

### 准备配置文件

```bash
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sysctl -p

mkdir -p /usr/local/mihomo
cd /usr/local/mihomo
wget https://feedneo.com/files/xHaeRNxG5f/clash.yml
```

#### mihomo.yml

<pre><code>cat > /usr/local/clash/mihomo.yml &#x3C;&#x3C; EOF
mixed-port: 7890

allow-lan: true

mode: Rule

log-level: info

external-controller: 0.0.0.0:9090
secret: 'Will_D'

experimental:
  sniff-tls-sni: true

tun:
  enable: true
  stack: system
  dns-hijack:
    - 8.8.8.8:53
    - tcp://8.8.8.8:53
    - any:53
    - tcp://any:53
  auto-route: true
  auto-detect-interface: true
  
dns:
  enable: true
  listen: 0.0.0.0:553
  default-nameserver:
    # 192.168.1.2为本案例中AdGuard自建的DNS，可以按需修改
    - 192.168.1.2
    - 119.29.29.29
    - 223.5.5.5
  fake-ip-range: 198.18.0.1/16 # Fake IP addresses pool CIDR
  fake-ip-filter:
    - '*.lan'
    - localhost.ptlogin2.qq.com
  nameserver:
<strong>      - 192.168.1.2
</strong>      - 119.29.29.29
      - 114.114.114.114
      - 223.5.5.5
  fallback:
      - https://doh.pub/dns-query
      - https://cloudflare-dns.com/dns-query
      - https://1.12.12.12/dns-query
      - https://120.53.53.53/dns-query
  fallback-filter:
    geoip: true
    geoip-code: CN
    ipcidr:
      - 240.0.0.0/4
    domain:
      - '+.google.com'
      - '+.facebook.com'
      - '+.youtube.com'

EOF

sed -n '24,$p' clash.yml >> mihomo.yml

</code></pre>

#### docker-compose.yml

```yaml
cat > /usr/local/mihomo/docker-compose.yml << EOF
services:
  clash:
    container_name: mihomo
    image: registry.cn-chengdu.aliyuncs.com/yunwei361/mihomo:latest
    cpus: '2'
    mem_limit: 1024M
    restart: always
    network_mode: host
    privileged: true
    devices:
      - /dev/net/tun
    volumes:
      - /usr/local/clash/clash-premium.yml:/root/.config/clash/config.yaml
    environment:
      - TZ=Asia/Shanghai

  mihomo-web:
    container_name: mihomo-web
    image: registry.cn-chengdu.aliyuncs.com/yunwei361/yacd:latest
    cpus: '2'
    mem_limit: 256M
    restart: always
    ports:
      - "1234:80"
    environment:
      - TZ=Asia/Shanghai
EOF

```

### 用 Docker compose 启动容器

```bash
# 启动 Clash
cd /usr/local/mihomo/
docker compose up -d

# 停止服务
docker compose down
```

### 浏览器访问

```
# Clash-Web UI
192.168.1.2:1234
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://network.yunwei361.com/gfw/mihomo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
