|
发表于 2025-8-19 14:56:33
|
显示全部楼层
本帖最后由 haowan 于 2025-8-19 15:02 编辑
自己研究
1. 添加本地 IPv6 路由
首先为指定的 IPv6 子网添加本地路由,并允许非本地地址绑定:
ip route add local 2001:470:1f06:556::/64 dev fy
sysctl net.ipv6.ip_nonlocal_bind=1
ip route add local:为指定的 IPv6 子网添加本地路由。此命令让网络接口 fy 处理发往 2001:470:1f06:556::/64 的 IPv6 数据包。
sysctl net.ipv6.ip_nonlocal_bind=1:启用对非本地地址的绑定,允许绑定未分配给本地设备的 IPv6 地址。
2. 安装并配置 ndppd
ndppd 是一个代理,用于响应非本地地址的邻居发现协议 (NDP) 请求,确保指定的 IPv6 地址可以在局域网中响应。
安装 ndppd:
apt install ndppd
编辑配置文件:
vim /etc/ndppd.conf
配置示例:
route-ttl 30000
proxy enp1s0 {
router no
timeout 500
ttl 30000
rule 2001:470:1f06:556::/64 {
static
}
}
route-ttl 30000:设置路由缓存的生存时间 (TTL)。
proxy enp1s0:指定 enp1s0 接口代理 NDP 请求。该接口是局域网连接的接口。
rule 2001:470:1f06:556::/64:配置指定的 IPv6 前缀。static 规则表示该前缀将静态代理。
重启 ndppd 服务:
systemctl restart ndppd.service
3. x-ui 配置
x-ui 是管理代理服务器的图形界面工具,下面是配置规则的说明。
配置示例:
{
"api": {
"services": [
"HandlerService",
"LoggerService",
"StatsService"
],
"tag": "api"
},
"inbounds": [
{
"listen": "127.0.0.1",
"port": 62789,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
},
"tag": "api"
},
{
"listen": "0.0.0.0",
"port": 3333,
"protocol": "http",
"settings": {
"accounts": [
{
"user": "XXXX",
"pass": "XXXX"
}
],
"allowTransparent": false
},
"tag": "inbound-3333"
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {},
"tag": "direct"
},
{
"protocol": "freedom",
"sendThrough": "2001:470:1f06:556::/64",
"settings": {},
"tag": "randomip"
},
{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}
],
"policy": {
"levels": {
"0": {
"handshake": 10,
"connIdle": 300,
"uplinkOnly": 2,
"downlinkOnly": 3,
"statsUserUplink": true,
"statsUserDownlink": true,
"bufferSize": 10240
}
},
"system": {
"statsInboundDownlink": true,
"statsInboundUplink": true
}
},
"routing": {
"rules": [
{
"inboundTag": ["api"],
"outboundTag": "direct",
"type": "field"
},
{
"ip": ["geoip:private"],
"outboundTag": "blocked",
"type": "field"
},
{
"protocol": ["bittorrent"],
"outboundTag": "blocked",
"type": "field"
},
{
"inboundTag": ["inbound-3333"],
"outboundTag": "randomip",
"type": "field"
}
]
},
"stats": {}
}
inbounds:定义监听的入站连接。
监听 127.0.0.1:62789,用于处理 API 请求。
监听 0.0.0.0:3333,用于 HTTP 代理服务,带有基本的用户名和密码认证。
outbounds:定义出站连接。
freedom:用于直接访问互联网。
randomip:通过指定的 2001:470:1f06:556::/64 地址段访问互联网。
blackhole:拦截和丢弃不合法的流量。
routing:定义流量路由规则。
流量根据入站标签和 IP 地址决定走向。Bittorrent 流量和私人 IP 流量会被丢弃。
4. x-ui 出站规则
出站服务器设置:
[
{
"protocol": "http",
"settings": {
"servers": [
{
"address": "x.x.x.x",
"port": 3333,
"users": [
{
"user": "XXXX",
"pass": "XXXX"
}
]
},
{
"address": "x.x.x.x",
"port": 3333,
"users": [
{
"user": "XXXX",
"pass": "XXXX"
}
]
}
]
},
"tag": "random",
"strategy": {
"type": "random"
}
}
]
servers:定义出站 HTTP 代理服务器,两个不同 IP 的服务器 x.x.x.x 和 x.x.x.x,使用相同的用户名和密码。
strategy:出站策略为随机选择 (random)。
|
|