夜微的后院
[纯记录]
2020-10-31

https://www.rultr.com/tutorials/proxy/2268.html

apt-get install unzip //Debian、Ubuntu系统

yum install unzip //RHEL/CentOS系统

bash <(curl -L -s https://install.direct/go.sh)

/usr/bin/v2ray/v2ray:V2Ray 程序;
/usr/bin/v2ray/v2ctl:V2Ray 工具;
/etc/v2ray/config.json:配置文件;
/usr/bin/v2ray/geoip.dat:IP 数据文件
/usr/bin/v2ray/geosite.dat:域名数据文件

service v2ray status

同时,V2Ray也支持Shadowsocks协议,把V2Ray软件当做Shadowsocks服务器来使用。完成此功能,需要在配置文件中增加”inboundDetour”配置块,使其支持另一种入流量:
"inboundDetour": [
{

 "protocol": "shadowsocks",
 "port": 10087,
 "settings": {
  "method": "aes-256-cfb",
  "password": "www.rultr.com",
  "udp": false
 }
}

],
“inboundDetour” 的字面意思就很有意思,就是指入流量的另一条道路。配置文件中”protocol”指入流量使用的协议,直接写 “shadowsocks”就是了;”port”是指使用”shadowsocks”协议侦听的端口,注意要和”vmess”协议端口有区别;”settings”部分是使用”shadowsocks”协议时的主要配置项,不做设置的话,”shadowsocks”协议将不能正常工作。一般只需要设置其中的”password”部分,由用户自行设定,用于客户端的连接。

这样设置完成后,V2Ray就可以同时作为V2Ray和Shadowsocks的服务器,响应不同客户端的连接,是不是很方便呢。如果不确信的话,可以用 netstat -tnlp 命令查看一下10086端口和10087端口是不是都显示为侦听状态。

以下是V2Ray作为服务器端的全部配置内容,这里提供给大家参考:

{
"log" : {

"access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log",
"loglevel": "warning"

},
"inbound": {

"port": 10086,
"protocol": "vmess",
"settings": {
  "clients": [
    {
      "id": "b831381d-6324-4d53-ad4f-8cda48b30811",
      "level": 1,
      "alterId": 64
    }
  ]
}

},
"inboundDetour": [
{

 "protocol": "shadowsocks",
 "port": 10087,
 "settings": {
  "method": "aes-256-cfb",
  "password": "www.rultr.com",
  "udp": false
 }
}

],
"outbound": {

"protocol": "freedom",
"settings": {}

},
"outboundDetour": [

{
  "protocol": "blackhole",
  "settings": {},
  "tag": "blocked"
}

],
"routing": {

"strategy": "rules",
"settings": {
  "rules": [
    {
      "type": "field",
      "ip": [
        "0.0.0.0/8",
        "10.0.0.0/8",
        "100.64.0.0/10",
        "127.0.0.0/8",
        "169.254.0.0/16",
        "172.16.0.0/12",
        "192.0.0.0/24",
        "192.0.2.0/24",
        "192.168.0.0/16",
        "198.18.0.0/15",
        "198.51.100.0/24",
        "203.0.113.0/24",
        "::1/128",
        "fc00::/7",
        "fe80::/10"
      ],
      "outboundTag": "blocked"
    }
  ]
}

}
}