V2Ray - ArchWiki

Jump to content

# V2Ray

From ArchWiki

V2Ray is the core tool of Project V, which is mainly responsible for the realization of network protocols and functions, and communicates with other Project V.

## Installation

Install the v2ray package.

## Configuration

V2Ray configuration is done with a JSON formatted file. See Config Reference. There are several methods of configuration, please visit V2Ray Beginner's Guide for detail.

## Usage

### From the command line

V2Ray is started with the `v2ray` command. Run `v2ray help` and `v2ray help run` to see its command line help.

### Service management

Start/enable `v2ray.service`.

## Tips and tricks

### Routing rules

See Routing of V2Ray.

The preset routing rule files are `geosite.dat` and `geoip.dat` in `/usr/share/v2ray`. They are provided by the v2ray-domain-list-community and v2ray-geoip packages respectively. These two packages are installed by default as dependencies of v2ray.

#### Replacing the preset routing rule files

There are ready-made packages for some routing rule files. For example, you can install the v2ray-rules-dat-gitAUR package for @Loyalsoldier/v2ray-rules-dat.

For routing rule files without ready-made packages, you can create packages and install or remove v2ray-domain-list-community and v2ray-geoip without removing the dependent package and put the routing rule files in the `/usr/share/v2ray` directory.

Warning Replacing `geosite.dat` and `geoip.dat` directly may cause file conflicts.

### Multiple configs

With multiple configs, it's convenient to achieve things like dropping new inbounds to the config directory without having to touch the master config.

#### Rules of multiple configs

- For top-level objects, objects in the latter config file override or supplement the former.
- Inbounds and outbounds are array structures, they have special rules:
  - If arrays in the latter config file have 2 or more elements, arrays in the latter config file overwrite the former config file.
  - If arrays in the latter config file have only 1 element, overwrite the original element with the same tag; if the element cannot be found:
    - For inbounds, add them to the end.
    - For outbounds, add them to the front; if the name of config file contains `tail`, add the outbounds to the end.

#### Enable multiple configs with systemd

To enable multiple configs with systemd, you can create the following drop-in file:

    /etc/systemd/system/v2ray.service.d/multi_config.conf

    ExecStart=
    ExecStart=/usr/bin/v2ray run -confdir /absolute/path/to/dir/

## Troubleshooting

### Failed with result 'exit-code'

If you see this error in the log: `Failed with result 'exit-code'`, it is because V2Ray does not have write permission to /var/log/v2ray/access.log. Use the following command to solve the problem.

    chown -R nobody /var/log/v2ray

## See also

- V2Fly offical Website & Documentation
- V2Ray Beginner's Guide
- Qv2ray official Website & Documentation

Category:

- Proxy servers

V2Ray
Add topic