Closed picklefan closed 3 years ago
"routing": {
"domainStrategy": "UseIP",
This is incorrect. See https://www.v2fly.org/config/routing.html
"domain:zhu.com": "google.com"
This is not how you use hosts. Your request will be rejected by Google's server due to the invalid SNI (zhu.com
).
"routing": { "domainStrategy": "UseIP",
This is incorrect. See https://www.v2fly.org/config/routing.html
But the document says I should use "Useip" other than the default setting.
WARNING
For outbounds with freedom protocol, the default value of domainStrategy is AsIs, therefore the DNS settings will not be >applied to this outbound by default. If necessary, it should be configured as UseIP.
But the document says I should use "Useip" other than the default setting.
UseIP
is only used in outbound settings. See https://www.v2fly.org/config/protocols/freedom.html#outboundconfigurationobject. For example:
{
"protocol": "freedom",
"settings": {
"domainStrategy": "UseIP"
},
"tag": "direct"
},
But I'm pretty sure you don't actually want UseIP
. What you're attempting to do is just not possible in practice. It's never going to work the way you want it to.
There are two domainStrategy
s, one in routing
, the other in freedom
outbound.
The one in routing
has three options "AsIs" | "IPIfNonMatch" | "IPOnDemand". The one in freedom
outbound has four options "AsIs" | "UseIP" | "UseIPv4" | "UseIPv6".
For outbounds with freedom protocol, the default value of domainStrategy is AsIs, therefore the DNS settings will not be applied to this outbound by default. If necessary, it should be configured as UseIP.
The meaning of the above sentence states that DNS settings will not apply to freedom outbound if the domainStrategy in freedom outbound is using the default value AsIs
.
"domain:zhu.com": "google.com"
This is not how you use hosts. Your request will be rejected by Google's server due to the invalid SNI (
zhu.com
).
Why, I assumed when I type zhu.com in my browser, the V2ray should request google.com instead.
hosts: map{string: address}
Static IP list, its value is a series of "domain name": "address". The address can be an IP or domain name. When resolving a >domain name, if the domain name matches an item in this list when the address of the item is an IP, the resolution result is the >IP of the item, and the following servers are not used for resolution; when the address is a domain name, this domain name will >be used for IP resolution instead of the original domain name.
There are two
domainStrategy
s, one inrouting
, the other infreedom
outbound.The one in
routing
has three options "AsIs" | "IPIfNonMatch" | "IPOnDemand". The one infreedom
outbound has four options "AsIs" | "UseIP" | "UseIPv4" | "UseIPv6".For outbounds with freedom protocol, the default value of domainStrategy is AsIs, therefore the DNS settings will not be applied to this outbound by default. If necessary, it should be configured as UseIP.
The meaning of the above sentence states that DNS settings will not apply to freedom outbound if the domainStrategy in freedom outbound is using the default value
AsIs
. OK, thanks, I see it now.
But the document says I should use "Useip" other than the default setting.
UseIP
is only used in outbound settings. See https://www.v2fly.org/config/protocols/freedom.html#outboundconfigurationobject. For example:{ "protocol": "freedom", "settings": { "domainStrategy": "UseIP" }, "tag": "direct" },
But I'm pretty sure you don't actually want
UseIP
. What you're attempting to do is just not possible in practice. It's never going to work the way you want it to.
Yes, you are right, I can use it to jump to my own site. But why can't google.
"domain:zhu.com": "google.com"
This is not how you use hosts. Your request will be rejected by Google's server due to the invalid SNI (
zhu.com
).
Got it. Thanks a lot.
Yes, you are right, I can use it to jump to my own site. But why can't google.
Because you didn't configure your web server to enforce a server name. A common practice is to configure a default server to return 404 for requests with a server name not matched by any other server. For example, with nginx
, we can do:
http {
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name _;
if ($host = zhu.com) {
return 301 https://$host$request_uri;
}
return 404;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name zhu.com;
}
}
Yes, you are right, I can use it to jump to my own site. But why can't google.
Because you didn't configure your web server to enforce a server name. A common practice is to configure a default server to return 404 for requests with a server name not matched by any other server. For example, with
nginx
, we can do:http { server { listen 80 default_server; listen [::]:80 default_server; listen 443 ssl http2; listen [::]:443 ssl http2; server_name _; if ($host = zhu.com) { return 301 https://$host$request_uri; } return 404; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name zhu.com; } }
Well, I thought when I put request zhu.com to V2ray it would turn my request as google.com to DNS. Guess I thought it wrong. Though I think the document is confusing in that part.
你正在使用哪个版本的 V2Ray?
V2Ray 4.35.1 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.16 linux/amd64) A unified platform for anti-censorship. 2021/03/11 01:10:48 Using config from STDIN 2021/03/11 01:10:48 [Info] github.com/v2fly/v2ray-core/v4/main/jsonem: Reading config: stdin:
你的使用场景是什么?
chrome 通过 VMess
你看到的异常现象是什么?
host 无法匹配 域名或IP
你期待看到的正常表现是怎样的?
"dns": { "hosts": { "domain:zhu.com": "google.com" }, //当我输入zhu.com的时候,他应该使用Google.com来解析(当该项的地址为域名时,会使用此域名进行 IP 解析,而不使用原始域名https://www.v2fly.org/config/dns.html#dnsobject)
请附上你的配置
服务端配置: { "log": { "access": "/var/log/v2ray/access.log", "error": "/var/log/v2ray/error.log", "loglevel": "debug"
},
}
客户端配置: 客户端配置无关紧要,这个问题不应该和客户端有任何关系。
请附上出错时软件输出的错误日志
服务器端错误日志: 2021/03/11 01:48:07 [Info] [4102618292] github.com/v2fly/v2ray-core/v4/proxy/vmess/inbound: received request for tcp:zhu.com:80 2021/03/11 01:48:07 [Info] [4102618292] github.com/v2fly/v2ray-core/v4/app/dispatcher: default route for tcp:zhu.com:80 2021/03/11 01:48:07 [Info] [4102618292] github.com/v2fly/v2ray-core/v4/proxy/freedom: opening connection to tcp:zhu.com:80 2021/03/11 01:48:07 [Info] [4102618292] github.com/v2fly/v2ray-core/v4/transport/internet/tcp: dialing TCP to tcp:zhu.com:80 2021/03/11 01:48:07 [Warning] github.com/v2fly/v2ray-core/v4/proxy/vmess/encoding: Critical Warning: potentially invalid user: a non VMessAEAD connection is received. From 2022 Jan 1st, this kind of connection will be rejected by default. You should update or replace your client software now. 2021/03/11 01:48:07 [Info] [1582210667] github.com/v2fly/v2ray-core/v4/proxy/vmess/inbound: received request for tcp:zhu.com:80 2021/03/11 01:48:07 [Info] [1582210667] github.com/v2fly/v2ray-core/v4/app/dispatcher: default route for tcp:zhu.com:80 2021/03/11 01:48:07 [Info] [1582210667] github.com/v2fly/v2ray-core/v4/proxy/freedom: opening connection to tcp:zhu.com:80 2021/03/11 01:48:07 [Info] [1582210667] github.com/v2fly/v2ray-core/v4/transport/internet/tcp: dialing TCP to tcp:zhu.com:80 2021/03/11 01:48:22 [Info] [1582210667] github.com/v2fly/v2ray-core/v4/transport/internet/tcp: dialing TCP to tcp:zhu.com:80 2021/03/11 01:48:22 [Info] [4102618292] github.com/v2fly/v2ray-core/v4/transport/internet/tcp: dialing TCP to tcp:zhu.com:80 2021/03/11 01:48:38 [Info] [1582210667] github.com/v2fly/v2ray-core/v4/transport/internet/tcp: dialing TCP to tcp:zhu.com:80 2021/03/11 01:48:38 [Info] [4102618292] github.com/v2fly/v2ray-core/v4/transport/internet/tcp: dialing TCP to tcp:zhu.com:80 2021/03/11 01:48:42 [Info] [1582210667] github.com/v2fly/v2ray-core/v4/transport/internet/tcp: dialing TCP to tcp:zhu.com:80 2021/03/11 01:48:42 [Info] [4102618292] github.com/v2fly/v2ray-core/v4/transport/internet/tcp: dialing TCP to tcp:zhu.com:80
客户端错误日志: 2021/03/10 22:48:07 tcp:127.0.0.1:62673 accepted tcp:zhu.com:80 [proxy] 2021/03/10 22:48:07 tcp:127.0.0.1:62674 accepted tcp:zhu.com:80 [proxy]
请附上访问日志
其它相关的配置文件(如 Nginx)和相关日志
如果 V2Ray 无法启动,请附上
--test
命令的输出如果 V2Ray 服务运行异常,请附上 journal 日志