Previous class
Firewall Setup
You can use the Uncomplicated Firewall (UFW) to manage your firewall rules in a more user-friendly way.
First Install UFW
sudo apt install ufw
To allow traffic on specific ports with UFW, you can use the allow
command followed by the port number.
Here are the steps:
- First, allow traffic on the SSH port (7822 in your case): (To avoid your Terminal Disconnecting)
sudo ufw allow 7822
- Then allow traffic on port 80 (HTTP) and 443 (HTTPS):
sudo ufw allow 80 sudo ufw allow 443
- Enable the firewall:
sudo ufw enable
- You'll be asked to confirm because this might disrupt existing SSH connections. However, since you've already allowed your SSH port (7822), your current session should not be interrupted.
- Check the status of UFW:
sudo ufw status
- The output will show you the current rules set up in UFW. You should see that traffic on ports 7822, 80, and 443 is allowed.
Please make sure to replace 7822
with your actual SSH port if it's different. If you have any questions or encounter any issues, feel free to ask.
AlmaLinux Use
sudo dnf install firewalld
- Start and enable
firewalld
:
sudo systemctl start firewalld sudo systemctl enable firewalld
- Check the status to make sure it's active:
sudo systemctl status firewalld
From here, you can use the
firewall-cmd
utility to manage your firewall rules. For example:
- To list all rules:
sudo firewall-cmd --list-all
- To allow a service (e.g., http):
sudo firewall-cmd --add-service=http --permanent
followed bysudo firewall-cmd --reload
to apply changes.
If you're more comfortable with
ufw
, you'd need to find a third-party repository or manually install it. However,
firewalld
is a capable tool and is well-integrated with AlmaLinux and similar distributions.
Next class