Detailed Tutorial on Linux Server Firewall Configuration

Firewall is the first line of defense for server security, and proper configuration is essential.

Linux Firewall (firewalld):

Check Status:

systemctl status firewalld

Start the Firewall:

systemctl start firewalld
systemctl enable firewalld

View Open Ports:

firewall-cmd --list-ports

Open Ports:

firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --permanent --add-port=22/tcp

Close a Port:

firewall-cmd --permanent --remove-port=8080/tcp

Reload Configuration:

firewall-cmd --reload

Linux Firewall (iptables):

View Rules:

iptables -L -n

Open a Port:

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

Save Rules:

service iptables save
Was this answer helpful? 0 Users Found This Useful

Related Articles

Complete List of Common Linux Server Commands

Mastering common Linux commands is the foundation of server management. File and Directory...

Steps and methods for handling zombie processes on Linux cloud servers

In daily use of Linux cloud servers, many website owners will encounter processes with a state of...

What to do if the cloud server port is occupied due to Nginx configuration error?

In the process of deploying or modifying Nginx configuration, many users often overlook a key...

Setting up Two-Factor Authentication for Linux Server

Why Use 2FA on a Linux Server? Despite their strong security, SSH keys are not infallible,...

Troubleshooting Common Network Related Issues on Linux Servers

If you are running into this blog post, chances are you have a Linux based server that is...