xray配置多个IPV6代理

本文最后更新于:2026年7月24日 晚上

Xray

/etc/NetworkManager/system-connections/ens3.nmconnection

1
2
3
4
5
6
7
8
9
10
11
12
13
[ipv6]
method=manual
address1=2607:f130::1/64
address2=2607:f130::2/64
address3=2607:f130::3/64
address4=2607:f130::4/64
address5=2607:f130::5/64
address6=2607:f130::6/64
address7=2607:f130::7/64
address8=2607:f130::8/64
address9=2607:f130::9/64
address10=2607:f130::10/64

重新加载NetworkManager配置并重启网络接口

1
2
sudo nmcli c reload
sudo nmcli c up ens33

验证IPv6地址配置

1
ip -6 addr show ens33

生成配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import subprocess

data = """[[inbounds]]
port = {port}
protocol = "socks"
tag = "tag_{port}"
[inbounds.settings]
auth = "password"
udp = true
ip = "{ip}"
[[inbounds.settings.accounts]]
user = "{user}"
pass = "{password}"
[[outbounds]]
sendThrough = "{ip}"
protocol = "freedom"
tag = "tag_{port}"

[[routing.rules]]
type = "field"
inboundTag = "tag_{port}"
outboundTag = "tag_{port}"

"""


def get_all_local_ips():
"""

:return:
"""
ips = []
try:
# Unix systems
ip_config = subprocess.check_output(['ifconfig'], encoding='utf-8')
for line in ip_config.split('\n'):
if 'inet ' in line or 'inet6 ' in line:
parts = line.split()
ip = parts[1]
if ip != '127.0.0.1' or ip != '::1':
ips.append(ip)

except Exception as e:
print(e)
return ips


def main(start, stop):
content = ''
ips = get_all_local_ips()

ports = list(range(start, stop))
infos = list(zip(ips, ports))
print(infos)

for ip, port in infos:
d = dict()
d['ip'] = ip
d['user'] = 'userb'
d['password'] = 'passwordb'
d['port'] = port
text = data.format(**d)
content += text + '\n'

with open('xray_config.toml', 'w') as f:
f.write(content)


if __name__ == '__main__':
main(2000, 5000)

测试代理

1
curl -6 -x "socks5://userb:passwordb@74.48.18.240:20000" ip.sb

xray配置多个IPV6代理
https://kingjem.github.io/2026/07/24/xray配置多个IPV6代理/
作者
Ruhai
发布于
2026年7月24日
许可协议