this post was submitted on 11 Oct 2023
203 points (100.0% liked)

Linux

1257 readers
51 users here now

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

Related Communities

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

founded 5 years ago
MODERATORS
 

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!

top 38 comments
sorted by: hot top controversial new old
[–] apt_install_coffee@lemmy.ml 18 points 1 year ago (2 children)

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.

[–] skimm@lemmy.sdf.org 4 points 1 year ago (2 children)

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.

[–] wrinkletip@feddit.nl 5 points 1 year ago (1 children)
[–] drwho 2 points 1 year ago

Agreed. Solid out of the box.

[–] apt_install_coffee@lemmy.ml 2 points 1 year 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.

[–] cole@lemdro.id 2 points 1 year ago (1 children)

opinions on Ubiquiti routers?

[–] apt_install_coffee@lemmy.ml 2 points 1 year 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.

[–] jollyrogue@lemmy.ml 6 points 1 year 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.

[–] Stillhart@lemm.ee 5 points 1 year ago (2 children)

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.

[–] possiblylinux127@lemmy.zip 3 points 1 year ago (1 children)

Use openwrt on a existing device

[–] Stillhart@lemm.ee 4 points 1 year ago (2 children)

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.

[–] Pantherina@feddit.de 1 points 1 year ago (1 children)

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?

[–] jollyrogue@lemmy.ml 2 points 1 year ago* (last edited 1 year ago) (1 children)

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.

[–] Pantherina@feddit.de 1 points 1 year ago (1 children)

Thanks! So its a bit like Docker images, why doesnt it save settings? This sounds pretty horrible, shouldnt network hardware always be updated automatically?

[–] jollyrogue@lemmy.ml 1 points 1 year ago

OpenWRT saves settings. It’s what’s in the backup, and that’s what allows the router to return to operation after a power cycle.

Things get can sideways when settings are persisted across updates. There is an option to persist settings, but there are fewer headaches when settings are wiped and restored from backup.

This gets even worse when packages are in play. Packages aren’t reinstalled when the backup is restored, so any packages need to be tracked then reinstalled after an update.

You’re opting to self-manage the router by installing OpenWRT. You are the QA department, and it’s up to you to make sure everything works and any manual changes are made.

In a production setting, no not at all. Updates need to be QA’d before being released, especially network equipment updates, to prevent outages.

The Turris Omnia is OpenWRT based and does auto updates, but the Turris is also $300-$400 dollars.

[–] possiblylinux127@lemmy.zip 1 points 1 year ago (1 children)

The key is you just buy something a little nicer.

[–] Stillhart@lemm.ee 1 points 1 year ago (1 children)

Wow I never thought of that...

[–] possiblylinux127@lemmy.zip 2 points 1 year ago (1 children)

I'm serious. You can pick up a WiFi 6 router with gigabit networking that will work just fine.

[–] drwho 1 points 1 year ago

Seriously. I have a couple of Linksys EA8300's running OpenWRT in my house, and I did not expect the performance jump over my old ones. For not a lot of money I pretty much tripled the speed of the house wireless network.

[–] Pantherina@feddit.de 1 points 1 year ago* (last edited 1 year ago) (2 children)

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

[–] Stillhart@lemm.ee 2 points 1 year ago (1 children)

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).

[–] Pantherina@feddit.de 1 points 1 year ago (2 children)

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

[–] drwho 1 points 1 year ago

Do they use DHCP for their network addressing information? They should get the router's IP as the default recursive DNS resolver...

[–] Stillhart@lemm.ee 1 points 1 year ago (1 children)

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.

[–] Pantherina@feddit.de 1 points 1 year ago

I wanted to use the changed DNS for adblocking (good for the environment too haha) and also of course not use Google but a good one, best not in my own country.

This would be pretty good for privacy I think, especially if it would use DNSCrypt where your ISP would just see the DNSses IP, right?

But this would probably need to be set up on all the clients, and my roomies have apple devices, LOL

[–] possiblylinux127@lemmy.zip 2 points 1 year 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

[–] barrett9h@lemmy.one 5 points 1 year ago (1 children)
  1. Install OpenBSD
  2. ???
  3. Profit!
[–] possiblylinux127@lemmy.zip 2 points 1 year ago (1 children)

No thanks. I like to stay on the beaten path

[–] drwho 3 points 1 year ago

That's understandable. However, pf (OpenBSD's firewall system) is incredibly logical and easy to use. I never expected to write a fully operational (bloody thing worked the first time I tried it!) firewall ruleset on a two hour flight from scratch.

[–] hottari@lemmy.ml 5 points 1 year ago* (last edited 1 year 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.

[–] knobbysideup@lemm.ee 4 points 1 year 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
[–] ReakDuck@lemmy.ml 2 points 1 year ago* (last edited 1 year ago) (1 children)

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)

[–] redprog@feddit.de 4 points 1 year ago (1 children)

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

[–] float@feddit.de 3 points 1 year ago (2 children)

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?

[–] redprog@feddit.de 2 points 1 year ago* (last edited 1 year ago) (1 children)

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 ^^

[–] ReakDuck@lemmy.ml 5 points 1 year 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.

load more comments (1 replies)
[–] JWBananas@startrek.website 1 points 1 year ago (1 children)

Nobody:

OP: "Please do the needful."

[–] drwho 4 points 1 year ago

It reads like OP has been looking for something that is actually usable and not LLM shat garbage blog posts. Asking people directly seems like the primary way of getting any actually useful information these days.