
Firewalld is a dynamic firewall application that provides a flexible way of setting up network filtering policies on a server by extending the Kernel-based Iptables functionalities. It provides flexible configuration options which include zone-based firewall management policies that represent a specific level of trust depending on your server network connections to protect the system from unauthorized access.
In this article, you will set up firewall policies using Firewalld and configure sample rules to filter network requests on a Vultr Cloud Server.
Before you begin:
Deploy a Vultr Rocky Linux server to use as the workstation.
Access the server using SSH as a non-root user with sudo privileges.
Update the server:
Firewalld is available as a default system package on most Redhat-based server distributions such as CentOS, Rocky Linux, and AlmaLinux. When unavailable, follow the steps below to install and enable Firewalld to set up firewall filtering rules on the server.
Install Firewalld.
Enable the Firewalld application to start at boot time.
Start Firewalld.
Verify that the Firewalld service is active and running.
Run the following command to save all runtime changes to the permanent Firewalld configuration.
Firewalld zones represent the level of trust for network connections associated with a specific network interface. Each zone includes a different security level and policies that govern the traffic flow on the associated interface. By default, Firewalld runs with the following zones:
public: Applies to public-facing interfaces connected to external networks such as the Internet.home: Applies to network interfaces associated with home networks or small office environments.work: Works with corporate or organization network interfaces with better security over the home zone.internal: Works with private interfaces connected to networks such as Vultr VPCs.external: Applies to external untrusted networks. It's similar to the public zone but applies a higher security level by blocking incoming connection requests while accepting outgoing network connections.dmz: Works with network interfaces connected to demilitarized zones partly connected to the Internet and filtered by a firewall.block: Blocks all incoming and outgoing network traffic. It's useful when troubleshooting server network interfaces or networking errors.View all available Firewalld zones.
Output:
View the default Firewalld zone.
Output:
View the active Firewalld zone and the associated server network interfaces.
Output:
View the Firewalld zones assigned to a specific network interface. For example, view the enp8s0 network interface zone.
Run the following command to change an interface from one zone to another. For example, change the enp1s0 interface to the external zone.
Output:
Switching interfaces between zones sets different firewall rules and policies on the network interface for troubleshooting or testing purposes on the server.
View the active zones again to verify that two Firewalld zones are active due to the new interface assignment.
Output:
View all firewall rules associated with the active zone. By default public.
Output:
Change the active zone depending on your server networking environment. For example, change the Firewalld zone to external.
Firewalld accepts network ports, system services, and service names across multiple zones depending on your server interfaces. Every Firewalld zone for example public applies the set policies and rules to the associated interfaces. Follow the steps below to set up firewall policies using Firewalld on the server.
To delete Firewalld rules, replace the --add option with --remove to delete the rule. For example, delete the FTP port 21 policy in the public zone.
Add a new Firewalld rule that allows the SSH TCP port 22 through the public zone.
The above rule allows SSH access to the server using port 22 through the public zone. In addition, the rule is permanently saved in the firewall table using the --permanent option.
Allow another service port 80 through the firewall.
View the active Firewalld zone ports to verify the new rules.
Output:
Run the following command to allow a range of ports through the public Firewalld zone. For example, port 7000 to 7500 depending on your internal hosts.
View the list of available Firewalld services on your server.
Output:
Allow a service such as HTTPS for access through the public zone table.
Allow another service such as FTP through the public zone.
Reload Firewalld to apply the new service changes.
Output:
Allow incoming traffic to the SSH port 22 from your public server IP address 192.0.2.100.
Forward traffic from one port to another. For example, forward traffic from the internal port 8080 to the destination port 8900 through all IP addresses.
The above rule forwards all incoming requests on port 8080 to 8900 to securely expose a specific resource on different ports.
Reload Firewalld to save the zone changes.
Create a new Firewalld zone with a custom name such as example-zone.
Reload Firewalld to save changes.
View the Firewalld zones and verify that the new custom zone is available.
Output:
Firewalld panic mode blocks all incoming and outgoing network connections on the server to protect the system in case of security threats. When enabled, the server blocks all connections including your active SSH session. Follow the steps below to enable panic mode and troubleshoot the system in case of external threats or network failures.
View the Firewalld panic mode status.
Output:
Enable panic mode to block all network connections on the server.
View the Firewalld panic mode status and verify that it's active.
Output:
In case Firewalld blocks your SSH session, access your instance page in the Vultr Console and use the Vultr Console to start a new server terminal session.
You have set up firewall policies using Firewalld on a Vultr Cloud Server and configured multiple rules to filter network connections using zone profiles. Firewalld uses zones, services, ports, and custom rules as the major firewall configuration options to filter network traffic on a server. To manually modify the Firewalld configurations, navigate to the /etc/firewalld application data directory. For more information, visit the application manual page using the man firewalld command.
0 Comments
Be the first to comment and share your perspective with the community.