Centos6.4 under iptables firewall configuration

Source: Internet
Author: User
Tags iptables

Configure the Cento6.4 iptables firewall.


1. View firewall status

# Service Iptables Status
Or:

#/etc/init.d/iptables Status
Description: This method can also be manipulated below.


2. Turn off/ turn on/reboot the firewall

# service Iptables Stop
# service iptables start
# service Iptables restart

4. Permanently shut down the firewall

# chkconfig--level iptables off

Then reboot the system to make it effective:

# Shutdown-r Now


5. Set open 80 port access

> View firewall status First:

[Root@localhost nginx]# service iptables status

Table:filter
Chain INPUT (Policy ACCEPT)
Num Target prot opt source destination
1 ACCEPT All--0.0.0.0/0 0.0.0.0/0 State related,established
2 ACCEPT ICMP--0.0.0.0/0 0.0.0.0/0
3 ACCEPT All--0.0.0.0/0 0.0.0.0/0
4 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 state NEW TCP dpt:22
5 REJECT All--0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited


Chain FORWARD (Policy ACCEPT)
Num Target prot opt source destination
1 REJECT All--0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited


Chain OUTPUT (Policy ACCEPT)
Num Target prot opt source destination


> Set 80 port (or manually modify/etc/sysconfig/iptables)

[Root@localhost ~]#/sbin/iptables-i input-p tcp--dport 80-j ACCEPT
You have new mail in/var/spool/mail/root

> Save Settings

[Root@localhost ~]#/etc/rc.d/init.d/iptables Save
iptables:saving firewall rules to/etc/sysconfig/iptables: [OK]


> View firewall status again

[Root@localhost ~]# service iptables status
Table:filter
Chain INPUT (Policy ACCEPT)
Num Target prot opt source destination
1 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 TCP dpt:80
2 ACCEPT All--0.0.0.0/0 0.0.0.0/0 State related,established
3 ACCEPT ICMP--0.0.0.0/0 0.0.0.0/0
4 ACCEPT All--0.0.0.0/0 0.0.0.0/0
5 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 state NEW TCP dpt:22
6 REJECT All--0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited


Chain FORWARD (Policy ACCEPT)
Num Target prot opt source destination
1 REJECT All--0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited


Chain OUTPUT (Policy ACCEPT)
Num Target prot opt source destination

> Set 80 Port--Modify/etc/sysconfig/iptables configuration file

[Root@localhost ~]# Vi/etc/sysconfig/iptables
# Add the following content
-A input-p tcp-m State--state new-m TCP--dport 80-j ACCEPT
Finally reboot the firewall for the configuration to take effect.


--------------------------------------------------------------------------------------------------------------- ----------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.