Technology Encyclopedia Home >How to configure firewall and security settings on Fedora?

How to configure firewall and security settings on Fedora?

Configuring firewall and security settings on Fedora involves several steps. The primary tool for managing firewall settings on Fedora is firewalld. Here’s how you can configure it:

Enabling and Starting Firewalld

  1. Install Firewalld (if not already installed):

    sudo dnf install firewalld
    
  2. Start Firewalld:

    sudo systemctl start firewalld
    
  3. Enable Firewalld to start on boot:

    sudo systemctl enable firewalld
    

Basic Firewall Configuration

  1. Check the current status of Firewalld:

    sudo firewall-cmd --state
    
  2. List all active zones and their services:

    sudo firewall-cmd --get-active-zones
    
  3. Add a service to the default zone (e.g., HTTP):

    sudo firewall-cmd --permanent --add-service=http
    
  4. Reload Firewalld to apply changes:

    sudo firewall-cmd --reload
    

Advanced Configuration

  1. Open a specific port (e.g., port 8080):

    sudo firewall-cmd --permanent --add-port=8080/tcp
    sudo firewall-cmd --reload
    
  2. Create a new zone for more granular control:

    sudo firewall-cmd --new-zone=customzone --permanent
    sudo firewall-cmd --reload
    sudo firewall-cmd --zone=customzone --add-source=192.168.1.0/24 --permanent
    sudo firewall-cmd --zone=customzone --add-service=https --permanent
    sudo firewall-cmd --reload
    

Security Settings Beyond Firewall

  1. Enable SELinux (if not already enabled):

    sudo setenforce 1
    
  2. Configure SELinux policies:
    SELinux policies can be complex, but you can use tools like semanage to manage them.

Example Scenario

Imagine you have a web server running on Fedora and you want to allow HTTP traffic but block all other incoming traffic. You would:

  • Enable Firewalld and start it.
  • Add the HTTP service to the default zone.
  • Reload Firewalld to apply the changes.

Recommendation for Cloud Environments

If you are managing a Fedora instance in a cloud environment, consider using managed security services to complement your firewall settings. For example, Tencent Cloud offers a range of security services that can help enhance the security posture of your cloud instances, including network firewalls, intrusion detection, and DDoS protection.

By following these steps, you can effectively configure firewall and security settings on Fedora to protect your system from unauthorized access and potential threats.