[Feature] Add firewall backend selection (iptables/nftables/none) to Fail2ban/IP Limit installer#5905
[Feature] Add firewall backend selection (iptables/nftables/none) to Fail2ban/IP Limit installer#5905hermit-turtle wants to merge 8 commits into
Conversation
|
Summary Findings Finding 1 - default "iptables" choice no longer installs nftables; EPEL and CentOS 7 handling dropped Finding 2 - iplimit_remove_conflicts is called but its definition is deleted Finding 3 - nftables action definition is incomplete and appears syntactically invalid actionunban = delete rule ip f2b- ip saddr ... with a literal, unfinished "..." instead of real clauses, and only one line total (no UDP counterpart, unlike actionban which has two lines). Separately, actionstart/actionstop run " add chain ip f2b- { ... }" and " delete chain ip f2b-", omitting the table argument that nft add/delete chain requires (no add table is issued anywhere in this action).Why it matters: as written this is not valid input to nft. actionstart, and therefore the jail itself, is likely to fail to initialize, and actionunban will fail on the literal "..." every time. The nftables backend this PR advertises is very likely non-functional, meaning it will not actually ban or unban anyone, which conflicts with the description text claiming both backends were verified to work correctly. Recommendation: Base the nftables action on the nftables*.conf templates shipped by fail2ban itself, which use a named set plus add element/delete element for ban and unban since nft cannot delete a rule by match spec, and exercise an actual ban/unban cycle with "nft list ruleset" before merging. Finding 4 - chosen backend is not persisted; later operations silently revert to iptables Positive observations Verdict This review was generated automatically; a maintainer may follow up. |
FIX #1: x-ui.sh:2306-2309Remove call to deleted function. Inline cleanup: rm -f /etc/fail2ban/jail.d/3x-ipl.conf 2>/dev/null
rm -f /etc/fail2ban/action.d/3x-ipl.conf 2>/dev/null
rm -f /etc/fail2ban/filter.d/3x-ipl.conf 2>/dev/nullFIX #2: x-ui.sh:2272-2298
FIX #3: x-ui.sh:2493-2507Replace nftables action with named-set syntax: actionban = nft add element ip f2b 3x-ipl { <ip> }
actionunban = nft delete element ip f2b 3x-ipl { <ip> }
actionstart = nft add table ip f2b ... | nft add set ... | nft add chain ... | nft add rule ...
actionstop = nft delete chain ... | nft delete set ... | nft delete table ...FIX #4a: install.sh:~1360After mkdir -p /etc/x-ui
echo "$XUI_FAIL2BAN_BACKEND" > /etc/x-ui/fail2ban_backend
chmod 600 /etc/x-ui/fail2ban_backendFIX #4b: x-ui.sh:~2314After mkdir -p /etc/x-ui
echo "$backend" > /etc/x-ui/fail2ban_backend
chmod 600 /etc/x-ui/fail2ban_backendFIX #4c: x-ui.sh:2450-2453At start of if [[ $# -lt 2 && -f /etc/x-ui/fail2ban_backend ]]; then
backend=$(cat /etc/x-ui/fail2ban_backend)
fi |
Summary
Added support for choosing the firewall backend for Fail2ban/IP Limit during installation: iptables (default), nftables, or none (skip). This makes the panel more compatible with modern systems while keeping full backward compatibility.
Why
Type of change
Areas affected
How was this tested?
x-uimenu → IP Limit section after installation.Breaking changes
None.
Default behavior remains exactly the same (
iptables). Existing installations are not affected unless user explicitly chooses a different backend on reinstall.Checklist