Forgo7ten
V2EX  ›  问与答

能否通过 Clash 等 vpn 工具来重定向 App 的 http 流量的 host ip?

  •  
  •   Forgo7ten · Oct 16, 2024 · 1958 views
    This topic created in 601 days ago, the information mentioned may be changed or developed.

    比如我有一个公网 ip 是1.2.3.4,当我在家的时候,我希望我本机去访问局域网地址192.168.0.2

    我的 Android 应用程序的代码可能是get("http://1.2.3.4/info"),我想在 app 外去修改成192.168.0.2

    目前想到的是使用 iptables ,尝试过后确实是可以的,但不方便开关。

    但我在想能不能使用 vpn 工具来实现?我使用了 clash 规则IP-CIDR,1.2.3.4/32,Redirect-Target,但没有达到想要的效果。

    或者有没有其他方式呢?便捷、方便开关的。大佬们快来

    9 replies    2024-10-17 10:41:13 +08:00
    whileFalse
        1
    whileFalse  
       Oct 16, 2024 via Android
    用 dns 就行
    Forgo7ten
        2
    Forgo7ten  
    OP
       Oct 16, 2024
    @whileFalse 能详细说一说不? dns 不是解析域名的吗,这样还得自己搞个 dns 服务器?
    bigtear
        3
    bigtear  
       Oct 16, 2024
    程序里填 http://gay.com/info
    代理工具里分流域名 gay.com ,在家用家里的代理服务器解析到 192 ,出门手机里的代理服务器解析到 1.2.3.4
    Tink
        4
    Tink  
    PRO
       Oct 16, 2024 via Android
    dns hosts
    PolarBears
        5
    PolarBears  
       Oct 16, 2024
    @Forgo7ten #2 就是局域网 DNS 返回成你局域网地址 192.168.0.2 就行了,有的路由器系统能自己添加域名记录给内网用如 RouterOS 。或者可以在自己家里的路由器上配置 dnat ,把 1.2.3.4 改成 192.168.0.2 也可以。
    bitfly
        6
    bitfly  
       Oct 16, 2024 via Android   ❤️ 1
    我也用这个功能
    目前是用 xray 的路由编写规则
    host:qq.com 1.2.3.4
    Forgo7ten
        7
    Forgo7ten  
    OP
       Oct 17, 2024
    @bigtear
    @bitfly

    @Tink

    @PolarBears
    没有域名,有域名就用 hosts 啦。Android 应用没有办法修改,就是 ip 请求。
    用 iptables 倒是能 ip 重定向,但是重启后要重新运行一遍,不能持久化不方便开关
    Muniesa
        8
    Muniesa  
       Oct 17, 2024
    clash 规则的最后一个应该是策略组的名字吧,在本地找一台机器搭建一个 clash 支持的代理,然后这台机器上修改 iptables ,让 clash 把这个 ip 的请求转发给本地的那台机器。
    Forgo7ten
        9
    Forgo7ten  
    OP
       Oct 17, 2024
    @Muniesa 这确实可以尝试,就是麻烦了一些,感谢🙏
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5379 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 07:22 · PVG 15:22 · LAX 00:22 · JFK 03:22
    ♥ Do have faith in what you're doing.