100===Dev Ops/Firewalld

Firewalld Introduced

블로글러 2024. 6. 12. 08:45

Firewalld is a dynamic firewall management tool that provides an easier and more flexible way to manage firewall rules in Linux, enhancing security by controlling incoming and outgoing network traffic.

The Big Picture

Imagine your computer is a castle, and firewalld is like the castle's dynamic gatekeeper. This gatekeeper doesn't just decide who can enter or leave based on a static list but can adjust its rules on the fly based on different zones, services, and even changing conditions.

Core Concepts

  1. Zones: These are like different security levels for your network interfaces. Each zone has its own set of rules. For example, the "public" zone might be very restrictive, while the "home" zone might be more lenient.
  2. Services: These define what kind of traffic is allowed through the firewall. For instance, allowing HTTP traffic for a web server.
  3. Rich Rules: These are more detailed and specific rules that allow greater customization beyond basic rules and services.
  4. Runtime vs Permanent Configuration: Runtime configurations are temporary and lost on reboot, while permanent configurations persist across reboots.

Detailed Walkthrough

  1. Zones:

    • Analogy: Think of zones like different parts of your house. The front yard (public zone) is very open but has strict rules about who can come in. The living room (home zone) is more relaxed because you trust most people there.
    • Each network interface (like eth0 or wlan0) can be assigned to a zone. For example, your Wi-Fi connection at home might be assigned to the home zone.
  2. Services:

    • Analogy: Services are like invitations to specific people for specific reasons. An invitation for a friend to come over and watch a movie is like allowing HTTP traffic for your web server.
    • Firewalld comes with predefined services like SSH, HTTP, and HTTPS. You can also define your own.
  3. Rich Rules:

    • Analogy: Rich rules are like having a more detailed conversation with the gatekeeper. Instead of just saying "let Bob in," you might say "let Bob in only if he shows his ID and only through the front door."
    • Example: Allow incoming traffic from a specific IP address to access a specific port.
  4. Runtime vs Permanent Configuration:

    • Analogy: Runtime configuration is like giving temporary access to a visitor that will expire when they leave, while permanent configuration is like giving someone a key to your house.
    • Changes made in runtime are active immediately but will be lost on reboot. Permanent changes are saved and applied on every boot.

Understanding Through an Example

Let's say you have a web server running on your computer, and you want to allow HTTP traffic (port 80) from the public zone. Here’s how you’d do it:

  1. Check the current zone:
    firewall-cmd --get-default-zone
  2. List all zones:
    firewall-cmd --get-zones
  3. Add the HTTP service to the public zone:
    firewall-cmd --zone=public --add-service=http --permanent
    The --permanent flag makes this change persistent across reboots.
  4. Reload the firewall to apply changes:
    firewall-cmd --reload

Conclusion and Summary

Firewalld is a flexible firewall management tool that uses zones to define different levels of trust and security for network interfaces. It allows the definition of services and rich rules to finely control network traffic. Configurations can be made temporarily (runtime) or permanently.

Test Your Understanding

  1. What are the main differences between runtime and permanent configurations in firewalld?
  2. How would you assign a network interface to a specific zone?
  3. Explain how you would allow SSH traffic only from a specific IP address using rich rules.

Reference

For more detailed information, you can refer to the official firewalld documentation: firewalld Documentation.

728x90