-
安装v2rayN:
- 打开终端,执行命令:
pip install v2rayN
- 完成安装后,检查版本:
v2rayN --version
- 打开终端,执行命令:
-
创建配置文件:
- 打开编辑器,新建或编辑
config.json文件。 - 添加以下内容:
{ "domain": "yourdomain.com", "port": 808, "encryption": "AE", "protocol": "SOCK5", "listen": "...", "lport": 808, "socks": "SOCKS", "socks_remote": "127...1:108", "http": 8281, "https": 8443, "udp": true, "inbound": true, "outbound": true, "dns": "8.8.8.8", "dns_over námeldung": true, "snì": "localhost", "snì_port": 54321, "user": "username", "pass": "password", "socks": "SOCKS", "socks_remote": "127...1:108", "http": 8281, "https": 8443, "udp": true, "inbound": true, "outbound": true, "dns": "8.8.8.8", "dns_over námeldung": true, "snì": "localhost", "snì_port": 54321, "user": "username", "pass": "password", "socks": "SOCKS", "socks_remote": "127...1:108", "http": 8281, "https": 8443, "udp": true, "inbound": true, "outbound": true, "dns": "8.8.8.8", "dns_over námeldung": true, "snì": "localhost", "snì_port": 54321, "user": "username", "pass": "password", "socks": "SOCKS", "socks_remote": "127...1:108", "http": 8281, "https": 8443, "udp": true, "inbound": true, "outbound": true, "dns": "8.8.8.8", "dns_over námeldung": true, "snì": "localhost", "snì_port": 54321, "user": "username", "pass": "password" } - 确保JSON格式正确,避免语法错误。
- 打开编辑器,新建或编辑
-
启动v2rayN:
- 在终端执行:
v2rayN -c config.json
- 该命令将启动v2rayN,代理已准备就绪。
- 在终端执行:
-
检查端口:
- 确保系统开放以下端口:
sudo iptables -L -n
- 打开所需的端口,
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT sudo iptables -A INPUT -p tcp --dport 808 -j ACCEPT sudo iptables -A INPUT -p tcp --dport 8443 -j ACCEPT
- 应用更改:
sudo service iptables save sudo service iptables restart
- 确保系统开放以下端口:
-
测试代理:
- 使用浏览器访问
http://yourdomain.com,确认是否能正常加载。 - 运行命令:
curl -I http://yourdomain.com:808
- 期望返回状态码200 OK。
- 使用浏览器访问
-
设置DNS过滤(可选):
- 在
config.json中添加dns_filters:"dns_filters": ["*.example.com"],
- 这将阻止访问特定域名的网站。
- 在
-
自动启动(可选):
-
创建启动脚本,保存为
v2rayN.service:[unit] Description=v2rayN Service After=network.target [service] ExecStart=/usr/bin/v2rayN -c /path/to/config.json Restart=always [install] WantedBy=multi-user.target
-
保存后,执行:
sudo mv v2rayN.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable v2rayN.service
-
启动服务:
sudo systemctl start v2rayN.service
-
完成以上步骤后,v2rayN 应该已成功配置并运行,确保网络连接正常,如遇到问题,检查日志或参考v2rayN的文档获取帮助。









