Host:接管本机流量
Host 接法创建 TUN,并用策略路由把本机流量送进 mayami。它适合单台 Linux 主机,不要求有 LAN 或路由器角色。
完整配置
yaml
inbounds:
host:
type: tun
interface: mayami0
address: [198.18.0.1/30]
auto_route: true
strict_route: false
outbounds:
direct:
type: direct
proxy:
type: socks
server: 127.0.0.1:1080
route:
rules:
- {ip_is_private: true, outbound: direct}
final: proxy
dns:
servers:
real: {type: udp, address: 1.1.1.1:53}
fake: {type: fakeip, inet4_range: 198.18.0.0/15}
rules:
- {query_type: [A, AAAA], server: fake}
final: real路由字段见 tun。
包怎么走
auto_route 为 TUN 地址族安装默认路由到独立表,并用策略规则只把指定 UID、来源口和地址范围送进 TUN。mayami 自己的连接带 mark,走主表,避免代理隧道本身再次进入 TUN。
strict_route 让 TUN 不支持的地址族也被接住并拒绝;进程被强杀时路由会保留,下次启动再接管。
选择直连与代理
直连仍由 mayami 拨 socket,因此可以执行 bind_address、interface 和 socket mark。与 Router 不同,本机流没有 LAN 帧来源,source_mac_address、capture 入站名等事实不可用。
宿主机会被改什么
mayami 会创建 TUN、写独立路由表和 ip rule,可能调整转发/RA sysctl。退出时清理自己创建的状态;strict_route 和异常退出会改变清理边界。