xray配置 设置只允许访问1111
要设置只允许访问1.1.1.1,可以按照以下步骤进行操作:
-
打开xray的配置文件,通常为config.json。
-
找到inbounds部分的配置,如果没有则添加一个,例如:
{
"inbounds": [
{
"port": 1080,
"listen": "127.0.0.1",
"protocol": "socks",
"settings": {}
}
]
}
- 在该配置中添加一个rules的数组,用于设置访问规则,例如:
{
"inbounds": [
{
"port": 1080,
"listen": "127.0.0.1",
"protocol": "socks",
"settings": {},
"rules": [
{
"type": "field",
"outboundTag": "blocked",
"ip": ["0.0.0.0/0"],
"notIp": ["1.1.1.1/32"]
}
]
}
],
"outbounds": [
{
"protocol": "freedom"
},
{
"protocol": "blackhole",
"tag": "blocked"
}
]
}
-
在rules数组中添加一个type为field的规则,用于匹配IP地址。
-
在该规则中,使用ip和notIp字段分别设置允许和禁止访问的IP地址,例如上面的配置中只允许访问1.1.1.1。
-
配置完成后保存文件并重新启动xray即可生效
原文地址: https://www.cveoy.top/t/topic/fUwT 著作权归作者所有。请勿转载和采集!