iptables best practice... or paranoia...

Support for security such as Firewalls and securing linux
Post Reply
CaViCcHi
Posts: 68
Joined: 2012/04/18 17:03:15
Contact:

iptables best practice... or paranoia...

Post by CaViCcHi » 2017/05/26 23:02:13

Hi guys,

I was wondering something about iptables and if what I'm about to say is a big "no-no"

is it bad practice to flush and restore/load all your rules anew? of course it's done via script so, once one is done the other one starts, so maybe a second total.

but then I wondered, what about that split second where the firewall is basically off? I mean I know I don't work at NORAD so... it's not a big deal. But still I do wonder if it's something people do... and it's just a "bad practice" when your infrastructure is at actual risk

thanks :)

User avatar
TrevorH
Site Admin
Posts: 33220
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: iptables best practice... or paranoia...

Post by TrevorH » 2017/05/27 14:17:03

It's definitely bad practice if you have rules that use connection tracking as stop/start of iptables kills all record of those established connections and they have to be reconnected.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
jlehtone
Posts: 4531
Joined: 2007/12/11 08:17:33
Location: Finland

Re: iptables best practice... or paranoia...

Post by jlehtone » 2017/05/27 16:39:48

Is the netfilter ever actually "off"? All we do with iptables is to add or remove rules.

There is always the default for each builtin chain, although that is "accept" by default.
If those are set to "deny" before network starts and never changed, then the only
things that get through are by explicit rules.

After flushing all chains, and before adding new rules, all packages do drop as per
our default deny. Yes, that should more or less massacre existing connections.

If you do add rules with a script, they activate one at a time and the order makes a difference.
Cf. the iptables.service loads a whole ruleset atomically.


Yes, the default of "accept" is "bad practice".
Tampering with netfilter rules without profound understanding is also bad practice.


PS. The CentOS 7 has firewalld.service and thus you don't have to touch iptables.service or
iptables for tampering the netfilter.

Post Reply