Firewall

TC Dan

New Member
Sep 6, 2018
13
1
3
56
Can someone give me a bit of guidance on which firewall-ish things to use and how to combine them? I recently did a fresh install on Debian 13 and it seems that iptables-legacy got installed and activated (without doing anything on IPv6) alongside nftables which got installed but not activated while fail2ban writes in both their configs and then there is also Event Guard which to my understanding does the same as fail2ban.. or something the like.
Is there a general recommendation or a standard config that is recommended and can be copied from somewhere?
 
The short version: pick one firewall backend and make everything write to that one. Having iptables-legacy active and nftables installed but idle isn't harmful by itself, but it gets confusing fast when fail2ban or anything else adds rules to the one that isn't actually filtering traffic.

What I'd check:
1. Which one is really in use. `update-alternatives --display iptables` shows whether iptables points at legacy or nft, and `iptables-legacy -S` vs `nft list ruleset` shows where your rules actually live.
2. IPv6. If the install only wrote IPv4 rules, check `ip6tables -S`. If the server has a public IPv6 address and no v6 rules, SIP and the web UI may be wide open on v6. Either add matching v6 rules or disable IPv6 if you don't use it.
3. fail2ban. Set its banaction to match the backend you're using (iptables-multiport for iptables, nftables-multiport for nftables) so bans land in the live ruleset.
4. Event Guard and fail2ban overlap. Event Guard is FusionPBX's own blocker, driven by FreeSWITCH events such as failed SIP registrations, while fail2ban works from log files. Plenty of people run both, but if you do, make sure both write to the same backend, and decide which one owns SIP so you're not troubleshooting double bans.

The simplest setup is usually to stick with whatever the official FusionPBX install script set up for your version, keep that one backend, and only add rules on top of it. If you post the output of `iptables -S` and `ip6tables -S` with your IPs masked, people can sanity-check it.
 
I'm quite sure it's insane. ;)
iptables points to legacy and the service is active,
iptables is populated,
ip6tables is empty,
nftables is installed but inactive
fail2ban is active,
jail.conf specifies
banaction = iptables-multiport
banaction_allports = iptables-allports
jail.local specifies various
action = iptables-allports[...]
jail.d/defaults-debian.conf specifies
banaction = nftables
banaction_allports = nftables[type=allports]
 

Attachments

Last edited:
I would prefer nftables in a new setup (as it seems more future-proof and I would like to be able to use IPv6 as well) if that does not get too complicated.
What I don't know is:
- fail2ban does also handle IPv6 correctly, I guess?
- I guess it is advisable to configure fail2ban to act on nftables directly, not on the iptables compatibility layer, or isnt't it?. How do I do that? Is there an example config somewhere?
- Does Event Guard handle IPv6 properly?
- Is it advisable to let Event Guard handle what it can and deactivate the corresponding jails in fail2ban? Is it better maybe to deactivate Event Guard and rely on fail2ban for everything?
- How come the config is such a mess after the install? Should I maybe activate nftables first and then run part of the installer again so it generates a more sensible config?
 
Last edited: