How to Configure Centos 6 firewall (iptables)

Introduction


CentOS 6 uses iptables as system firewall.
We configure iptables in our default installation to drop all incoming traffic (including incoming traffic for routing) except for ICMP and TCP port 22 (SSH).

Please run iptables -nL to see current firewall rules.

Disabling firewall

To disable firewall perform one of the following:

1.  use text interface for basic firewall setup

system-config-firewall-tui

from system-config-firewall-tui package. Mark firewall as disabled, press Ok to save the changes.

2.  disable firewall service: to stop firewall service run

service iptables stop && service ip6tables stop
   
then to prevent firewall from starting on boot, if necessary run 


chkconfig iptables off && chkconfig ip6tables off

3. delete files /etc/sysconfig/ip6tables and /etc/sysconfig/iptables and to reload blank firewall configuration run 


service iptables restart && service ip6tables restart

To disable firewall only until first reboot run: 

iptables -F.

Configuring firewall

To configure firewall perform one of the following:

1. use text interface for basic firewall setup 

system-config-firewall-tui

from system-config-firewall-tui package. Mark firewall as enabled, press Customize, mark required services, add additional ports, etc. Follow program's interface instructions. Press Ok to save the changes.

2. edit /etc/sysconfig/iptables and /etc/sysconfig/ip6tables to add additional firewall rules. This requires firewall restart (service iptables restart && service ip6tables restart). For example, to allow HTTP incoming rule one should add the line below before the COMMIT line and restart firewall. 

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to reinstall OS (Linux or Windows) on supermicro with IPMI?

  OS Installation from Virtual Media - Login to your IPMI (you should have IP address of IPMI...

How to install cPanel/WHM on CentOS 7

Installation Requirements A clean fresh minimal installation of CentOS 7 server. Minimum of 1...

RHEL7; Boot, reboot, and shut down a system

Prerequisites Switch on a physical server or a virtual machine (in this case, type: # virsh...

Powered by WHMCompleteSolution