mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6097] [Bug]: Regarding the issue of client IP restrictions #4213
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4213
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @a671271260 on GitHub (Jul 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6097
Describe the bug
Client IP restriction, set to 1,Will it affect inbound traffic?
I set up a single client, and other clients with the same inbound settings cannot connect either.
How to reproduce the problem
1.Open the client
2.Set the IP limit to 1
Other clients with the same inbound will also be affected
Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.5.0
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
Ub22
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
No response
Before submitting
@MHSanaei commented on GitHub (Jul 25, 2026):
@claude
@github-actions[bot] commented on GitHub (Jul 25, 2026):
Claude finished @MHSanaei's task in 3m 58s —— View job
IP limit is per-client, but the ban it produces is per source IP and host-wide
Nothing in the code applies one client's
limitIpto another client. The limit is evaluated per email, but enforcement is a fail2ban firewall ban on the offending IP address, which drops that IP for every port on the server (except SSH and the panel port). So other clients stop working exactly when they are connecting from the same source IP that got banned.What the code actually does
internal/web/job/check_client_ip_job.goruns every 10s. It asks Xray's online-stats API for live users and buildsemail -> ip -> lastSeen(collectFromOnlineAPI, line 88).clientstable (loadClientLimits, line 145) and applied per email:selectIpsToBan(liveIps, limitIp)(line 513) keeps the newestlimitIplive IPs of that one client and marks the older ones for banning. A client withlimitIp = 0is skipped entirely (line 483)./var/log/x-ui/3xipl.log(line 533):3x-ipljail reads that log and bans the IP. The action written bycreate_iplimit_jailsinx-ui.sh(lines 2546-2547) is: This is anINPUT-chain drop of all TCP and UDP ports from that source address, with only the SSH port(s) and the panel port exempt (exemptports, line 2557). Defaultbantimeis 30 minutes (line 2490).RemoveUser+AddUserthrough the Xray API (disconnectClientTemporarily, line 588). That one is strictly scoped to the offending email and the inbound tag, so it cannot affect other clients.Step 4 is the part that produces the symptom you describe: fail2ban has no notion of clients or inbounds, only of IP addresses.
The three cases where other clients go down
limitIp = 1rotating across edge nodes gets those edge IPs banned, and every other client routed through the same edges dies with it. This is documented indocs/real-client-ip.md— fix it by setting Transport / Stream Settings → Sockopt → Real client IP (trustedXForwardedFor: ["CF-Connecting-IP"]for the Cloudflare CDN, oracceptProxyProtocolfor an L4 relay/Spectrum).limitIp. With a limit of 1, the older device's IP is banned host-wide, and anything else behind that IP goes with it.How to tell which one you have
3xipl.lognames the email that triggered each ban and the IP that was banned. Compare that IP against the public IP of the clients that stopped working. If it matches, this is the expected behavior of an IP-level ban, not a per-inbound bug. If the banned IP belongs to a CDN or relay, it is the second case above.Recovering and configuring
x-uimenu → 22. IP Limit Management → 6. Unban an IP Address, or 3. Unban Everyone. Equivalent CLI:0to disable enforcement for it.ignoreipby hand to/etc/fail2ban/jail.d/3x-ipl.confworks, butcreate_iplimit_jailsrewrites that file whenever you change the ban duration or reinstall, so the entry is lost.Note also that the limit is only enforced when fail2ban is installed and
XUI_ENABLE_FAIL2BANis not set to something other thantrue(resolveEnforce, line 77, andisFail2BanEnabled, line 453) — the panel disables the field in the client form otherwise.If after checking
3xipl-banned.logyou find that the banned IP does not belong to any device of the limited client, that would be a genuine bug; please post the relevant3xipl.logand3xipl-banned.loglines (IPs redacted as needed) plus the inbound's transport settings, and it can be traced further.@a671271260 commented on GitHub (Jul 26, 2026):
Assuming the client IP limit is set to 1, but there are multiple clients, all connected through my WiFi LAN, this would trigger the client rule with IP restrictions, thereby preventing other WiFi users from normally accessing other clients. Is this what it means?
@AndreyKaller commented on GitHub (Jul 26, 2026):
А почему не ввести проверку по HWID как это делают в других панелях ? Ведь например Happ имеет настройку передачи HWID на панель управления.
@MHSanaei commented on GitHub (Jul 27, 2026):
Yes — that is exactly it, and it is expected behaviour rather than a bug, so I am closing this. Nothing in the code applies one client's
limitIpto another client; the limit is evaluated strictly per email. What is not per-client is the enforcement.When a client exceeds its limit, the panel writes the offending IP to
/var/log/x-ui/3xipl.log, and fail2ban's3x-ipljail bans that IP address at the firewall — all TCP and UDP ports, with only SSH and the panel port exempt. fail2ban has no notion of clients or inbounds, only addresses. So every device sharing that public IP loses access, whichever client config it was using.Everyone on one WiFi LAN presents a single public address to the server, so with
limitIp = 1that is precisely what happens: the second device's connection pushes the first device's IP over the limit, that address is banned, and the whole LAN goes down for 30 minutes (the default ban duration).What to do:
limitIp = 0for clients whose users share a network, or raise it to cover the real device count.x-uimenu → 22. IP Limit Management → 3. Unban Everyone, orfail2ban-client set 3x-ipl unbanip <ip>.cat /var/log/x-ui/3xipl-banned.logandtail -n 50 /var/log/x-ui/3xipl.log— the latter names the email that triggered each ban.One thing worth ruling out separately: if your inbound is behind a CDN or a relay without real-IP recovery, Xray records the intermediary's address for every client, which produces the same symptom for a different reason and is fixable. See
docs/real-client-ip.md(Transport → Sockopt → Real client IP).@AndreyKaller on HWID — that is a reasonable idea but a separate feature request rather than part of this bug, and it depends on the client app sending it (only some do). Please open a feature request for it so it can be tracked on its own.
If you find a banned IP in
3xipl-banned.logthat does not belong to any device of the limited client, that would be a real bug — please reopen with those log lines and the inbound's transport settings.