mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6569] [Bug]: EL7 - fail2ban setup pulls in firewalld and blocks all panel/inbound ports after reboot #4404
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#4404
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 @Drswith on GitHub (Sep 16, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6569
Describe the bug
On RHEL/CentOS 7 (EL7), the automatic Fail2ban setup that runs during install/upgrade
silently pulls in
firewalldas a transitive dependency and leaves the unitenabled.
firewalldis not started by the package transaction, so nothing appears to break atthat moment — the panel keeps working normally. But on the next reboot it starts with
its default
publiczone, which only allowssshanddhcpv6-client. Every 3x-ui portis then rejected by the host firewall:
44328)2096)Clients get
Connection refused(the firewall rejects withicmp-host-prohibited),which looks exactly like "the panel died" even though
x-uiis running and listeningcorrectly on all ports.
This is especially confusing to diagnose because the operator never configured a
firewall in the first place: on EL7 the dependency is pulled in silently, by a package
transaction that the 3x-ui script triggers on their behalf.
How to reproduce the problem
firewalldis not installed. Manyminimal/VPS images remove it at provisioning time, so verify first:
rpm -q firewalld→package firewalld is not installed.prints
Setting up Fail2ban for the IP Limit feature...and then executes:yum makecache -y && yum install epel-release -yyum -y install fail2ban nftablesreachable — nothing looks wrong.
reboot).(
curl: (7) Failed to connect ... Connection refused), while SSH on port 22 stillworks.
firewall-cmd --list-all→services: dhcpv6-client ssh,ports:emptyiptables -L INPUT -n -v→ finalREJECT ... reject-with icmp-host-prohibitedExpected behavior
Installing or upgrading 3x-ui should not leave the host in a state where a firewall the
operator never asked for blocks the panel and all inbounds on the next boot.
If
firewalldreally has to be installed on EL7 as a side effect offail2ban, theinstaller should either leave it disabled (the
3x-ipljail does not need it), or openthe ports 3x-ui relies on, or at minimum warn loudly that a firewall was just enabled.
Actual behavior
firewalldis installed and enabled as a side effect of the fail2ban dependency chain,with an empty
publiczone. After the next reboot it rejects all traffic except SSH,taking the panel, the subscription service, and every inbound offline — with no
indication in the 3x-ui output that anything firewall-related was installed.
Relevant logs
The yum transaction triggered by the installer (note
firewalldarriving as aDep-Install, not as a user-requested package):firewalldis the only reverse dependency on EL7, so there is no way to installfail2banthere without it:The resulting zone / ruleset (empty
ports:is the whole problem):firewalldwas enabled at install time but only started at the reboot — the firewalllog contains a single line, timestamped at boot, not at package-install time:
Meanwhile the panel and Xray are up and listening — only the firewall is blocking them:
3x-ui version
3.8.5
Xray-core version
26.9.9
How did you install 3x-ui?
install.sh script
Operating system
CentOS 7.9 (EL7), kernel 5.4.x, KVM VPS. The image had
firewalldremoved atprovisioning time (
yum historyshows an-y remove firewalld linux-firmwaretransaction), so the host had no firewall at all before the upgrade.
Which parts of the panel are affected?
Install / upgrade script
Is the panel behind a reverse proxy or CDN?
No — direct access
Before submitting
Additional context
Root cause.
x-ui.sh→setup_fail2ban_iplimit()→ thecentos)branch:The comment above this block explains that
nftableswas added so the default sshdjail would not log
nft: not found, and it explicitly mentions "fresh RHEL-family"systems. The problem is that on EL7 the same command also drags in
firewalld, andnothing in the script ever accounts for that:
install_firewall()only implementsufw, so there is no firewalld code path anywhere, and no port is ever opened in itszone.
Because the RPM only enables the unit (systemd preset) without starting it, the
breakage is deferred to the next boot — which makes it very hard to connect the symptom
back to the install/upgrade that caused it. Debian/Ubuntu are unaffected, which likely
explains why this has gone unnoticed.
Impact. Any EL7 deployment that did not already have
firewalldinstalled loses allnon-SSH connectivity after the first reboot following a 3x-ui install or upgrade.
Suggested fix (any of these).
firewalldwas pulled in by this transaction and was notpresent/running before, leave it disabled afterwards (
systemctl disable --now firewalld). The3x-ipljail uses plain iptables(
before = iptables-allports.conf) and does not need firewalld, so IP Limit keepsworking.
that inbound ports must be opened manually.
firewalld, so the operator is not left debugging a "panel is down" symptom that hasnothing to do with the panel.
Workaround for affected users (IP Limit / fail2ban keeps working):
Note. As of this report,
x-ui.shonmainstill contains the same block.@github-actions[bot] commented on GitHub (Sep 16, 2026):
Confirmed — this is a real bug, and your root-cause analysis matches the source line for line. The install/upgrade path does run the fail2ban package transaction unattended on EL7, and there is no firewalld handling anywhere in the repository, so nothing detects or compensates for a firewall arriving as a dependency.
What I verified in the source
The transaction is unattended, on both install and upgrade.
install.sh:1828callssetup_fail2banat the end of a fresh install; it shells out to the CLI atinstall.sh:1405—if /usr/bin/x-ui setup-fail2ban; then.update.sh:1266does the same on every upgrade, which is the pathx-ui updateand the panel self-updater both take.x-ui.sh:3593maps that subcommand tosetup_fail2ban_iplimit.The EL7 branch is exactly as you quoted (
x-ui.sh:2317):It is reached only when fail2ban is absent —
x-ui.sh:2279:if ! command -v fail2ban-client &> /dev/null; then— which is why hosts that already had fail2ban (or already had firewalld) never see this.Nothing in the repository knows firewalld exists. A grep for
firewalldacross all*.sh,*.goand*.mdreturns zero hits.install_firewall()(x-ui.sh:1080) is ufw-only andapt-get-only:so it cannot even run on EL7, and every other entry in
firewall_menu(x-ui.sh:1031-1078) callsufwdirectly. The docs page for this is ufw/nftables-only too (docs/content/docs/en/reference/ports-firewall.mdx:3).Your point that the IP Limit jail does not need firewalld is correct. The jail pins its own action (
x-ui.sh:2523,action=3x-ipl), and that action is raw iptables (x-ui.sh:2551,before = iptables-allports.conf;x-ui.sh:2564,actionban = <iptables> -I f2b-<name> 1 -s <ip> ...). Disabling firewalld therefore does not break IP Limit.When it became unattended.
0d764f1b— "feat(iplimit): auto-install fail2ban on install and update" (2026-06-22), first shipped in v3.4.0. Before that commit the sameyumtransaction existed but only ran when an operator chose the IP Limit menu item.71ac9204(2026-04-22) addednftablesto that command, but per youryum historythe firewalld chain comes fromfail2banitself, not fromnftables. Still present on the default branch at the tip; v3.8.5 is the latest release, so there is nothing newer to upgrade into.What I could not verify
I have no access to EPEL package metadata from here, so the
fail2ban→fail2ban-firewalld→firewallddependency edge and the systemd-preset enablement rest on youryum history infoandrpm -q --whatrequires firewalldoutput rather than on anything in this repo. Both of those are self-consistent and I have no reason to doubt them. I could not read thefirewall-cmdoutput you pasted as anything other than text, which is all that was needed.Workaround for anyone hitting this
Check first, on any EL7 host that ran a 3x-ui install or upgrade and has not yet rebooted — this is the window where the host still looks healthy:
If that prints
enabled, either drop the firewall you did not ask for (IP Limit keeps working, per the jail lines above):or keep it and open your own ports before rebooting — substitute your panel port, your subscription port and every inbound port:
Verdict: Confirmed bug
Severity: High
Confidence: High for the panel-side chain (every line cited above); the EPEL dependency edge is reporter-supplied, see "What I could not verify"
Root cause:
setup_fail2ban_iplimit()inx-ui.sh:2270, thecentos)EL7 branch atx-ui.sh:2317, runsyum -y install fail2ban nftablesunattended frominstall.sh:1828/update.sh:1266, and no code path in the repository inspects, disables or configures a firewall the transaction may have introduced. Triggers whenID=centosandVERSION_IDstarts with 7 andfail2ban-clientis absent (x-ui.sh:2279) and firewalld was not already installed. Made unattended by0d764f1b(v3.4.0); the same command was previously menu-driven.Already fixed: Still present on the default branch —
x-ui.sh:2317is unchanged at the tip, and v3.8.5 is the latest releaseDuplicate of: None.
gh search issues "firewalld"and a search for firewall/reboot/unreachable return no other report of thisEvidence:
install.sh:1405if /usr/bin/x-ui setup-fail2ban; then;install.sh:1828setup_fail2ban;update.sh:1266setup_fail2ban;x-ui.sh:2279if ! command -v fail2ban-client &> /dev/null; then;x-ui.sh:2320yum -y install fail2ban nftables;x-ui.sh:1083apt-get install -y ufwinsideinstall_firewall();x-ui.sh:2551before = iptables-allports.conf;x-ui.sh:2564actionban = <iptables> -I f2b-<name> 1 -s <ip> -p tcp -m multiport ! --dports <exemptports> -j <blocktype>; commit0d764f1b; zerofirewalldhits repo-wideNot determined: Whether the RHEL-family branch at
x-ui.sh:2309(dnf -y install fail2ban nftables, used for fedora/rhel/almalinux/rocky/ol/amzn and CentOS 8+) pulls the samefail2ban-firewallddependency — if it does, the fix belongs in both branches rather than only the EL7 one. It would matter less there because those images usually ship firewalld enabled already, so the transaction changes nothing.dnf repoquery --requires --resolve fail2banon an EL8/EL9 host settles it.Suggested fix: in
setup_fail2ban_iplimit()(x-ui.sh:2270), record on the RPM branches whether firewalld was installed and active before the transaction, and if the transaction introduced it, leave it disabled — the3x-iplaction is iptables-only (x-ui.sh:2551) and never needs it. If leaving it enabled is preferred, the minimum is a loud warning naming the panel port, since the breakage is deferred to the next boot and reads as "the panel died". Whichever way it goes,install_firewall()being ufw/apt-only means there is no in-menu remediation path on the RHEL family today.@MHSanaei flagging this one: a 3x-ui install or upgrade on a CentOS 7 host with no firewalld takes the panel, the subscription port and every inbound offline at the next reboot, with no firewall-related output at install time.
This reply was generated automatically; a maintainer may follow up.
@Drswith commented on GitHub (Sep 16, 2026):
Follow-up: I independently verified the two items you flagged, and there is one correction to the impact estimate. Patch attached at the end.
1. The EPEL dependency edge — independently reproduced
You noted this edge rested on my
rpmoutput rather than on anything reproducible here. Reproduced from scratch in a clean EL7 container (nofirewalld, nofail2ban), running the exact command fromx-ui.sh:2320:2.
Not determined-> the RHEL-family branch is affected tooThe same edge exists on EL9:
So the branch at
x-ui.sh:2315(dnf -y install fail2ban nftables, used by fedora/rhel/almalinux/rocky/ol/amzn and CentOS 8+) carries the same dependency. Note that the baserockylinux:9image does not ship firewalld, so "those images usually ship firewalld enabled already" does not hold for minimal or container images.3. Why it stays silent until a reboot — mechanism confirmed
firewalld's%postonly enables the unit; it never starts it:And on EL7 that
presetresolves to enable:(
99-default-disable.presetcontainsdisable *, but preset is first-match-wins and90-default.presetsorts earlier.)The zone that then applies has no port entries at all:
which is why the panel port, the subscription port and every inbound port are rejected after the first boot, while SSH keeps working.
4. Patch
Adds a
disable_pulled_in_firewalldhelper, records whetherfirewalldexisted before the transaction, and calls the helper after the install. The detection and the call both sit outside thecase "${release}"block, so every OS branch is covered — no separate EL9 change is needed.fix-el7-firewalld.patch(applies tox-ui.sh)5. Testing
Applied to
x-ui.shand run as/usr/bin/x-ui setup-fail2banon a clean EL7 container — realyumtransaction, real RPM state, real script:systemctlinvocations observed (recorded with a stub, since containers have no systemd):The helper's branches were exercised separately: firewalld absent before the transaction -> disabled; firewalld present before -> no action; firewalld present and active -> warning only, never reconfigures an operator's running firewall; no argument (default) -> no action.
Happy to open this as a PR if the approach looks right. The one open design question is whether the check should stay precise (act only when
firewalldwas genuinely absent before the transaction, which is what the patch does) or be widened to also rescue hosts that already hit this (act wheneverfirewalldis enabled but not running).