Shadowsocks-libev: 怎样设置才能实现ipv6优先

Created on 13 Sep 2014  ·  35Comments  ·  Source: shadowsocks/shadowsocks-libev

服务器是双栈,访问ipv6 only的站点一切正常,访问双栈的站点则ipv4优先。

Most helpful comment

@zeanzhou I have solved this problem by these steps:

make sure your vps has right ipv6 access
OS: Ubuntu 16.04.3 LTS (GNU/Linux 4.12.2-041202-generic x86_64)
ss version: shadowsocks-libev 3.1.3

  1. vi /etc/default/shadowsocks-libev
...
# add '-6' to resovle hostname to IPv6 address first
DAEMON_ARGS="-u -6" 
...
  1. vi /etc/shadowsocks-libev/config.json
...
"dns_ipv6": true
...
  1. vi /etc/hosts
...
## Scholar
## type 'host google.com' to get the correct ipv6 address
## for me it's '2607:f8b0:4005:804::200e'
2607:f8b0:4005:804::200e scholar.google.cn
2607:f8b0:4005:804::200e scholar.google.com.hk
2607:f8b0:4005:804::200e scholar.google.com
2607:f8b0:4005:804::200e scholar.l.google.com
  1. systemctl restart shadowsocks-libev

enjoy!

All 35 comments

For win7 just use
netsh int ipv6 set prefix ::1/128 50 0
netsh int ipv6 set prefix ::/0 40 1
netsh int ipv6 set prefix 2002::/16 30 1
netsh int ipv6 set prefix ::/96 20 3
netsh int ipv6 set prefix ::ffff:0:0/96 10 4
netsh int ipv6 set prefix 2001::/32 5 1

补充,我的意思是无论用ipv4或ipv6连接ss,访问双栈站点时,都是ipv6优先
目前的情况是,在ss服务器上直接访问双栈站点时,是ipv6优先
client连接到ss服务器后,就变成ipv4优先

you mean Use IPV4 address if possible

You want to improve ipv6 priority on your client,don't ya?
You should insure you have ipv6 access on your net,and just open cmd and use command which i gave you.
For linux, just put ipv6 dns address in your resolv.conf

@kxmp no,i want ss server to do this

Use ipv6 test first http://ipv6-test.com/

yes, teated with that web site
ipv4 priority

@mkoplm777 Show your screenshot of dns test

@kxmp you mean server's dns?
it's 2001:4860:4860::8888 only,

but,madeye saied
https://github.com/madeye/shadowsocks-libev/blob/master/src/server.c#L542

@mkoplm777 Test result of dns on http://ipv6-test.com/

@kxmp all Reachable

@kxmp all Reachable

@mkoplm777 You said you want ss server do that,and your server already do that : )

@kxmp it's not
always ipv4 priority

@mkoplm777 What you mean? You said you want to use ipv6,but now you said you want ipv4?!?!

@kxmp i want ipv6 priority,but now it's ipv4 priority
i think ,may be ss's problem

@mkoplm777 It depend you system and browser config.Linux prefer use ipv6 but windows seems not.
Open your cmd on you client and type nslookup he.net. Can you see a ipv6 address like it:

Addresses: 2001:470:0:76::2
216.218.186.2

when use ss-local by client,
DNS analytical always by ss serve

maybe thiss:

{
    // Use IPV4 address if possible
    for (rp = result; rp != NULL; rp = rp->ai_next)
    {
        if (rp->ai_family == AF_INET) break;
    }

Have you solved this problem? I think I can understand your meaning. My VPS (Digital Ocean) already has an ipv6 address and when I test on http://ipv6-test.com it shows that ipv6 connectivity is supported. Also, when I type "dig scholar.google.com" in ssh it will output:

;; Query time: 26 msec
;; SERVER: 2001:4860:4860::8888#53(2001:4860:4860::8888)

However, when I use the shadowsocks client to visit http://scholar.google.com, it will resolve the ipv4 address in priority, because I know the ipv4 address of my VPS (Digital Ocean SFO) has been forbidden by google scholar but ipv6 is available, so I cannot visit the page normally now.

I tried to install shadowsocks-python on my VPS, then I didn't come across this problem, the shadowsocks on server will use ipv6 in priority the same as the VPS itself, and I could visit http://scholar.google.com through ipv6 address normally.

So I think it may be specific issue on shadowsocks-libev, and I also want to let the shadowsocks on server use ipv6 address in priority.

I hava the same problems with @tufu9441

the same problems with @tufu9441

The same problems with @tufu9441

@tufu9441 Since Google Scholar blocked DO(IPv4), you can roll your own DNS server to resolve scholar.google.* with IPv6. Hit Resolve Google Scholar with IPv6 only for more info.

Same problem here.
target url: http://v4v6.ipv6-test.com/json/defaultproto.php

  • Visit directly with curl on server I got

({"address":"2402:9e80:0:1000::1:12c1","protocol":"6"})

  • client browser using a SOCKS5 proxy created by ssh -D, got

({"address":"2402:9e80:0:1000::1:12c1","protocol":"6"})

  • client browser using a SOCKS5 proxy created by ss-local, got

({"address":"45.124.66.123","protocol":"4"})

So I think ss-local or ss-server prefer IPv4. Any advise to make ss prefer IPv6?

Sorry, I found the IPv6 priority solution is made in 72ee77e.
Just add a param -6 to ss-server.

But the IPv6 to IPv4 fallback isn't suppoted after that.
try target url: http://fallback-v6.ipv6-test.com/json/proto.php

  • Visit directly with curl on server I got

({"address":"45.124.66.188","protocol":"4"})

  • client browser using a SOCKS5 proxy created by ssh -D, got

({"address":"45.124.66.188","protocol":"4"})

  • client browser using a SOCKS5 proxy created by ss-local, got

ERR_EMPTY_RESPONSE

Set "dns_ipv6": true solved the above problem.

@totmann THX! Your method solved my problem!

Really strange...
I'm using ssserver -c config.json --prefer-ipv6 -d start to run my ssserver on my VPS.

  • client browser using a shadowsocks as a proxy:

Test url: http://v4v6.ipv6-test.com/json/defaultproto.php

({"address":"2001:19f0:6001:xxxx:xxxx:xx:xxxx:xxxx","protocol":"6"})

Test url: http://fallback-v6.ipv6-test.com/json/proto.php

500 Internal Privoxy Error

But the result in google search when I search for "ip" shows that my IP is ipv6. And of course, I am still blocked by Google Scholar...

@zeanzhou I have solved this problem by these steps:

make sure your vps has right ipv6 access
OS: Ubuntu 16.04.3 LTS (GNU/Linux 4.12.2-041202-generic x86_64)
ss version: shadowsocks-libev 3.1.3

  1. vi /etc/default/shadowsocks-libev
...
# add '-6' to resovle hostname to IPv6 address first
DAEMON_ARGS="-u -6" 
...
  1. vi /etc/shadowsocks-libev/config.json
...
"dns_ipv6": true
...
  1. vi /etc/hosts
...
## Scholar
## type 'host google.com' to get the correct ipv6 address
## for me it's '2607:f8b0:4005:804::200e'
2607:f8b0:4005:804::200e scholar.google.cn
2607:f8b0:4005:804::200e scholar.google.com.hk
2607:f8b0:4005:804::200e scholar.google.com
2607:f8b0:4005:804::200e scholar.l.google.com
  1. systemctl restart shadowsocks-libev

enjoy!

@ferstar 第一步,那个目录没有那个文件咋办? 用的秋水逸冰一键脚本,

@ferstar 您好,按您的设置没有成功,想再请教一下
首先问下你们讨论的前提是vps本身自带ipv6吗?我是virmach的vps,自身没有提供ipv6,
我是按这个地址的办法,申请了ipv6 tunnel。一直到ping6 ipv6.google.com这步,都成功了,ipv6应该生效了。这篇文末说ss-libev版无法通过hosts强制访问谷歌,它一直会通过DNS解析,但您给的办法应该做到了hosts访问谷歌吧?还是说,您的办法只适用vps自身有提供ipv6,这种ipv6 tunnel的情况不适用,只能自建DNS?

Yes, I have the same problem as yours.
My ssr server have two address , for IPv4 and IPv6 .
Client use the IPv4 to access internet by ssr.
but I want to use the IPv6 of SSR to access some website.
Because some website have limited for client's IP.

@ferstar 您好,按您的设置没有成功,想再请教一下
首先问下你们讨论的前提是vps本身自带ipv6吗?我是virmach的vps,自身没有提供ipv6,
我是按这个地址的办法,申请了ipv6 tunnel。一直到ping6 ipv6.google.com这步,都成功了,ipv6应该生效了。这篇文末说ss-libev版无法通过hosts强制访问谷歌,它一直会通过DNS解析,但您给的办法应该做到了hosts访问谷歌吧?还是说,您的办法只适用vps自身有提供ipv6,这种ipv6 tunnel的情况不适用,只能自建DNS?

我是vps自带ipv6地址,你的这种情况我不清楚,而且现在我也没再用ssr了

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mcmxciv picture mcmxciv  ·  3Comments

DragonCat1 picture DragonCat1  ·  3Comments

blackgear picture blackgear  ·  3Comments

qianguozheng picture qianguozheng  ·  4Comments

iceberg1369 picture iceberg1369  ·  3Comments