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, pressCustomize, 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 

  • 4 Users Found This Useful
Was this answer helpful?

Related Articles

Send any Linux Command output via E-mail

Create a script file with below syntax : command > file.tmp mailx -s "Subject" mailaddress...

How to Cache or copy a website?

Full website contents can be copied with wget command with below options :wget \--recursive...

How to resize volumes with LVM?

Quick tips: To see the details of logical volume group use: vgdisplay To see the details of...

Install Fedena on CentOS

Installing Fedena on Centos is a bit tricky since most of the stack used to run fedena is not...

KVM create and restore a full backup (Disk Image)

Making a backupBoot the system rescue cd ISO and follow the directions until you get to a...

Powered by WHMCompleteSolution