[GH-ISSUE #6097] [Bug]: Regarding the issue of client IP restrictions #4213

Closed
opened 2026-10-31 20:38:01 +07:00 by bsakaguchi · 5 comments
Owner

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

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
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 ```shell ``` ### 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 - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:38:01 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@MHSanaei commented on GitHub (Jul 25, 2026):

@claude

<!-- gh-comment-id:5080309471 --> @MHSanaei commented on GitHub (Jul 25, 2026): @claude
Author
Owner

@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 limitIp to 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

  1. internal/web/job/check_client_ip_job.go runs every 10s. It asks Xray's online-stats API for live users and builds email -> ip -> lastSeen (collectFromOnlineAPI, line 88).
  2. The limit is read per email from the clients table (loadClientLimits, line 145) and applied per email: selectIpsToBan(liveIps, limitIp) (line 513) keeps the newest limitIp live IPs of that one client and marks the older ones for banning. A client with limitIp = 0 is skipped entirely (line 483).
  3. For each over-limit IP it writes one line to /var/log/x-ui/3xipl.log (line 533):
    [LIMIT_IP] Email = <email> || Disconnecting OLD IP = <ip> || Timestamp = <ts>
    
  4. fail2ban's 3x-ipl jail reads that log and bans the IP. The action written by create_iplimit_jails in x-ui.sh (lines 2546-2547) is:
    actionban = <iptables> -I f2b-<name> 1 -s <ip> -p tcp -m multiport ! --dports <exemptports> -j <blocktype>
                <iptables> -I f2b-<name> 1 -s <ip> -p udp -m multiport ! --dports <exemptports> -j <blocktype>
    
    This is an INPUT-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). Default bantime is 30 minutes (line 2490).
  5. The panel also does a per-client RemoveUser + AddUser through 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

  • They share a public IP. Two devices on the same home/office LAN, or on the same mobile carrier CGNAT pool, present one address to the server. When client A's old IP is banned, client B behind that same address loses every port too.
  • The inbound sits behind a CDN or relay without real-IP recovery. Then Xray records the intermediary's address for every client, not the visitor's. A client with limitIp = 1 rotating across edge nodes gets those edge IPs banned, and every other client routed through the same edges dies with it. This is documented in docs/real-client-ip.md — fix it by setting Transport / Stream Settings → Sockopt → Real client IP (trustedXForwardedFor: ["CF-Connecting-IP"] for the Cloudflare CDN, or acceptProxyProtocol for an L4 relay/Spectrum).
  • Several devices use the same client config. IPs are counted per email, so every device sharing one UUID/email counts against that single 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

cat /var/log/x-ui/3xipl-banned.log
fail2ban-client status 3x-ipl
iptables -L f2b-3x-ipl -n
ip6tables -L f2b-3x-ipl -n
tail -n 50 /var/log/x-ui/3xipl.log

3xipl.log names 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

  • Unban: x-ui menu → 22. IP Limit Management → 6. Unban an IP Address, or 3. Unban Everyone. Equivalent CLI:
    fail2ban-client set 3x-ipl unbanip <ip>
    
  • Set the client's IP limit back to 0 to disable enforcement for it.
  • Shorten the ban window with menu option 2. Change Ban Duration.
  • A per-IP whitelist for the jail is not implemented; #5378 is the open request for it. Adding ignoreip by hand to /etc/fail2ban/jail.d/3x-ipl.conf works, but create_iplimit_jails rewrites 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_FAIL2BAN is not set to something other than true (resolveEnforce, line 77, and isFail2BanEnabled, line 453) — the panel disables the field in the client form otherwise.

If after checking 3xipl-banned.log you find that the banned IP does not belong to any device of the limited client, that would be a genuine bug; please post the relevant 3xipl.log and 3xipl-banned.log lines (IPs redacted as needed) plus the inbound's transport settings, and it can be traced further.

<!-- gh-comment-id:5080310322 --> @github-actions[bot] commented on GitHub (Jul 25, 2026): **Claude finished @MHSanaei's task in 3m 58s** —— [View job](https://github.com/MHSanaei/3x-ui/actions/runs/30172248268) --- ### 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 `limitIp` to 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 1. `internal/web/job/check_client_ip_job.go` runs every 10s. It asks Xray's online-stats API for live users and builds `email -> ip -> lastSeen` (`collectFromOnlineAPI`, line 88). 2. The limit is read per email from the `clients` table (`loadClientLimits`, line 145) and applied per email: `selectIpsToBan(liveIps, limitIp)` (line 513) keeps the newest `limitIp` live IPs of **that one client** and marks the older ones for banning. A client with `limitIp = 0` is skipped entirely (line 483). 3. For each over-limit IP it writes one line to `/var/log/x-ui/3xipl.log` (line 533): ``` [LIMIT_IP] Email = <email> || Disconnecting OLD IP = <ip> || Timestamp = <ts> ``` 4. fail2ban's `3x-ipl` jail reads that log and bans the IP. The action written by `create_iplimit_jails` in `x-ui.sh` (lines 2546-2547) is: ``` actionban = <iptables> -I f2b-<name> 1 -s <ip> -p tcp -m multiport ! --dports <exemptports> -j <blocktype> <iptables> -I f2b-<name> 1 -s <ip> -p udp -m multiport ! --dports <exemptports> -j <blocktype> ``` This is an `INPUT`-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). Default `bantime` is 30 minutes (line 2490). 5. The panel also does a per-client `RemoveUser` + `AddUser` through 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 - **They share a public IP.** Two devices on the same home/office LAN, or on the same mobile carrier CGNAT pool, present one address to the server. When client A's old IP is banned, client B behind that same address loses every port too. - **The inbound sits behind a CDN or relay without real-IP recovery.** Then Xray records the intermediary's address for every client, not the visitor's. A client with `limitIp = 1` rotating across edge nodes gets those edge IPs banned, and every other client routed through the same edges dies with it. This is documented in `docs/real-client-ip.md` — fix it by setting **Transport / Stream Settings → Sockopt → Real client IP** (`trustedXForwardedFor: ["CF-Connecting-IP"]` for the Cloudflare CDN, or `acceptProxyProtocol` for an L4 relay/Spectrum). - **Several devices use the same client config.** IPs are counted per email, so every device sharing one UUID/email counts against that single `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 ```bash cat /var/log/x-ui/3xipl-banned.log fail2ban-client status 3x-ipl iptables -L f2b-3x-ipl -n ip6tables -L f2b-3x-ipl -n tail -n 50 /var/log/x-ui/3xipl.log ``` `3xipl.log` names 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 - Unban: `x-ui` menu → **22. IP Limit Management** → **6. Unban an IP Address**, or **3. Unban Everyone**. Equivalent CLI: ```bash fail2ban-client set 3x-ipl unbanip <ip> ``` - Set the client's IP limit back to `0` to disable enforcement for it. - Shorten the ban window with menu option **2. Change Ban Duration**. - A per-IP whitelist for the jail is not implemented; #5378 is the open request for it. Adding `ignoreip` by hand to `/etc/fail2ban/jail.d/3x-ipl.conf` works, but `create_iplimit_jails` rewrites 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_FAIL2BAN` is not set to something other than `true` (`resolveEnforce`, line 77, and `isFail2BanEnabled`, line 453) — the panel disables the field in the client form otherwise. If after checking `3xipl-banned.log` you find that the banned IP does **not** belong to any device of the limited client, that would be a genuine bug; please post the relevant `3xipl.log` and `3xipl-banned.log` lines (IPs redacted as needed) plus the inbound's transport settings, and it can be traced further.
Author
Owner

@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?

<!-- gh-comment-id:5083073629 --> @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?
Author
Owner

@AndreyKaller commented on GitHub (Jul 26, 2026):

А почему не ввести проверку по HWID как это делают в других панелях ? Ведь например Happ имеет настройку передачи HWID на панель управления.

<!-- gh-comment-id:5084527596 --> @AndreyKaller commented on GitHub (Jul 26, 2026): А почему не ввести проверку по HWID как это делают в других панелях ? Ведь например Happ имеет настройку передачи HWID на панель управления.
Author
Owner

@MHSanaei commented on GitHub (Jul 27, 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?

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 limitIp to 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's 3x-ipl jail 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 = 1 that 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:

  • Set limitIp = 0 for clients whose users share a network, or raise it to cover the real device count.
  • Unban now: x-ui menu → 22. IP Limit Management → 3. Unban Everyone, or fail2ban-client set 3x-ipl unbanip <ip>.
  • Shorten the window with menu option 2. Change Ban Duration.
  • Check what was actually banned: cat /var/log/x-ui/3xipl-banned.log and tail -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.log that 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.

<!-- gh-comment-id:5091414821 --> @MHSanaei commented on GitHub (Jul 27, 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? 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 `limitIp` to 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's `3x-ipl` jail 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 = 1` that 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: - Set `limitIp = 0` for clients whose users share a network, or raise it to cover the real device count. - Unban now: `x-ui` menu → **22. IP Limit Management** → **3. Unban Everyone**, or `fail2ban-client set 3x-ipl unbanip <ip>`. - Shorten the window with menu option **2. Change Ban Duration**. - Check what was actually banned: `cat /var/log/x-ui/3xipl-banned.log` and `tail -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.log` that 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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4213
No description provided.