How To Install V2ray On Amazon EC2 And Google Cloud Ubuntu Linux

V2ray is similar but better than ShadowSocks. This article will tell you how to install v2ray server on ubuntu linux. It also tell you how to use v2ray client to access the v2ray server. Before start you should know that v2ray has strict requirements on time. It is required that the absolute value of the time difference between the server and the client cannot exceed 2 minutes, so you must ensure that the time is accurate enough. Fortunately, v2ray does not require consistent time zones on server and client.

1. Update Linux Server Date Time.

  1. Get linux server current date time.
    $ date
    Thu Feb 27 11:48:59 UTC 2020
  2. Change linux date time and time zone.
    date --set="Fri Jun 28 15:05:15 CST 2020"
    

2. Install V2ray On Ubuntu Linux Server.

  1. First you should install unzip manually. Otherwise the v2ray installation will fail.

    $ sudo apt install unzip
  2. Change to root user.
    $ sudo su
    
    [email protected]:/home/ubuntu#
  3. Install v2ray on linux server.
    # bash <(curl -L -s https://install.direct/go.sh)
    Installing V2Ray v4.22.1 on x86_64
    Downloading V2Ray: https://github.com/v2ray/v2ray-core/releases/download/v4.22.1/v2ray-linux-64.zip
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   608  100   608    0     0   2068      0 --:--:-- --:--:-- --:--:--  2068
    100 11.6M  100 11.6M    0     0  3171k      0  0:00:03  0:00:03 --:--:-- 3619k
    Archive:  /tmp/v2ray/v2ray.zip
      inflating: /usr/bin/v2ray/geoip.dat  
      inflating: /usr/bin/v2ray/geosite.dat  
      inflating: /usr/bin/v2ray/v2ctl    
      inflating: /usr/bin/v2ray/v2ray    
    PORT:28922
    UUID:f8fa304d-2c38-4941-ad6e-442a925d74d5
    Archive:  /tmp/v2ray/v2ray.zip
      inflating: /etc/systemd/system/v2ray.service  
    Created symlink /etc/systemd/system/multi-user.target.wants/v2ray.service → /etc/systemd/system/v2ray.service.
    V2Ray v4.22.1 is installed.
    
  4. Use vim to edit v2ray configuration file. The file path is /etc/v2ray/config.json.
    # vim /etc/v2ray/config.json
  5. Go to https://www.uuidgenerator.net to generate a new unique id and replace it in above config.json file inbounds —> settings —> clients —> id value. The port number is also decided by yourself. For more configuration settings, please read article V2ray Configuration Overview.
    {
      "inbounds": [{
        "port": 10086,
        "protocol": "vmess",
        "settings": {
          "clients": [
            {
              "id": "10fdwe3c8-uyer3-df343-t256-df89f7df8",
              "level": 1,
              "alterId": 64
            }
          ]
        }
      }],
      "outbounds": [{
        "protocol": "freedom",
        "settings": {}
      },{
        "protocol": "blackhole",
        "settings": {},
        "tag": "blocked"
      }],
      "routing": {
        "rules": [
          {
            "type": "field",
            "ip": ["geoip:private"],
            "outboundTag": "blocked"
          }
        ]
      }
    }
  6. Enable v2ray auto start when os start.
    # systemctl enable v2ray
  7. Run command systemctl start v2ray to start v2ray service.
    systemctl start | stop | restart v2ray

3. Install And Configure V2ray Client.

You can go to the official v2ray client download page to get the v2ray client which match your needs. I use MacOS, so i just installed V2RayX. Below is the steps about how to use V2RayX.

  1. Download, install and start V2RayX.
  2. Click V2RayX icon at Mac top menu bar, then click Configure… menu item.
    v2rayx configure menu
  3. Input v2ray server ip address ( or domain name ), listen port number, User ID in the red line input box, input a name in the Tag input box, click OK button to save it. Do not need to modify other fields.
    v2rayx configure dialog
  4. Now this newly added v2ray server will be shown in V2RayX —> Server list, check it.
  5. Check the V2RayX —> Global Mode menu item.
  6. You can add multiple v2ray server, if you do not want to use it, you can click V2RayX —> Unload core. If you want to use it again, you can first select it in V2RayX —> Server list, then click V2RayX —> Load core menu.
  7. For more v2ray configuration, please go to V2ray Configuration Overview. Client and server use same configuration file. But client’s inbounds settings should map to server outbounds settings vice versa.
READ :   How To Install Ubuntu On Virtualbox Mac

4. Add V2ray Server Port Number In Amazon Or Google Cloud Firewall.

If you use amazon aws or google cloud linux VPS server, generally, your v2ray server port number should be blocked by amazon or google cloud firewall by default. So you should add the port number in amazon aws or google cloud firewall to allow it.

4.1 Amazon AWS.

Please refer section 5. Edit EC2 Linux Instance Used Security Group. in article How To Install ShadowSocks Server On Amazon EC2 Linux

4.2 Google Cloud.

Please refer section 1. Create A Firewall Rule In Google Cloud. in article How To Install ShadowSocks On Google Cloud Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.