• 请不要在回答技术问题时复制粘贴 AI 生成的内容
SevenNight2020
V2EX  ›  程序员

clash 问题求教

  •  1
     
  •   SevenNight2020 · May 20, 2024 · 6267 views
    This topic created in 747 days ago, the information mentioned may be changed or developed.

    环境

    macOS 14.5 clashx 1.118.1.1

    问题

    由于开发需要在 hosts 文件中做 IP 映射,我想在打开 clash 的情况下既可以科学上网,又能够正常访问映射了 IP 的服务,请问各位大哥,应该怎么做?

    18 replies    2024-05-21 00:32:37 +08:00
    supuwoerc
        1
    supuwoerc  
       May 20, 2024
    自定义规则,浏览器的话 SwitchyOmega
    ysicing
        2
    ysicing  
       May 20, 2024
    类似这样么

    ```yaml
    hosts:
    "one.one.one.one": "127.0.0.1"
    ```

    ```bash
    dig +short one.one.one.one
    127.0.0.1
    ```
    565656
        3
    565656  
       May 20, 2024
    设置里有个 bypass 选项,填进去你的 ip 就行了
    crocoBaby
        4
    crocoBaby  
       May 20, 2024
    设置->系统代理->绕过域/网络->bypass 加上 host 地址即可
    dudu2017
        5
    dudu2017  
       May 20, 2024
    ```yaml
    # Static hosts for DNS server and connection establishment (like /etc/hosts)
    #
    # Wildcard hostnames are supported (e.g. *.clash.dev, *.foo.*.example.com)
    # Non-wildcard domain names have a higher priority than wildcard domain names
    # e.g. foo.example.com > *.example.com > .example.com
    # P.S. +.foo.com equals to .foo.com and foo.com
    # hosts:
    # '*.clash.dev': 127.0.0.1
    # '.dev': 127.0.0.1
    # 'alpha.clash.dev': '::1'
    ```

    https://web.archive.org/web/20230521134928/https://dreamacro.github.io/clash/configuration/configuration-reference.html#configuration-reference
    csrocks
        6
    csrocks  
       May 20, 2024
    加规则, 中间填上不走代理的 ip 段
    - IP-CIDR,x.x.x.0/24,DIRECT
    shabbyin
        7
    shabbyin  
       May 20, 2024
    感觉挂上代理后 哪怕国内的站点走直连网速也很慢很多
    大家有这种感觉吗
    wheat0r
        8
    wheat0r  
       May 20, 2024
    @shabbyin #7 可能是规则太复杂了
    icezzz
        9
    icezzz  
       May 20, 2024
    clashx 设置有个功能忽略主机与域的代理,可以添加指定域名
    arfaWong
        10
    arfaWong  
       May 20, 2024
    clash meta 默认支持读取系统 hosts
    https://wiki.metacubex.one/config/dns/#use-system-hosts
    配套的软件换成 clash verge 吧
    https://github.com/clash-verge-rev/clash-verge-rev/releases
    Huelse
        11
    Huelse  
       May 20, 2024
    更多设置-通用-忽略这些主机与域的代理设置,加上你的开发域名就行了,不用改配置
    切换 hosts 用 switchhosts 或 ihosts 之类的
    nanno520
        12
    nanno520  
       May 20, 2024
    bypass:
    - localhost
    - svc2.nn.com
    - svc1.nn.com
    - 127.*
    这里*.nn.com 保存不了,需要什么格式吗
    asd999cxcx
        13
    asd999cxcx  
       May 20, 2024
    目前用的 cfw+docker easyconnect 是这么做的:在 docker 里面启动对应的 easyconnect 容器,在对应的节点文件里面选择预处理
    parsers: # array
    - url: 订阅的 url
    yaml:
    prepend-rules:
    - IP-CIDR,你要映射的 ip/24,项目
    - DOMAIN-SUFFIX,你要映射的域名,项目
    #上面根据你要映射的类型来,分别是映射类型,映射目标,分组名
    prepend-proxies:
    - name: "http"
    type: "http"
    server: "127.0.0.1"
    port: "8888"
    - name: "socks"
    type: "socks5"
    server: "127.0.0.1"
    port: "1080"
    #这里就是转发类型和端口号
    prepend-proxy-groups:
    - name: '项目'
    type: select
    proxies: ['http','socks']

    这样你在更新订阅的时候就会自动带上这个配置
    注意,需要用到 cfw 的 tun 模式
    ConnectException
        14
    ConnectException  
       May 20, 2024
    如果只是 web 网页需要走代理的话, 可以使用网页插件 SwitchyOmega 然后 clash 不开启系统代理, 然后需要代理的软件指向本机的 clash 的端口即可, 然后 chalsh 规则开全局代理

    这样哪些软件需要走代理就直接配置代理就可以了 SwitchyOmega 分流也很方便
    Virexw
        15
    Virexw  
       May 20, 2024   ❤️ 1
    @supuwoerc #1 用新版吧,ZeroOmega 。SwitchyOmega 快不支持了。
    tzlovezaq
        16
    tzlovezaq  
       May 20, 2024
    我也有个问题,我在 NAS 上部署了 docker 版的 bt 服务,在旁路由部署了 clash ,怎么让 bt 服务不走代理?
    现在为了实现这一目的,我的漏网之鱼都直连了。

    bt 服务 IP 和端口:192.168.0.1:6800
    旁路由:192.168.0.2

    请说的细一点,有点笨
    wheat0r
        17
    wheat0r  
       May 20, 2024
    @tzlovezaq #16 你可以用给容器使用 macvlan 网络,直接分配出口路由器地址作为网关地址
    chengyecc
        18
    chengyecc  
       May 21, 2024 via Android
    @shabbyin 可能是影响了 dns 解析,导致连不到最近的 cdn ,甚至走海外线路,比如 b 站,如果解析到其他地域的 ip ,直播就会非常卡
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2792 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 80ms · UTC 14:48 · PVG 22:48 · LAX 07:48 · JFK 10:48
    ♥ Do have faith in what you're doing.