0%

V2RayConfigure

Background

It is well known that the GFW makes it difficult to use Google which is necessary for research. With National Day coming, many IPs are blocked. However, the IPv6 address is not blocked, perhaps because the address is too long to be matched fast.

Anyway, we can not connect to the VPS via IPv4, but via IPv6. It is reasonable for us to buy a VPS with IPv6 address and reach Google Scholar with it.

Buy VPS

There are many merchants, providing VPS. You can find these merchants in many websites, such as VPS Recommend and Zhujiceping. What’s more, you can get similar information by searching in Github. I use the Ramnode for 2 years and it works well.

How to choose one

If we ignore the overselling problem, which is the main reason for bad performance under normal conditions, the main features we need to consider about are as follows.

  1. Latency. It is most important!!! However, because of the physical links and government regulation, the latency from mainland of China to VPS in Japan or Singapore is more than 100ms. HongKong, China is better, but still needs 50ms or more. As a result, if you want to play online games, VPS is not suitable for you but some other technologies.
  2. CPU and RAM. If you just install V2ray and other simple softwares, 128M RAM is enough. If you want your own blog on the VPS, better CPU and more RAM is necessary.
  3. Bandwidth. It is least important. Because even 500GB is enough for private use but if you would like to see many academic videos on Youtube, you need more bandwidth as 20-minutes HD video needs 1GB or more.

To better understand the difference of VPS, some virtualization technologies are vital. There are three main virtualization technologies used in VPS: Xen, KVM and OpenVZ. You can get more information from this link.

  1. OpenVZ, in fact, is not virtualization technology but Linux-based containerization technology. You can not run Docker on it or modify kernel modules, but OpenVZ VPS is cheapest.
  2. Xen is an open-source virtualization platform that originally began as a research project in the University of Cambridge. It uses QEMU to provide complete hardware emulation.
  3. KVM is a kernel module, and reuses many functions of the Linux kernel for its purposes. It only runs on hardware that supports hardware-assisted virtualization, and is common.

Buy Domain Name

It is necessary to buy a domain name because it is hard for us to remember 120.12.6.78 or 2340:234:be::12f. Besides, we can just change the DNS configuration without changing the configuration of our programs, which is very convenient. You can get a ‘.site’ domain for 10 year with about $30, which is not very expensive.

Install V2ray

You can install v2ray buy run the go.sh from https://install.direct/go.sh and refer to the official doc.

After installation, you need to configure the config.json. I recommend to use the mKCP or QUIC,which is faster, for the connection between client and VPS. You can get the configuration from Internet easily. The inbound configuration in VPS and the outbound configuration must be the same, for example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"outbounds": [{
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": ["123::00"],
"port": [123],
"users":[
{
"id": ["4684-4565"],
"level": 1,
"alterId": 64
}
]
}
]},
"streamSettings": {
"network": "mkcp",
"kcpSettings": {
"uplinkCapacity": 5,
"downlinkCapacity": 100,
"congestion": true,
"header": {
"type": "none"
}
}
}
}]

The configuration of inbound in client can be personalized with socks or http, with authentication or without, for example:

1
2
3
4
5
6
7
8
9
10
11
"inbounds": [{
"port": [123],
"protocol": "socks",
"sniffing":{
"enabled": true,
"destOverride": ["http", "tls"]
},
"settings": {
"auth": "noauth"
}
}],

The configuration of outbound in VPS needs to be as follows:

1
2
3
4
5
6
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]

Configure IPv6 in Aliyun

IPv6 is supported by China Mobile and other Mobile Network Operators. However, we can not use IPv6 sometimes. So we may need another server in China:

Client <– IPv4 –> China Server <– IPv6 –> Abroad Server

The ‘China Server’ need to support both IPv4 and IPv6, but it is hard in China now. Aliyun, Tencent Cloud and some other Cloud provider do not support IPv6 directly. So we need to use tunnel: 6in4. We can use the tunnel broker of HE.

Enable IPv6 in Aliyun

Modify the /etc/sysctl.conf to support IPv6:

1
2
3
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0

Restart network to support IPv6, and check with ifconfig.

Register Tunnel Broker

The website is https://www.tunnelbroker.net/ and make a registeration. Create a regular tunnel and use the public IP of Aliyun server to generate a tunnel. After this, you can get an example configurations for Linux-route2, which is suitable for CentOS. You need to change the public IP into private IP in Aliyun.

1
2
3
4
5
6
modprobe ipv6
ip tunnel add he-ipv6 mode sit remote 66.220.18.42 local [Private IP] ttl 255
ip link set he-ipv6 up
ip addr add 2001:470:c:17cb::2/64 dev he-ipv6
ip route add ::/0 dev he-ipv6
ip -f inet6 addr

Use ping6 command to check and try to ping your VPS abroad. And install V2ray in Aliyun too and make the inbound configuration as http or socks. You can use vmess or mKCP too if you would like. Finally, you get the following infrasturature and are able to reach Google Scholar.

Client <– Socks –> China Server <– V2ray –> Abroad Server

If my article helps you, I will be very happy.