How to Configure a CentOS Firewall

How to Configure a CentOS Firewall thumbnail
You can configure the CentOS software firewall for your personal needs.

The CentOS distribution of the Linux operating system includes a built-in software firewall. A combination of iptables (the user control interface) and netfilter (the kernel module that actually does the filtering) allows the system administrator to specify which packets should be dropped and which ones should be allowed to go through the network interface. You can call iptables with the appropriate parameters to configure your CentOS firewall.

Instructions

    • 1

      Press "Control-Alt-F1" to bring up a text console with the login prompt, then log in to the computer using your regular account.

    • 2

      Type the following command:

      sudo -i

      Press "Enter," then type your password and press "Enter" again. The command prompt will now have superuser privileges.

    • 3

      Type the following command to initialize the set of rules being followed by the CentOS firewall:

      iptables -F

      Press "Enter."

    • 4

      Specify the default policies for incoming, outgoing and forwarded packets by typing the following commands:

      iptables -P INPUT DROP

      iptables -P FORWARD DROP

      iptables -P OUTPUT ACCEPT

      Press "Enter" after each line.

    • 5

      Specify a class of incoming packets that should be accepted (as the INPUT chain drops all packets unless they match a rule whitelisting them), as in the following sample command:

      iptables -A INPUT -s 192.168.30.1 -j ACCEPT

      The example accepts all packets coming from a trusted Internet Protocol (IP) address; replace "192.168.30.1" with the sender's address of your choice. Press "Enter."

    • 6

      Repeat Step 5 for each class of packets you want to accept. At the end of this process, the CentOS firewall will have been completely configured.

Related Searches:

References

  • Photo Credit Thinkstock Images/Comstock/Getty Images

Comments

Related Ads

Featured