How to open a specified port using iptables on CentOS

Source: Internet
Author: User
A server that can be written in python can be found to be normal during testing on Ubuntu14.04.3. However, after setting up the environment on CentOS6.3, it is found that the http requests to specific ports, such as 8000, cannot be accessed, it's hard to explain. At last, we found that the firewall blocked access to special ports. The development port on the current host is as follows: using iptables to open the following ports/sbin/iptables-I can be written in python on servers tested on Ubuntu 14.04.3, it is normal, but after setting up the environment on CentOS 6.3, it is found that for specific ports, for example, 8000 of http requests cannot be accessed. At last, we found that the firewall blocked access to special ports.

The development port on the current host is as follows:

The following describes how to open a specific Port:
Use iptables to open the following ports:
/Sbin/iptables-I INPUT-p tcp -- dport 8000-j ACCEPT
/Sbin/iptables-I INPUT-p tcp -- dport 8090-j ACCEPT
/Sbin/iptables-I INPUT-p tcp -- dport 10000-j ACCEPT
/Sbin/iptables-I INPUT-p tcp -- dport 12000-j ACCEPT
Save
/Etc/rc. d/init. d/iptables save
Restart service
Service iptables restart
Check whether the port to be opened takes effect?

/Etc/init. d/iptables status

It can be seen that our requirements are met.

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.