CentOS iptables Firewall Open 80-Port method

Source: Internet
Author: User
Tags centos iptables

Open ports:

The code is as follows Copy Code

[root@wx32 ~]# iptables-i input-p tcp--dport 80-j ACCEPT

Save configuration:

The code is as follows Copy Code

[root@wx32 ~]# Service Iptables Save
Saving firewall rules to/etc/sysconfig/iptables: [OK]

Reboot the firewall:

The code is as follows Copy Code

[root@wx32 ~]# Service iptables restart
Flushing firewall rules: [OK]
Setting chains to Policy Accept:filter [OK]
Unloading iptables modules: [OK]
Applying iptables firewall rules: [OK]
Loading additional iptables modules:ip_conntrack_netbios_n[OK]

To view the configuration:

The code is as follows Copy Code

[root@wx32 ~]# 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

Port View Method:

The code is as follows Copy Code

[Root@vcentos ~]#/etc/init.d/iptables Status

Table:filter

Chain INPUT (Policy ACCEPT)

Num Target prot opt source destination

1 ACCEPT UDP--0.0.0.0/0 0.0.0.0/0 UDP dpt:80

2 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 TCP dpt:80

3 Rh-firewall-1-input All--0.0.0.0/0 0.0.0.0/0

Chain FORWARD (Policy ACCEPT)

Num Target prot opt source destination

1 Rh-firewall-1-input All--0.0.0.0/0 0.0.0.0/0


Add:

View CentOS Firewall information:/etc/init.d/iptables status

Turn off the CentOS Firewall service:/etc/init.d/iptables stop

Check that the server's 80 port is blocked by the firewall, you can use the command: Telnet server_ip 80来 test.

The code is as follows Copy Code

1> The solution is as follows:

/sbin/iptables-i input-p TCP--dport 80-j ACCEPT

2> then Save:

/etc/rc.d/init.d/iptables Save

3> reboot the firewall

/etc/init.d/iptables restart

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.