this post was submitted on 24 Dec 2025
16 points (100.0% liked)

Linux

10754 readers
382 users here now

A community for everything relating to the GNU/Linux operating system (except the memes!)

Also, check out:

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 2 years ago
MODERATORS
 

I have been setting up stateful firewalls on various machines at home using iptables for over a year now, following the guide on the Arch Wiki: https://wiki.archlinux.org/title/Simple_stateful_firewall

I would now like to learn how to tighten security even more by not setting the OUTPUT chain policy to ACCEPT. I want to allow only that which I need, following the philosophy of least privilege or default to deny, if you will. https://www.youtube.com/watch?v=aP8j9dgpAs0

Question: is it as simple as copy-pasting the rules for the INPUT chain into the OUTPUT chain, reversing the "-s/--source" options to "-d/--destination" and changing ESTABLISHED states to NEW? My guess is... Probably not? Because I would need to add ports 80 and 443 for web browsing, for starters, right? And also any outgoing port for my torrent client? And any port that I have chosen for my ssh server? Do I need to add the loopback interface there too?

Any guidance and referral to further reading would be appreciated! Unsolicited advice to use the newer front end nftables is... Well, not sought for at this moment

you are viewing a single comment's thread
view the rest of the comments
[–] vudu@slrpnk.net 6 points 23 hours ago (2 children)

Hear me out. I highly suggest you checkout UFW https://wiki.archlinux.org/title/Uncomplicated_Firewall which wraps iptables (or nftables)

When you use UFW and get it working the way you want you can then go look at iptables directly and see how it's implemented.

[–] FauxLiving@lemmy.world 3 points 21 hours ago (1 children)

firewalld is also a decent choice.

[–] dgdft@lemmy.world 5 points 21 hours ago (1 children)

PSA for those who haven’t read the docker docs in detail: If you run docker with UFW or any other iptables based firewall, it will often overwrite and break your firewall rules.

Many people running containers on public hosts get burned by this, because they’re expecting their firewall to block outside traffic from hitting the container.

Firewalld is a solid alternative that does not suffer from the same failure model; highly recommend.

[–] vudu@slrpnk.net 2 points 3 hours ago

Did not know this. thanks!

Thanks! That looks like a great way to learn what's going on "under the hood".