本文为历史文章,部分内容可能过期

目标:利用V2ray既能作服务端又能作客户端端特性,在斐讯N1上搭建V2ray服务,使手中的设备能够利用斐讯N1的网络上网,同时自带白名单科学上网的功能

前言

机器入手时已被刷好5.44版本的armDebian,省去部分工作,据说该机器默认优先从U盘引导,刷机难度并不大。
斐讯N1刷armDebian记录:斐讯 N1 刷 Armbian 5.64斐讯n1安装linux系统

安装V2ray

直接使用官方命令安装

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

此脚本会自动安装以下文件:

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

此脚本会配置自动运行脚本。自动运行脚本会在系统重启之后,自动运行 V2Ray。目前自动运行脚本只支持带有 Systemd 的系统,以及 Debian / Ubuntu 全系列。
运行脚本位于系统的以下位置:

  • Systemd:/etc/systemd/system/v2ray.service
  • SysV:/etc/init.d/v2ray

配置文件

首先按照想要的加密方式配置服务端,即inbounds部分,然后在outbounds部分配置按照客户端的方式写入你梯子的v2ray信息即可,这一部分可以直接从Windows端导出客户端配置,选择outbounds部分粘贴。
最后配置国内直连,将上面从Windows端导出的客户端配置的routing部分修改为以下样式即可,更多路由方式还可以自定义,以下部分摘自白话文教程,更多连接方式也可以在这里参考。

"routing": {
        "domainStrategy": "IPOnDemand",
        "rules": [
            {
                "type": "field",
                "outboundTag": "direct",
                "domain": ["geosite:cn"] // 中国大陆主流网站的域名
            },
            {
                "type": "field",
                "outboundTag": "direct",
                "ip": [
                    "geoip:cn", // 中国大陆的 IP
                    "geoip:private" // 私有地址 IP,如路由器等
                ]
            }
        ]
    }

样例参考

{
    "log": {
        "loglevel": "warning",
        "access": "/var/log/v2ray/access.log",
        "error": "/var/log/v2ray/error.log"
    },
    "inbounds": [
        {
            "port": xxxxx, // 服务器监听端口
            "protocol": "vmess",    // 主传入协议
            "settings": {
                "clients": [
                    {
                        "id": "axxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx0",  // 这里是把你的斐讯N1视作服务器的id
                        "alterId": 64
                    }
                ]
            }
        }
    ],
    "outbounds": [
        {
            "tag": "proxy",
            "protocol": "vmess",
            "settings": {
                "vnext": [
                    {
                        "address": "xxxx.xxxx.com",
                        "port": 443,
                        "users": [
                            {
                                "id": "bxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx1",//这里是你梯子的id
                                "alterId": 64,
                                "email": "t@t.tt",
                                "security": "auto"
                            }
                        ]
                    }
                ],
                "servers": null,
                "response": null
            },
            "streamSettings": {
                "network": "ws",
                "security": "tls",
                "tlsSettings": {
                    "allowInsecure": true,
                    "serverName": "xxxx.xxxx.com"
                },
                "tcpSettings": null,
                "kcpSettings": null,
                "wsSettings": {
                    "connectionReuse": true,
                    "path": "/39hope",
                    "headers": {
                        "Host": "xxxx.xxxx.com"
                    }
                },
                "httpSettings": null,
                "quicSettings": null
            },
            "mux": {
                "enabled": true
            }
        },
        {
            "tag": "direct",
            "protocol": "freedom",
            "settings": {
                "vnext": null,
                "servers": null,
                "response": null
            },
            "streamSettings": null,
            "mux": null
        },
        {
            "tag": "block",
            "protocol": "blackhole",
            "settings": {
                "vnext": null,
                "servers": null,
                "response": {
                    "type": "http"
                }
            },
            "streamSettings": null,
            "mux": null
        }
    ],
    "dns": null,
    "routing": {
        "domainStrategy": "IPOnDemand",
        "rules": [
            {
                "type": "field",
                "outboundTag": "direct",
                "domain": ["geosite:cn"] // 中国大陆主流网站的域名
            },
            {
                "type": "field",
                "outboundTag": "direct",
                "ip": [
                    "geoip:cn", // 中国大陆的 IP
                    "geoip:private" // 私有地址 IP,如路由器等
                ]
            }
        ]
    }
}

作者 Assaultcore

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注