CentOS / Redhat Iptables Firewall Configuration Tutorial

CentOS / Redhat Iptables Firewall Configuration Tutorial

Iptables is a firewall management tool that is commonly used on CentOS and Red Hat Linux systems. Iptables allows you to configure rules that control incoming and outgoing traffic on your system.

Here are the basic steps to configure iptables on a CentOS or Red Hat Linux system:

  1. Start by listing the current iptables rules using the iptables command:
ref‮e‬r to:lautturi.com
iptables -L

This will show you the current rules that are applied to the system.

  1. To add a new rule to the iptables firewall, use the iptables command with the -A option. For example, to allow incoming traffic on port 80 (HTTP), you can use the following command:
iptables -A INPUT -p tcp --dport 80 -j ACCEPT

This will allow incoming traffic on port 80 and pass it through to the system.

  1. To block incoming traffic on a specific port, you can use the REJECT target instead of ACCEPT. For example, to block incoming traffic on port 22 (SSH), you can use the following command:
iptables -A INPUT -p tcp --dport 22 -j REJECT
  1. To save the iptables rules, use the iptables-save command. For example:
iptables-save > /etc/sysconfig/iptables

This will save the iptables rules to the /etc/sysconfig/iptables file, so they will be applied on boot.

It's always a good idea to carefully review the documentation and use the appropriate commands to configure the iptables firewall on your system. This will help ensure that you have a secure and reliable firewall to protect your system.

Created Time:2017-10-27 14:56:37  Author:lautturi