高度な使い方 · Clash ドキュメント

ルールベースの WireGuard

WireGuard のデフォルトルート取り込みを無効にした後、interface-name、DIRECT、DOMAIN ルールでトラフィックを wg0 へ送り、AllowedIPs、MTU、endpoint を確認する方法を説明します。

  • WireGuard
  • interface-name
  • AllowedIPs
  • MTU
  • endpoint
高度な使い方

カーネルが Wireguard に対応し、すでに有効になっているものとします。Table オプションを使うと、wg-quick が既定のルートを上書きするのを防げます。

wg0.conf の例:

ini
[Interface]
PrivateKey = ...
Address = 172.16.0.1/32
MTU = ...
Table = off
PostUp = ip rule add from 172.16.0.1/32 table 6666

[Peer]
AllowedIPs = 0.0.0.0/0
AllowedIPs = ::/0
PublicKey = ...
Endpoint = ...

続いて Clash では、アウトバウンドインターフェースを指定した DIRECT ポリシーグループを一つ用意するだけです:

yaml
proxy-groups:
  - name: Wireguard
    type: select
    interface-name: wg0
    proxies:
      - DIRECT
rules:
  - DOMAIN,google.com,Wireguard

通常は、Clash 独自のユーザー空間 Wireguard クライアントよりも高い性能が得られます。Wireguard はカーネル内で動作します。