Calling all Linux enthusiasts! Help us create a comprehensive guide to Linux firewalls and security!

3 years ago by Harry_Houdini to c/linux

Hello fellow Linux enthusiasts!

As many of you know, Linux can be a powerful and flexible operating system, but it can also be daunting for new users, especially when it comes to securing their systems. With the abundance of information available online, it's easy to get overwhelmed and confused about the best practices for firewall configuration and basic security.

That's why I reaching out to the Linux community for help. I am looking users who are willing to share their expertise and write a comprehensive guide to Linux firewall and security.

The goal of this guide is to provide a centralized resource that covers the following topics:

Introduction to Linux firewalls (e.g., firewalld, ufw, etc.)
Understanding basic security principles (e.g., ports, protocols, network traffic)
Configuring firewalls for various scenarios (e.g., home networks, servers, VPNs)
Best practices for securing Linux systems (e.g., password management, package updates, file permissions)
Troubleshooting common issues and errors
Advanced topics (e.g., network segmentation, SELinux, AppArmor)

I am looking for a well-structured and easy-to-follow guide that will help new users understand the fundamentals of Linux firewall and security, while also providing advanced users with a comprehensive resource for reference.

If you're interested in contributing to this project, please reply to this post with your experience and expertise in Linux firewall and security. We'll be happy to discuss the details and work together to create a high-quality guide that benefits the Linux community.

Thank you for your time and consideration, and im looking forward to hearing from you!

TCB13 34 points 3 years ago path: 0 4447934, hotness: undefined, score: 34, children: 0
apt_install_coffee 31 points 3 years ago

I build Linux routers for my day job. Some advice:

  • your firewall should be an appliance first and foremost; you apply appropriate settings and then other than periodic updates, you should leave it TF alone. If your firewall is on a machine that you regularly modify, you will one day change your firewall settings unknowingly. Put all your other devices behind said firewall appliance. A physical device is best, since correctly forwarding everything to your firewall comes under the "will one day unknowingly modify" category.

  • use open source firewall & routing software such as OpenWRT and PFSense. Any commercial router that keeps up to date and patches security vulnerabilities, you cannot afford.

path: 0 4455438, hotness: undefined, score: 31, children: 6
LordKitsuna 10 points 3 years ago

i just want to also toss opnsense into that list, a long time ago it forked off pfsense and these days it offers (in my opinion) a significantly easier and better UI as well as more up to date kernel and better tools for dealing with things like buffer bloat

path: 0 4455438 4459031, hotness: undefined, score: 10, children: 0
skimm 4 points 3 years ago

Any links or thoughts on sane OpenWRT settings for a home network? I'm a networking noob but learning slowly and would love some good reading or tips.

path: 0 4455438 4468855, hotness: undefined, score: 4, children: 2
wrinkletip 5 points 3 years ago

The defaults are great.

path: 0 4455438 4468855 4469183, hotness: undefined, score: 5, children: 0
apt_install_coffee 2 points 3 years ago

Most firewalls are at their safest when you first get them i.e by default they block everything coming in. As you start doing port forwarding and the like you start making the network selectively less secure; that's when you have to pay attention.

path: 0 4455438 4468855 4487232, hotness: undefined, score: 2, children: 0
cole 2 points 3 years ago

opinions on Ubiquiti routers?

path: 0 4455438 4469591, hotness: undefined, score: 2, children: 1
apt_install_coffee 2 points 3 years ago

I had an EdgeRouter X for years before I started my job. They are solid devices, and I'd definitely put them above most consumer routers.

Because they only charge for the hardware, they will eventually run into the same disincentive to provide consistent timely updates. If you do buy an Ubiquiti or similar enthusiast brand, do still keep an eye out for the CVEs that don't get patched.

path: 0 4455438 4469591 4487161, hotness: undefined, score: 2, children: 0
pastermil 17 points 3 years ago

I think firewall is the last thing you'd want to discuss with the newcomers...

path: 0 4458854, hotness: undefined, score: 17, children: 13
LordKitsuna 5 points 3 years ago

Yeah I don't even understand the point. The vast majority of people don't even need a client side firewall. The only time you need to worry about a client side of firewall is if you're on a laptop that you actually take out of your house ever or on a university or otherwise shared network. At home it's completely meaningless and a waste of CPU Cycles.

There are significantly better ways to address security, like how to enable a sandbox like firejail or bubblewrap or enable things like apparmor, firewall is probably one of the most inconsequential parts of security these days because it's all handled by the local router

path: 0 4458854 4458922, hotness: undefined, score: 5, children: 12
AProfessional 11 points 3 years ago

Home networks are full of trash like iot devices, like smart speakers, tvs, plugs, etc. Average people should have firewalls. It’s free.

path: 0 4458854 4458922 4467998, hotness: undefined, score: 11, children: 9
LordKitsuna 3 points 3 years ago

If you genuinely wish to isolate those devices the correct way to do it is not with client firewalls but with a Smart Switch and vlans

path: 0 4458854 4458922 4467998 4480731, hotness: undefined, score: 3, children: 2
AProfessional 3 points 3 years ago

You may want them to communicate with each other to control them. Also setting up a vlan is quite complex for most users even if it has clear upsides.

path: 0 4458854 4458922 4467998 4480731 4482681, hotness: undefined, score: 3, children: 0
AnonStoleMyPants 1 point 3 years ago

Man, I should do this one of these days.

path: 0 4458854 4458922 4467998 4480731 4497027, hotness: undefined, score: 1, children: 0
gohixo9650 -1 points 3 years ago

if you have set up your whole home like being bugged you'll not gain much from a firewall in the most secure of devices among them.

path: 0 4458854 4458922 4467998 4468431, hotness: undefined, score: -1, children: 5
AProfessional 7 points 3 years ago

Sure you will, the literal point of a firewall is to isolate trusted and untrusted devices.

path: 0 4458854 4458922 4467998 4468431 4468596, hotness: undefined, score: 7, children: 4
Honytawk 8 points 3 years ago

Yeah, because how many people take their laptops out of their home, amiright?

path: 0 4458854 4458922 4469839, hotness: undefined, score: 8, children: 1
LordKitsuna 6 points 3 years ago

I did consumer electronics recycling and repair for 5 years, and then did like another 5 years of just generic home call repair. You would be shocked how many people basically use their laptop as nothing more than a weird underpowered desktop and it literally just never leaves that spot

path: 0 4458854 4458922 4469839 4480759, hotness: undefined, score: 6, children: 0
aodhsishaj 13 points 3 years ago

This is a very broad subject. Are we talking straight iptables, or ufw/firewalld or at the app level with selinux/apparmor. Or at the firewall level like opnsense/pfsense? Or on the router side ddwrt and tomato etc. You can grab certain distros on either side, whonix/tails on the blueteam side, kali on the red team side. There are hardened kernels like zen and securelinux. There's network security, but also kernel level stuff like run levels, tpm, uefi, etc.

My real question is who is the audience for this? What is their use case, what distro are they using? What is the proposed environment?

path: 0 4448041, hotness: undefined, score: 13, children: 1
Pantherina 2 points 3 years ago

Problem 1: what tools do you choose?

path: 0 4448041 4452745, hotness: undefined, score: 2, children: 0
jollyrogue 7 points 3 years ago

Interesting.

What are the hosting details and contrib guidelines?

And some other random notes…

“Best practices for securing Linux” could probably be dropped. There are enough of those, and the topic could overrun the focus on firewalls. I could see a secure network section, but Linux might be too broad.

What about opening it up to FOSS firewalls and networking in general? The BSDs, Illumos, Haiku, and others could be added. Linux could be the starting point, and the others could be added as people feel like it.

path: 0 4447544, hotness: undefined, score: 7, children: 0
knobbysideup 5 points 3 years ago
  • use pfsense for a firewall. Using nftables, firewalld, etc should only really come into play if on an untrusted network. Firewalls on servers can cause more problems than they solve and are easy to misconfigure.
  • run lynis on your Linux servers to help get them compliant with CIS benchmarks
  • be careful with your reverse proxies
  • keep things patched
  • run only necessary services
  • configure needed services conservatively
  • no root logins
path: 0 4453996, hotness: undefined, score: 5, children: 1
LordKitsuna 3 points 3 years ago

i just want to also toss opnsense into that list, a long time ago it forked off pfsense and these days it offers (in my opinion) a significantly easier and better UI as well as more up to date kernel and better tools for dealing with things like buffer bloat

path: 0 4453996 4459040, hotness: undefined, score: 3, children: 0
hottari 5 points 3 years ago

Have your tried the ArchWiki for the firewall programs you mentioned and their Security wiki as well? I usually find it resourceful and very comprehensive.

path: 0 4473635, hotness: undefined, score: 5, children: 0
MigratingtoLemmy 5 points 3 years ago

Basically, a dummies guide on nftables and SELinux?

path: 0 4448787, hotness: undefined, score: 5, children: 0
Stillhart 5 points 3 years ago

I tried using a guide online one time to build a linux router/firewall onto a passively-cooled mini-computer that I could leave on a shelf with no I/O connected... basically a replacement for the garbo off-the-shelf wifi routers that die every year. It worked...mostly. The problem is that the random little things that didn't work right just were insurmountable for a linux noob who was just trying to follow a guide.

I hate that spending money on the best ones you can buy STILL die after a year or two. And now they all require you to login so even more people can inspect all my network traffic.

I'd love to see a guide that's kept up to date for building a simple router/firewall, with sections like you have above for more information so people can unlock ports for unusual stuff or whatever. I mean, in a perfect world, you install a LTS OS and set it up and forget about it for a few years. Mine was like that except it required manual intervention every time it rebooted. If that wasn't the case, it would have been perfect and I would be recommeding it to everyone.

path: 0 4452084, hotness: undefined, score: 5, children: 25
LordKitsuna 4 points 3 years ago

Instead of building one from scratch why not simply use one of the already made router operating systems? I would personally recommend opnsense, it has a nice easy to use web UI and can be setup in like maybe 20min.

as for hardware you can use just about anything but i highly recommend these cute little dedicated router boxes. It is passively cooled, plenty powerful to handle wireguard VPN at gigabit speeds and should easily last you many many years without an issue.

path: 0 4452084 4459087, hotness: undefined, score: 4, children: 1
Stillhart 1 point 3 years ago

That's the kind of box I've been using. Just been running linux on it. It's been a few years, I'll look into opnsense, thx.

path: 0 4452084 4459087 4459145, hotness: undefined, score: 1, children: 0
possiblylinux127 2 points 3 years ago

Use openwrt on a existing device

path: 0 4452084 4453182, hotness: undefined, score: 2, children: 8
Stillhart 3 points 3 years ago

My issue is that the cheapo consumer hardware sucks. Using good software on bad hardware doesn't solve the issue. Unless I can use it on a normal computer... last I looked into it, I don't think you could.

path: 0 4452084 4453182 4457828, hotness: undefined, score: 3, children: 7
Pantherina 1 point 3 years ago

I really want to. My flatmates dont care at all, but afaik our router is supported. Could you share any experiences, how is the installation on such a "not meant to use third party software" device, are updates automatic? Do you install packages? How is the WebUI, how long would it take to just have it working?

path: 0 4452084 4453182 4457828 4464471, hotness: undefined, score: 1, children: 3
jollyrogue 1 point 3 years ago

Installation of OpenWRT from stock depends on the device. Some devices are more involved than others.

Updates are not automatic, and they require planning with some down time. The process is backup settings, update wiping out settings, reapply settings by uploading backup.

I do not install packages. That leads even more horribly complicated updates. I don’t recommend using anything that isn’t in the stock image.

LuCI is serviceable. It’s not pretty, or the most intuitive, but it works.

OPNsense is better if you have the x86 hardware around to run it.

path: 0 4452084 4453182 4457828 4464471 4469794, hotness: undefined, score: 1, children: 2
possiblylinux127 -1 points 3 years ago

The key is you just buy something a little nicer.

path: 0 4452084 4453182 4457828 4458797, hotness: undefined, score: -1, children: 2
Stillhart 0 points 3 years ago

Wow I never thought of that...

path: 0 4452084 4453182 4457828 4458797 4459109, hotness: undefined, score: 0, children: 1
Pantherina 1 point 3 years ago

Can you explain to me what a router does? Is is just a PC tunnelling inbound and outbound connections? What makes it the master of the network?

Btw in Germany we have FritzBox which doesnt suck, but seems they sell their company

path: 0 4452084 4452672, hotness: undefined, score: 1, children: 13
Stillhart 3 points 3 years ago

You got a lot of good answers to this. I'll add mine:

A router is a device that bridges multiple physical networks (it will have at least two network interfaces) and directs traffic between them. It inspects every packet of data and decides which port to send it to.

In a typical home here in the US, one network is your ISP (connected to your cable modem, for example) and the other is your home computers, consoles and devices via wifi or direct connection (like a NAS drive, for example).

Generally you want a firewall to go along with your router. Instead of blindly passing all data to the correct network, it will decide whether it is allowed to pass or not based on a configured ruleset. Most consumer home wifi routers have a simple firewall built-in.

They also have other features like "load balancing" to prioritize certain data that is more sensitive to interruptions in the data flow (like gaming) over data that isn't (like video or audio), or "DHCP servers" to hand out IP addressed to devices on the network, or "VPN tunneling" to encrypt data, etc.

A linux-based computer is more than capable of performing all these tasks. If well-configured, it can do it much better than a consumer device, with better hardware and more reliability for less money over time (when taking reliability into account).

path: 0 4452084 4452672 4457795, hotness: undefined, score: 3, children: 3
Pantherina 1 point 3 years ago

Thanks!

I had another problem, I wanted to set a not sucking DNS server on our router, but nobody had internet anymore unless they would set the same server on their devices. Why is that?

I simply wanted to avoid our ISP spying on us by using some shit DNS server they control or get paid by

path: 0 4452084 4452672 4457795 4464479, hotness: undefined, score: 1, children: 2
Stillhart 1 point 3 years ago

The best way to avoid your ISP spying is to use a VPN. It encrypts all the data before your ISP ever sees the data so they can't spy on you. I use Private Internet Access but I recommend doing some research and finding one that's good in your country.

I'm not sure why you had an issue with just changing your DNS. Did you change it in the DHCP settings or somewhere else?

Regardless, just to be clear, changing your DNS won't prevent your ISP from spying on you. Many of the big DNS providers like Google will absolutely spy on you through your DNS calls so I do think it's a good idea to use a better DNS. I personally use AdGuard DNS, which has a built in ad blocker that works really well.

path: 0 4452084 4452672 4457795 4464479 4470699, hotness: undefined, score: 1, children: 1
possiblylinux127 2 points 3 years ago

A router routes traffic. It usually has dhcp and a firewall.

However, most devices for consumers are a router, switch and a wireless access point. What this means is that they have a router but also Ethernet plugs in the back and a WiFi antenna

path: 0 4452084 4452672 4453242, hotness: undefined, score: 2, children: 0
captain_aggravated 2 points 3 years ago

There is a thing called the OSI model, which is a useful tool for understanding what different components of a computer network do. I suggest looking up that term if you want to learn more about how networks work.

You might be familiar with the idea of IP addresses and MAC addresses. An IP address is routable, as in you can look at an IP address and tell where on the network (and broadly speaking, in the world) it is. A MAC address is assigned to the network adapter during its manufacture, it's kind of like the machine's name.

When you get out a sheet of parchment, a well of squid ink and a quill pen and write an old fashioned letter to an acquaintance (ask your parents, they probably used to actually do this), you write both the recipients street address and their name on the envelope. The postal service uses the street address to move the letter to the correct building, and then there's probably someone in your household who gets the mail out of the mailbox and then says "Jim, this letter is for you."

Think of a router as a post office; routers send each other data packets based on the recipient IP address. A switch works via MAC addresses and is more like your dad saying "Jim you got a letter." A hub, which is a technology we don't use anymore, would be more like your dad reading everyone's mail out loud for everyone to hear, and everyone else is just supposed to ignore what's not for them.

Now, let's talk about a more informal definition of the word "router": The box with a bunch of wires and probably a couple antennas on it that your Wi-Fi probably comes out of. We call that little box a "router," and that's one of the many jobs it does. You can think of networking components as little building blocks, and your home router has many building blocks in it. It's a little computer with some networking hardware attached, and it likely functions as a router, an Ethernet switch, a wireless access point or two, probably your DHCP server (assigns IP addresses to devices on the network automatically), it probably serves as a firewall, mine can be a print server or a file server.

path: 0 4452084 4452672 4455784, hotness: undefined, score: 2, children: 7
Pantherina 1 point 3 years ago

Thanks a lot! So a switch uses Mac adresses and not the DHCP IPs?

In our basement we had two switches. A long ethernet cable goes from the router there, into one switch, and from that one many cables into another switch, and from that one all the cables go seperately to the rooms. Both switches are supplied with electricity.

Now for some reason ethernet doesnt work anymore, even though I used the correct cables and removed the rest as nobody uses ethernet anymore, just two cables, repeater and my cloud server.

I just used one switch, as I had no idea what you would need two switches for? Before there were 8 cables or so, now only 2

path: 0 4452084 4452672 4455784 4464452, hotness: undefined, score: 1, children: 6
captain_aggravated 2 points 3 years ago

"From that one many cables into another switch" as in, you used more than one cable to plug one switch into another? Yeah that won't work. Ethernet doesn't like that kind of thing.

It is valid to connect one switch to another if you need more ethernet ports, but you would connect them with one cable. The best way to do it if possible would be to connect each switch to a port on the router,

path: 0 4452084 4452672 4455784 4464452 4479572, hotness: undefined, score: 2, children: 5
kugmo 4 points 3 years ago

I'd love a good firewalld guide that's kinda tldr and would go into the details later.

path: 0 4488983, hotness: undefined, score: 4, children: 0
Secret300 4 points 3 years ago

Been using Linux for 8 years. Never even touched a firewall. Well one time on Ubuntu server i used ufw to open a port but that was it

path: 0 4454654, hotness: undefined, score: 4, children: 1
Espi 5 points 3 years ago

While I think firewalls are overrated, they are also dead easy to set up, and the best kind of defense is defense in depth.

path: 0 4454654 4455092, hotness: undefined, score: 5, children: 0
JWBananas 3 points 3 years ago

Nobody:

OP: "Please do the needful."

path: 0 4448445, hotness: undefined, score: 3, children: 0
barrett9h 2 points 3 years ago
  1. Install OpenBSD
  2. ???
  3. Profit!
path: 0 4449386, hotness: undefined, score: 2, children: 1
possiblylinux127 0 points 3 years ago

No thanks. I like to stay on the beaten path

path: 0 4449386 4453259, hotness: undefined, score: 0, children: 0
ReakDuck 2 points 3 years ago

What kind of attacks could I expect on a Linux Machine? Especially when using bare Arch Linux and only setting up software that I consume (Minecraft Server, Zerotier)

path: 0 4472159, hotness: undefined, score: 2, children: 5
redprog 4 points 3 years ago

Arch on a server, that's gonna be fun lol

path: 0 4472159 4472960, hotness: undefined, score: 4, children: 4
float 4 points 3 years ago

There aren't many distro with a base system as tiny as Arch. It's not a bad choice at all. It's on my server since many years, working perfectly reliable. Everything except the base system is inside Podman containers. Why not?

path: 0 4472159 4472960 4481525, hotness: undefined, score: 4, children: 3
redprog 1 point 3 years ago
path: 0 4472159 4472960 4481525 4481891, hotness: undefined, score: 1, children: 0
redprog 1 point 3 years ago

Not necessarily saying it's a bad idea, especially with everything running within podman it's probably even quite awesome. It just feels like it's a lot more tedious to fix in the case that something got messed up. Still, not a bad idea generally, as long as you know what you're doing ^^

path: 0 4472159 4472960 4481525 4482003, hotness: undefined, score: 1, children: 1
ReakDuck 6 points 3 years ago

After using many different distros, I feel everywhere a little incompetent when trying to fix simple issues.

Arch Linux for some reason always makes things easy and easy fixable in case things go bad.

path: 0 4472159 4472960 4481525 4482003 4483065, hotness: undefined, score: 6, children: 0
sir_reginald -1 points 3 years ago

This shouldn't be targeted at the average used who does not need firewalls nor most networking stuff. If highly invested in security, maybe AppArmor/SELinux could come handy. Other topics I find interesting would be the use of VPNs with Wireguard, setup killswitches, how to configure a system-wide Tor proxy, etc.

In stuff like that I could definitely help, depending on the conditions.

path: 0 4473177, hotness: undefined, score: -1, children: 0
linux
linux

@lemmy.ml

login for more options
67083
9205
4151

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

go to feed...