Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[solved]可以实现 DNS 代理查询(via vmess)吗? #230

Closed
ghost opened this issue Aug 9, 2016 · 29 comments
Closed

[solved]可以实现 DNS 代理查询(via vmess)吗? #230

ghost opened this issue Aug 9, 2016 · 29 comments

Comments

@ghost
Copy link

ghost commented Aug 9, 2016

  1. 你正在使用哪个版本的 V2Ray?
    v1.23

  2. 你的使用场景是什么?
    场景1:PAC > HTTP > Server1 > GFW > Server2 > Free
    场景2:Chrome(SwitchyOmega) > Socks5 > Client > GFW > Server > Free

@ghost
Copy link
Author

ghost commented Aug 9, 2016

就是想在墙内输出正确(未污)的 DNS查询结果,不管是走 TCP 还是 VMESS 。

V2ray 官方文档关于 DNS 功能的说,我不是很明白。
DNS 功能是在墙外 Server 上呢?(服务器在墙外了还需要吗?)
还是在墙内的 Client 上呢?(访问墙外DNS服务器反馈的结果不会被污吗?)

@netcookies
Copy link
Contributor

netcookies commented Aug 9, 2016

不会被污,配置可以参考:https://www.v2ray.com/chapter_02/protocols/dokodemo.html
完整版本是这样的,在 Server1 上配置如下,

{
          "protocol": "dokodemo-door",
          "port": 5353,
          "settings": {
             "address": "8.8.8.8",
             "port": 53,
             "network": "tcp,udp",
             "timeout": 0
          }
}

这样你 dns 只要设置成 server1#5353 就相当于 8.8.8.8#53

@qingfengshi
Copy link

不是很明白,能看一下你的配置文件吗?@netcookies

@netcookies
Copy link
Contributor

你需要的配置我已经贴给你了呀,其它的你参考安装 v2ray 后的默认配置就好了。

@qingfengshi
Copy link

我貌似有点明白你的意思,做一个dokodemo-door的inbound,然后在客户端调用服务器的这个端口。多谢,我试试

@netcookies
Copy link
Contributor

是的,就是这个意思啦。做个 inboundDetour

@qingfengshi
Copy link

按照这个端口映射的方法,国外网站的流量应该都是通过端口映射进行DNS解析的了,但是我在现在的电脑上还是不能通过vmess实现翻墙。并且现在服务器和客户端都不报错了

@netcookies
Copy link
Contributor

你加 tg 群来贴日志和配置吧,tg 群地址在 v2ray 首页有

@ghost
Copy link
Author

ghost commented Aug 10, 2016

@netcookies 你好,

我 Client(Server1) 的原配置是,主 inbound 为 Socks5,副 inboundDetour 为 HTTP 。
我尝试了一下,设置两个副 inboundDetour ,一个为 HTTP,一个为 dokodemo-door:

"inboundDetour": [
    {
        "protocol": "http",
        "port": 80,
        "settings": {
            "timeout": 8
        }
    }
],
"inboundDetour": [
    "protocol": "dokodemo-door",
    "port": 53,
    "settings": {
        "address": "8.8.8.8",
        "port": 53,
        "network": "tcp",
        "timeout": 0
    }
]

只有一个副 inboundDetour 工作(谁在前,谁生效)

另外也常试过这样配置,同样只有设置在前面的协议生效 -_-|||

"inboundDetour": [
    {
        "protocol": "http",
        "port": 80,
        "settings": {
            "timeout": 8
        }
    },
    {
        "protocol": "dokodemo-door",
        "port": 53,
        "settings": {
            "address": "8.8.8.8",
            "port": 53,
            "network": "tcp",
            "timeout": 0
        }
    }
]

是我配置文件写错了吗?
还是就只能配置一个副 inboundDetour 并只能使用一种协议?

有没有两全其美的办法?
同时保证 Socks5 & HTTP 的 INPUT 同时又能用上 Dokodemo-door 转发?

还有个问题,Dokodemo-door 端口转发也是走 VMESS 吗?

@netcookies
Copy link
Contributor

第二种配置没问题,就是这样配置的。 dokodemo 是走 vmess的

@netcookies
Copy link
Contributor

@ghost
Copy link
Author

ghost commented Aug 11, 2016

@netcookies 好的,我再仔细测试下第二种配置方式。

另外,v2ray 的 dns 功能是供 v2ray 它自用的吧?能提供给第三方查询?

@netcookies
Copy link
Contributor

不确定,你可以配置下,看看53端口的监听 地址是什么,如果不是127.0.0.1 的话应该就是可以给第三方查询的

@ghost
Copy link
Author

ghost commented Aug 11, 2016

@netcookies OK,搞定了!谢谢你。

原因是 dokodemo-door 的传输协议必需加上 udp!如果仅设置 tcp 的话,
就会像前面我提到的——转发功能根本不工作!
(根本不监听端口、而不是53端口查询不到结果,
但是设置 53 端口 via TCP 转发并独占副 inboundDetour 却是可以工作的
没想明白为什么一定要加 UDP ……)

"inboundDetour": [
    {
        "protocol": "http",
        "port": 80,
        "settings": {
            "timeout": 8
        }
    },
{
    "protocol": "dokodemo-door",
    "port": 53,
    "settings": {
        "address": "8.8.8.8",
        "port": 53,
        "network": "tcp,udp",
        "timeout": 0
    }
}
],

记得很早看 v2ray 官网的关于端口转发功能的介绍时,并尝试去配置想达到 DNS 代理查询的目的,根本就没考虑过 udp…… 当时配置并测试了几次,但结果有时好有时污,后来没时间细琢磨就放弃了。还是一直用着 DNSCrypt + V2Ray 的组合,现在可以一个 V2Ray 都搞定 💯

@ghost ghost closed this as completed Aug 11, 2016
@ghost ghost changed the title 可以实现 DNS 代理查询(via vmess)吗? [solved]可以实现 DNS 代理查询(via vmess)吗? Aug 11, 2016
@v2ray
Copy link
Collaborator

v2ray commented Aug 11, 2016

因为 DNS 走的是 UDP 而不是 TCP,所以 dokodemo-door 上面需要开启 udp。

另外 V2Ray 的 DNS 目前只是 V2Ray 内部使用的,没有暴露给外部的方面。上面的配置是目前可行的一个 DNS 中转配置。

@ghost ghost reopened this Aug 12, 2016
@ghost ghost closed this as completed Aug 12, 2016
@ghost ghost reopened this Aug 12, 2016
@ghost
Copy link
Author

ghost commented Aug 12, 2016

@v2ray 你好!

使用 V2Ray 的 dokodemo-door 转发功能,来代理查询 DNS 也已经几天了。

首先肯定的是,已经完全无污了!但是观看一些游戏直播、在线视频的境外站点时,
感觉速度不如使用 DNSCrypt 流畅。
(楼主的 ISP 会定时在高峰期污一些大流量的境外站点,如 Twitch 等)

查找了下原因,问题可能出在 CDN 上。
同时使用 DNSCrypt 与 V2Ray 来访问 OpenDNS 的服务器 208.67.222.222 得到的结果不一样。
(DNSCrypt 是加密直连通信,GoogleDNS 不支持,所以用 OpenDNS 作对比。)

DNSCrypt 的解析结果里偶尔是会有东南亚的节点,
而 V2Ray Client 查询到的IP地址固定为美国(V2Ray Server 端所在地)。

Q:
V2Ray Server 53端口转发来自 V2Ray Client 的 UDP 数据包时,会修改源IP报头吗?
还是说只是“传递”作业(DNS Server “看”到的是 Client 的真实IP)?

(Sorry,楼主非 CODER,看不懂源码,见谅 -_-'')

@v2ray
Copy link
Collaborator

v2ray commented Aug 12, 2016

Q:
V2Ray Server 53端口转发来自 V2Ray Client 的 UDP 数据包时,会修改源IP报头吗?
还是说只是“传递”作业(DNS Server “看”到的是 Client 的真实IP)?

DNS Server 只能看到 V2Ray server 的 IP,看不到 client 的 IP 的。V2Ray 只中转实际的数据,对于最终收到数据的服务器(如 GoogleDNS)来说,它只知道是 V2Ray server 发来的数据,而不知道之前有过中转。

@ghost
Copy link
Author

ghost commented Aug 12, 2016

@v2ray 明白了,谢谢。

@ghost ghost closed this as completed Aug 12, 2016
@ghost ghost reopened this Aug 12, 2016
@ghost
Copy link
Author

ghost commented Aug 12, 2016

@v2ray 有没有可能 dokodemo-door 转发功能 以后增加“是否修改数据包IP报头”的选项

@ghost ghost closed this as completed Aug 12, 2016
@ghost ghost reopened this Aug 12, 2016
@v2ray
Copy link
Collaborator

v2ray commented Aug 12, 2016

你想以此来实现什么样的功能?

@ghost
Copy link
Author

ghost commented Aug 12, 2016

@v2ray 比如我现在碰到的状况:

Dokodemo-door 转发功能,代理 DNS 查询时修改了数据包的源 IP 报头,导致 DNS 服务器反馈了“错误”的 CDN 节点。

@v2ray
Copy link
Collaborator

v2ray commented Aug 12, 2016

强行修改 IP 报头是不行的,DNS 服务器将不会回响应数据发还给 V2Ray server,而是发给你的机器所在的 IP,而你的机器上没有打开相应的端口。然后就没有然后了…

@ghost
Copy link
Author

ghost commented Aug 12, 2016

哈哈,好象是这个道理诶~ -_-''

@ghost ghost closed this as completed Aug 12, 2016
@ghost
Copy link
Author

ghost commented Aug 24, 2016

#喜迎G20# DNSCrypt 死翘翘 ~

@leewi9
Copy link

leewi9 commented Nov 9, 2017

如果到国外VPS的延迟比较大,再用这个VPS上的DNS,不是更慢了吗

@Yuki-Nagato
Copy link

DNS使用的是UDP协议

@FH0
Copy link
Contributor

FH0 commented Jun 9, 2018

那DNS在iptables里怎么转发到v2ray的映射端口呢?

iptables -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to 5353

上面的这种方式代理不上,还有其他的方法吗?
@BenhoNNNN

@ghost
Copy link
Author

ghost commented Jun 13, 2018

@FH0 你是指什么?

@FH0
Copy link
Contributor

FH0 commented Jun 13, 2018 via email

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants