V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
tanpengsccd
V2EX  ›  宽带症候群

请教一个 Mac 的 Clash 的配置: 希望公司的内部域名走指定网卡, 普通常用域名走自己的热点

  •  
  •   tanpengsccd · 270 天前 · 2078 次点击
    这是一个创建于 270 天前的主题,其中的信息可能已经有所发展或是发生改变。

    请教一个 Clash 的配置:

    1. 希望公司的内部域名如 mycorp.com 和 192.168.10.1/24 走指定网卡.
    2. 其他普通常用域名走自己的 UFI 棒子连接公网.

    我看 Surge 上可以直接配置 指定部份域名 使用 指定的 NameServer

    [Host]
    abc.com = 1.2.3.4
    *.dev = 6.7.8.9
    foo.com = bar.com
    mycorp.com = server:192.168.10.1
    bar.com = server:8.8.8.8
    baz.com = server:https://cloudflare-dns.com/dns-query
    

    https://surge.mitsea.com/dns/local-dns-mapping 想问问 Clash P 核心 或者 meta 核心 有这个功能:域名

    1. 指定部份域名 使用 指定的 NameServer ,其他使用系统 dns 吗?
    2. 指定部份域名 使用 指定的 网卡 比如 WIFI 的 en0 ,其他走 UFI 的公网出口 吗?
    11 条回复    2023-08-04 08:23:31 +08:00
    tanpengsccd
        1
    tanpengsccd  
    OP
       270 天前
    找到了
    ```yml
    ...
    dns:
    # 对部分域名使用单独的 DNS 服务器
    nameserver-policy:
    'www.baidu.com': 114.114.114.114
    '+.internal.crop.com': system
    ...
    ```
    tanpengsccd
        2
    tanpengsccd  
    OP
       270 天前
    上面只解决问题 1, 但是 2 不行.
    tanpengsccd
        3
    tanpengsccd  
    OP
       270 天前
    2. 可能可以使用 系统工具
    networksetup -setadditionalroutes <networkservice> [ <dest> <mask> <gateway> ]* 来配置.
    mohumohu
        4
    mohumohu  
       270 天前
    interface-name
    tanpengsccd
        5
    tanpengsccd  
    OP
       269 天前
    2. clash 有个 mask on socks 特性 https://github.com/Dreamacro/clash/pull/1705
    zhinianyuxin0
        6
    zhinianyuxin0  
       269 天前
    直接找到公司内网的 ip 段,然后添加一个路由不就搞定了吗? 使用 route add 命令很简单就实现了,都不用 clash
    tanpengsccd
        7
    tanpengsccd  
    OP
       269 天前
    2. 还有个解决方案: https://github.com/Dreamacro/clash/issues/2839 按这个方案我成功了, 但是
    例子 nameserver-policy 是 数组时, 我的 verge 的 meta 内核 不能识别, 需要是 dict .
    ```
    nameserver-policy:
    "+.internal.com": [172.25.16.1#en0]
    ```
    tanpengsccd
        8
    tanpengsccd  
    OP
       269 天前
    @zhinianyuxin0 是的 networksetup -setadditionalroutes <networkservice> [ <dest> <mask> <gateway> ]* 这个直接配置路由确实简单粗暴,但是感觉侵入系统路由了,不是特别方便, 我想如果如果 我关掉 clash 就能恢复默认路由 会优雅一点.
    leefor2020
        9
    leefor2020  
       269 天前
    静态路由表的方式最好用吧
    我 Windows 上就这么实现的
    mohumohu
        10
    mohumohu  
       268 天前   ❤️ 1
    https://dreamacro.github.io/clash/configuration/configuration-reference.html
    # direct to another interfacename or fwmark, also supported on proxy
    - name: en1
    type: select
    interface-name: en1
    routing-mark: 6667
    proxies:
    - DIRECT
    zer
        11
    zer  
       267 天前 via iPhone
    换 surge 吧,这个需求实现很简单,以前用了很久,可以配置成外网走 4G ,内网走有线网
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2804 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 15:13 · PVG 23:13 · LAX 08:13 · JFK 11:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.