V2Ray Guide: A Path to Internet Freedom
V2Ray is a product born out of frustration, a call for freedom. In 2015, after developers behind tools like Shadowsocks and GoAgent were pressured to shut down, the creator of V2Ray decided to take up the mantle of building a new "scientific internet access" tool. He once wrote:
I'm just an ordinary developer who has already left China and doesn't rely on these tools anymore. But seeing the forced takedown of ShadowSocks and GoAgent's code was too much, so I felt I had to do something.
V2Ray has grown into a mature and user-friendly tool since its inception. Today, I'll walk you through how to use it effectively.
First, here are some resources worth checking out:
-
V2Ray Source Code(The original creator is no longer active; the project has been moved to V2Fly) -
V2Ray Official Website(The latest official site is V2Fly.org) - New V2Ray Guide (Plain Language)
- Configuration Documentation
Table of Contents
Getting V2Ray
The latest version of V2Ray can be found either on the official website or directly on its GitHub Releases page:
V2Ray is available as pre-built packages for many platforms. You can check the available packages here. For example, on Arch Linux, you can install V2Ray with the following command:
pacman -S v2ray
Configuring V2Ray
There are many ways to configure V2Ray, and I highly recommend reading
through the
New V2Ray Guide (Plain Language)
to tailor a setup that suits your needs. For beginners, I suggest
starting with the "mKCP Configuration" from the guide, and I
also recommend adding a seed
parameter as described in
the
configuration documentation
under KcpObject
.
You can generate a UUID using this tool.
Using the Client
For a full list of third-party clients, please check the official website. Here, I'll focus on some recommended clients.
Linux
Running V2Ray
If you installed V2Ray via your system's package manager, you can skip ahead to the "Enabling Systemd Auto-Start for V2Ray" section.
After downloading and extracting V2Ray, copy your
config.json
file into the extracted directory and run
V2Ray:
./v2ray
If the file isn't executable, check its properties (right-click -> Properties -> Permissions -> Allow executing file as program) or use the following command:
chmod +x v2ray
Once it's running, you'll see a message indicating where V2Ray is listening, such as:
2000/01/01 00:00:00 [Info]TCP|Listener: Listening on 127.0.0.1:1080
In this case, the proxy address is 127.0.0.1
, and the
port is 1080
.
Enabling Systemd Auto-Start for V2Ray
Enabling auto-start on boot significantly improves the user experience. There are various ways to do this, but here's a simple method using systemd (if you installed V2Ray via your package manager, you might be able to skip this configuration).
First, create a v2ray.service
file under
/lib/systemd/system/
:
vim /lib/systemd/system/v2ray.service
Edit the v2ray.service
file as follows:
[Unit]
Description=V2Ray Service
Documentation=https://www.v2fly.org/
After=network.target nss-lookup.target
[Service]
User=nobody
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/usr/bin/v2ray -config /etc/v2ray/config.json # you might want to update the config file
Restart=on-failure
RestartPreventExitStatus=23
[Install]
WantedBy=multi-user.target
Remember to update the path to your configuration file. After editing,
save and exit (use :wq
in vim). Then, enable the service:
systemctl enable v2ray.service
That's it! If you ever need to disable the service:
systemctl disable v2ray.service
For more information on systemd, refer to the Arch Linux Wiki.
Checking Systemd Logs
If you encounter errors while running V2Ray, you can normally check
the logs directly. However, when using systemd, you can view the logs
for v2ray.service
with this command:
journalctl -u v2ray.service
This method works for checking logs for other services as well, helping you quickly identify issues.
Setting Up the Proxy
Once V2Ray is running, you can set up a global proxy in your system. In GNOME, for example:
Settings -> Network -> Network Proxy -> Manual
Environment variables
You can also set up environment variables (replace fields marked with
<>
accordingly). To make the settings permanent,
add them to your ~/.bashrc
file:
proxy=<http://ProxyServerAddress:Port/>
export all_proxy=$proxy
export ALL_PROXY=$proxy
export http_proxy=$proxy
export https_proxy=$proxy
export ftp_proxy=$proxy
export rsync_proxy=$proxy
export HTTP_PROXY=$proxy
export HTTPS_PROXY=$proxy
export FTP_PROXY=$proxy
export RSYNC_PROXY=$proxy
export no_proxy="localhost,127.0.0.0/8,::1,<LocalAddress>,<LocalDomain>"
Extending Proxy Access to sudo
To ensure that sudo commands also use the proxy, add the following to
/etc/sudoers.d/05_proxy
(from
this guide):
Defaults env_keep += "*_proxy *_PROXY"
There are many additional tweaks you can explore. I highly recommend reading this Arch Wiki page for more details.
After setting up a global proxy, you'll still need to configure your browser to use it.
Firefox
In Firefox:
menu -> Preferences -> Advanced -> Network -> Setting -> Manual proxy configuration
Enter the proxy address in the SOCKS Host field and the port in the Port field.
Chromium
In Chromium, the proxy settings follow the system's global configuration:
menu -> Settings -> Show advanced settings... -> Network -> Change proxy settings...
Usually, this will bring up your system's proxy settings. If it doesn't, manually open your system settings or follow the terminal prompts.
Android
You can download the following apps either from the Play Store or their project pages:
These apps work similarly—just import your
config.json
file to start using them.
Conclusion
V2Ray is not a simple tool, but it fulfills the purpose it was created for. Sometimes complexity is not something we seek, but rather something imposed by the times or society. Let this be a reminder for all of us.
Stay true to your purpose, and you'll see it through to the end.
Sincerely.