How to set up a firewall using FirewallD on CentOS 8

How to set up a firewall using FirewallD on CentOS 8

To set up a firewall using FirewallD on CentOS 8, follow these steps:

  1. Install FirewallD:
ref‮:ot re‬lautturi.com
sudo dnf install firewalld
  1. Enable and start the FirewallD service:
sudo systemctl enable firewalld
sudo systemctl start firewalld
  1. To check the current firewall status, use the firewall-cmd command with the --state option:
firewall-cmd --state

This will show the current firewall status, which should be running.

  1. To allow incoming traffic on a specific port, use the --add-port option:
sudo firewall-cmd --add-port=22/tcp

This will allow incoming traffic on port 22 (SSH).

  1. To allow incoming traffic from a specific IP address or range, use the --add-source option:
sudo firewall-cmd --add-source=192.168.1.0/24

This will allow incoming traffic from IP addresses in the range 192.168.1.0 to 192.168.1.255.

  1. To make the changes permanent, use the --permanent option:
sudo firewall-cmd --permanent --add-port=22/tcp
sudo firewall-cmd --permanent --add-source=192.168.1.0/24
  1. To apply the permanent changes, use the --reload option:
sudo firewall-cmd --reload

You can use the firewall-cmd command to view the current firewall rules and make additional changes as needed. For more information, see the FirewallD documentation.

Created Time:2017-10-29 22:08:38  Author:lautturi