1、下载安装包
- 从 https://github.com/v2ray/v2ray-core/releases/tag/v4.28.2 下载 v2ray-linux-64.zip 文件并解压
- (实际上选择合适自己机器的就行了 这里选用的是最小包 解压即用)
- 可从本站点下载适用于Linux-64位的压缩包 下载

2、配置config.json文件
- 因为我们的v2ray此时是用来作为客户端工作 所以需要配置节点
- 节点的配置文件为 config.json
- 节点文件可以从v2ray的Windows客户端导出

- 前提是我们在Windows客户端使用的v2ray已经有服务器节点可用;则此操作就是更便捷的为Linux下的v2ray客户端配置服务器节点
- 检查配置文件 成功效果如下
[root@VM-8-11-centos v2]# v2ray -test -config config.json
V2Ray 4.44.0 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.17.3 linux/amd64)
A unified platform for anti-censorship.
2022/02/23 22:23:52 [Info] main/jsonem: Reading config: config.json
Configuration OK.
[root@VM-8-11-centos v2]#
3、运行
- 在 Windows 和 macOS 中,配置文件通常是 V2Ray 同目录下的 config.json 文件 。直接运行 v2ray 或 v2ray.exe 即可
- 在 Linux 中,配置文件通常位于 /etc/v2ray/config.json 文件(非压缩包安装)。运行 v2ray –config=/etc/v2ray/config.json,或使用 systemd 等工具把 V2Ray 作为服务在后台运行
4、测试
- curl –socks5 127.0.0.1:10808 https://www.google.com #注意是两个-
- 其中的 10808 端口为我们配置文件中配置的端口 每个人的可能都不相同
5、配置curl、wget等命令使用代理
方法一(推荐)
- 修改文件“/etc/profile”,在文件结束位置增加如下内容:
# 设置http代理
export http_proxy=socks5://127.0.0.1:10808
# 设置https代理
export https_proxy=socks5://127.0.0.1:10808
# 设置ftp代理
export ftp_proxy=socks5://127.0.0.1:10808
# 17.16.x.x为我们自己的云服务器的内网IP 配置为no_proxy代表内网传输不走代理
export no_proxy="172.16.x.x"
- 修改后重启服务器 上面的设置才会生效
- 或者不重启服务器 执行以下命令 使配置立即生效
source /etc/profile
方法二(在当前终端临时生效)
- 使代理生效
export http_proxy=socks5://127.0.0.1:10808
export https_proxy=socks5://127.0.0.1:10808
export ftp_proxy=socks5://127.0.0.1:10808
export no_proxy="172.16.x.x"
- 使代理失效
unset http_proxy
unset https_proxy
unset ftp_proxy
unset no_proxy
方法三(针对单用户生效)
- 编辑文件 vim ~/.bashrc 添加以下内容
# set proxy
function setproxy() {
export http_proxy=socks5://127.0.0.1:10808
export https_proxy=socks5://127.0.0.1:10808
export ftp_proxy=socks5://127.0.0.1:10808
export no_proxy="172.16.x.x"
}
# unset proxy
function unsetproxy() {
unset http_proxy https_proxy ftp_proxy no_proxy
}
- 保存退出
- 执行 source ~/.bashrc ,使得配置立即生效;
- 或是关闭当前终端,重新打开,使得配置立即生效;
- 在终端执行 setproxy 使代理生效
- 在终端执行 unsetproxy 使代理生效
原创文章,作者:witersen,如若转载,请注明出处:https://www.witersen.com
评论列表(3条)
[…] https://www.witersen.com/?p=1408 […]
[…] linux下配置V2ray作为客户端来访问GitHub、G*le等服务 […]
怎么运行V2ray客户端呀?
[root@iZ2ze0adjult3m3h0zfmg4Z v2ray]# systemctl enable v2ray
Failed to execute operation: No such file or directory