Enable port 80 access in CentOS firewall settings

Source: Internet
Author: User
To enable port 80 access in CentOS firewall settings, we add port 80 as an example: [root @ centoshttpd] #/sbin/iptables-IINPUT-ptcp -- the dport80-jACCEPT saves [root @ centoshttpd] #/etc/rc. d/init. d/iptablessaveiptables: set

Enable port 80 access in CentOS firewall settings

The following is an example of adding port 80:

[Root @ centos httpd] #/sbin/iptables-I INPUT-p tcp -- dport 80-j ACCEPT

Save

[Root @ centos httpd] #/etc/rc. d/init. d/iptables save

Iptables: save the firewall rules to/etc/sysconfig/iptables: [OK]

If the above steps are not complete, it may be that the iptables file uses include call.

Generally, this path is/etc/sysconfig/iptables.

Or use vi to open the file and modify it.

[Root @ centos httpd] # vi/etc/sysconfig/iptables

# Generated by iptables-save v1.4.7 on Tue Feb 14 07:32:18 2012
* Filter
: Input accept [0: 0]
: Forward accept [0: 0]
: Output accept [7: 640]
-A input-p tcp-m tcp -- dport 10000-j ACCEPT
-A input-p tcp-m tcp -- dport 80-j ACCEPT
-A input-m state -- state RELATED, ESTABLISHED-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-I lo-j ACCEPT
-A input-p tcp-m state -- state NEW-m tcp -- dport 22-j ACCEPT
-A input-j REJECT -- reject-with icmp-host-prohibited
-A forward-j REJECT -- reject-with icmp-host-prohibited
COMMIT
# Completed on Tue Feb 14 07:32:18 2012

Restart the service

[Root @ centos httpd] # service iptables restart
Iptables: clear firewall rules: [OK]
Iptables: Set the chain to policy ACCEPT: filter [OK]
Iptables: uninstalling module: [OK]
Iptables: application firewall rules: [OK]

Check whether the port is effective:

[Root @ centos httpd] #/etc/init. d/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: 10000
2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt: 80
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,
4 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
5 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
6 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp
7 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with ic

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 ic

Chain OUTPUT (policy ACCEPT)
Num target prot opt source destination

Original from [wind letter network], reprinted please retain the original link: http://www.ithov.com/linux/112523.shtml

Related Article

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.