Fading Coder

One Final Commit for the Last Sprint

Home > Notes > Content

Firewall Rule Management Across CentOS and Ubuntu Environments

Notes May 10 45

Network traffic filtering on RHEL-based distributions is handled by firewalld, which organizes rules into zones and requires explicit synchronization between permanent and runtime configurations.

Verify the daemon's current state:

systemctl is-active firewalld

Initialize the service and configure it to launch automatically during system boot:

sudo systemctl enable --now firewalld

To expose a web application, assign the required TCP ports to the default zone and commit the changes. The configuration must be reloaded to activate persistent rules:

sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd --reload

Confirm the active zone settings:

sudo firewall-cmd --list-all

Debian-based platforms typically rely on ufw as a frontend for netfilter. Unlike firewalld, rule modifications are applied immediately to the kernel packet filter.

Inspect the current filter status and logging level:

sudo ufw status verbose

Activate the firewall framework:

sudo ufw enable

Establish a secure baseline by rejecting unsolicited inbound connections while permitting all outbound requests:

sudo ufw default deny incoming
sudo ufw default allow outgoing

Permit remote administration by explicitly allowing TCP traffic on the standard SSH port:

sudo ufw allow proto tcp to any port 22

Validate the updated rule chain:

sudo ufw status numbered

Related Articles

Designing Alertmanager Templates for Prometheus Notifications

How to craft Alertmanager templates to format alert messages, improving clarity and presentation. Alertmanager uses Go’s text/template engine with additional helper functions. Alerting rules referenc...

Deploying a Maven Web Application to Tomcat 9 Using the Tomcat Manager

Tomcat 9 does not provide a dedicated Maven plugin. The Tomcat Manager interface, however, is backward-compatible, so the Tomcat 7 Maven Plugin can be used to deploy to Tomcat 9. This guide shows two...

Spring Boot MyBatis with Two MySQL DataSources Using Druid

Required dependencies application.properties: define two data sources and poooling Java configuration for both data sources MyBatis mappers for each data source Controller endpoints to verify both co...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.