V2Ray is a very popular network proxy tool. With its powerful functions and flexible configuration, it has become the preferred tool for many people to break through network restrictions and enhance privacy protection. Compared with another popular proxy tool Shadowsocks, V2Ray supports more protocols (such as VMess, VLess, Socks, etc.), has stronger anti-detection capabilities, and can be used with a variety of client apps. Therefore, it is favored by many technical users and ordinary users.
This article will teach you how to use V2Ray from scratch. Let's start with the preparation.
To use V2Ray, you first need a V2Ray server, also commonly called a V2Ray node, and then use the V2Ray client app to connect to this server, which is a bit like using a VPN, except that VPN does not require us to build a server ourselves, and we can directly use the client to connect to the VPN provider's server. If you think it is more convenient to use a VPN, you can consider subscribing a VPN service, but be careful to choose a VPN with a good reputation and long-term stability, such as NordVPN, Surfshark, and ExpressVPN.
The V2Ray server is usually deployed on a VPS located outside your country, so before you start using V2Ray, you need to get a VPS. You can choose a cloud service provider to register a user account on their website, and then create a VPS from there. The specific steps are as follows.
Choose a cloud service provider
Some well-known cloud service providers are: DigitalOcean, Vultr, BandwagonHost, Amazon Cloud (AWS). Amazon Cloud is usually used for large-scale network projects or enterprise-level applications, and the price is also higher, so it is recommended to choose DigitalOcean, Vultr, or BandwagonHost. This tutorial will choose DigitalOcean, but if you choose other ones, the subsequent steps are basically the same.
The following is a brief introduction on how to create a VPS on DigitalOcean.
Create a VPS
First, go to the DigitalOcean website and sign up with your email address, or with a Google account or GitHub account.
After signup, you need to choose a payment method for your DigitalOcean account. You can choose Visa, MasterCard, PayPal, etc.
Then click the green "Create" button in the upper right corner of the page, and click the first item in the drop-down menu, that is, "Droplets", which will enter the page for creating a new VPS. (Droplet is a special name for VPS used by DigitalOcean)
The page for creating a VPS is divided into several parts, each with different options and settings. It is recommended to select and set as shown below:
Choose Region: Select a city closer to your country. Because the server in a closer location will make V2Ray's transmission faster due to the shorter distance.
Datacenter: The default is fine, no need to change.
Choose an image: The default Ubuntu is good, no need to change. And the version number does not need to be changed, too.
Choose Size: Select Basic > Regular > $6/mo, which is enough for personal use. If you plan to share your V2Ray server with multiple users, you can choose one with a higher price according to usage.
Additional Storage and Backups: Not required, just skip them
Choose Authentication Method: For the convenience of beginners, it is recommended to select Password and then enter a password below. This password will be used when you log in after connecting to the VPS using SSH. It is best not to use a simple password.
Keep all other settings as default, and then click the "Create Droplet" button at the bottom of the page to create the VPS. It takes about ten seconds to a minute for the VPS to be created. After that, the page will display the IP address of the VPS. You can copy it and use it when connecting to the VPS later.
Connect to VPS
Next, we use SSH to connect to the newly created VPS.
Windows users can open the system application PowerShell, and Mac users open Terminal. Then enter the following command in the command line interface and press Enter (note that "your_server_ip" should be replaced with the IP address of the VPS you created.):
ssh root@your_server_ip
When connecting to a VPS that has never been connected before, the system will display the following prompt:
This key is not known by any other names. Are you sure you want to continue connecting (yes/no)
You need to enter yes and press Enter to confirm.
After connected, the interface will display the following text to ask you to enter the VPS login password:
root@your_server_ip's password:
Enter the password you provided when creating the VPS and press Enter (the interface will not display the characters you enter when typing).
If logged in successfully, the cursor will be displayed at the end of the line of characters shown below (the "@" is followed by your VPS name. When creating a VPS, the system will give it a default name. You can also give your VPS a different name in the VPS control panel, but the name does not affect the subsequent steps).
root@the-hostname-of-your-server:~#
Then you can start entering the following commands to deploy V2Ray. First install V2Ray on the VPS, then configure and optimize.
Install V2Ray
Before installing V2Ray, update the package list and install cURL to download the V2Ray installation script. Use the following command to complete it.
apt-get update -y && apt-get install curl -y
After entering the command, press Enter to execute. It takes from ten seconds to one minute to update the package list and install cURL. In the newer Ubuntu system, an option prompt may pop up in the command line interface during this process, if you see it, press Enter to continue.
After completion, start downloading and installing V2Ray. Using the one-click installation script recommended by V2Ray developers, you can complete the installation of V2Ray with just one command.
Use the following command:
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
After pressing Enter, the system will start downloading and installing the latest version of V2Ray. It will take 10 to 20 seconds for it to complete. After installed, the command line interface will display text to tell you that V2Ray has been installed. Next, start configuring V2Ray.
Configure V2Ray
When configuring V2Ray, you need a user ID. This user ID needs to conform to the UUID format. You can use the following command to generate it in the command line interface.
uuidgen
After the user ID is generated, you should write it down or copy it and save it to your computer's notepad (select the id and press Ctrl+Shift+C to copy).
Then edit the V2Ray configuration file, using the following command:
vi /usr/local/etc/v2ray/config.json
This command uses the Vi editor to open a file called config.json. The file is almost blank, with only two curly braces.
First press the "delete" key to delete the two curly braces, and then you can add configuration content to the file.
V2Ray has multiple configuration methods. If you are a novice, it is recommended to start with simple configuration and then gradually explore more advanced configuration methods in the future.
The following is a basic configuration. You can directly copy the text into the configuration file (note to replace the user ID with the ID you generated in the previous step; just right-click to paste the content into the command line interface; press the "i" key on the keyboard to enter the editing mode of the Vi editor to start editing the content; use the arrow keys to move the cursor on the interface.).
{ "inbounds": [ { "port": 8000, "protocol": "vmess", "settings": { "clients": [ { "id": "a1111111-1111-1111-1111-111111111111", "alterId": 0 } ] } } ], "outbounds": [ { "protocol": "freedom", "settings": {} } ] }
The most important parameters in the configuration file are user ID, port, and alterID. You need to copy or remember them because you will need to enter them when you use the V2Ray client app. You can change the port to another number, but you don't need to change alterID.
If you plan to share your V2Ray server with others, you can add new users to the configuration file. For detailed configuration methods of multi-user connection, read this tutorial.
After editing the configuration file, press the Esc key to exit the editing mode, then enter :wq
and press Enter to save the file content and exit the Vi editor.
Optimize speed (optional)
Now that your V2Ray server has been set up, you can start using V2Ray, but to make data transmission faster, you can make an optimization. This optimization is optional, you can still use V2Ray normally without doing it, skip this step if you want to start using V2Ray right away.
Installing the Google BBR congestion control algorithm can speed up the V2Ray server. Google BBR is a TCP congestion control algorithm developed by Google that can be used to increase the speed of the V2Ray server. The installation process of Google BBR is originally complicated, but we can use the script of GitHub user Teddysun to install Google BBR, which only requires one line of command.
wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
After running the command, press any key to start the installation. It only takes a few seconds to complete the installation.
At this point, the installation, configuration, and optimization of V2Ray are all completed. The next step is to start V2Ray and use the client app to connect to the server.
Start V2Ray
To start V2Ray, use the following command.
systemctl start v2ray
In the future, if you made changes to the V2Ray configuration file, you need to run the following command to restart V2Ray to apply the changes.
systemctl restart v2ray
Installation and use of V2Ray client app
Let me first introduce the V2Ray client app running on mobile systems.
Android: V2RayNG, which can be downloaded from GitHub (click here to go to the download page), and can also be installed on the Google Play Store if the phone supports Google Play services (Phones sold in China don't support it).
iOS: Shadowrocket, ShadowRay, Kitsunebi, Pepi, etc. Some apps are paid apps. If you are a Chinese user, you need to use an overseas iTunes account to download these apps on the App Store, because all VPN and other proxy apps in the Chinese version App Store have been removed.
And next are the V2Ray client apps used on desktops or laptops, which can be downloaded on GitHub:
Windows system: V2RayN (After entering the download page, select "v2rayN-Core.zip" to download, unzip and open the "v2rayN.exe" inside to run the client app)
Mac system: V2RayX
Let me briefly introduce how to use V2RayNG. Open the app and tap the plus sign in the upper right corner to add a server. Select "Manual input [Vmess]" in the drop-down list, then enter the remark, you can use any name for it, and enter server IP address, Port, ID, and alterID. There is also a Security field, which is to select the encryption method, it is recommended to select "Chacha20-poly1305". After that, tap the check mark in the upper right corner to confirm, and then tap the connection button in the lower right corner to connect to the server.
The usage of client apps for other operating systems is similar. First add the server, enter the server IP address and user information, and confirm, then connect. Some client apps will automatically connect after started.
After connected, you can leave the app and let it run on its own, and then try to access those restricted websites.