Open a specific port (iptables) to the CentOS Firewall)

Source: Internet
Author: User

Open a specific port (iptables) to the CentOS Firewall)
Iptables is the firewall and service name in linux.Service iptables status view Firewall status service iptables start Enable Firewall service iptables stop disable Firewall service iptables restart firewall open specific port: ① file/etc/sysconfig/iptables ② Add: -ARH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 8080-j ACCEPT in my centos6.5, you only need to enter the red part.★The number 8080 indicates that port 8080 is opened, or you can change it to another port.★③ Restart the Firewall
========================================================== =====================================Save settings for the firewall serivce iptables save view iptables rules and number iptables-nL -- line-number: Disable all input forward (forwarding) all OUTPUT ports iptables-p input DROPiptables-p forward DROPiptables-p output drop open only port 22 iptables-a input-p tcp -- dport 22-j ACCEPTiptables-a output-p tcp -- sport 22-j ACCEPT parameter description: -The A parameter is regarded as adding A rule-p to specify the protocol. We usually use tcp protocol. Of course, udp also exists. For example, the DNS-dport of port 53 is the target port, when the data enters from the external server as the target port-sport the data goes out of the server, if-j is used for the data source port, it is specified to be ACCEPT-receiving or DROP-not receiving. If an IP address is not allowed to access iptables-a input-p tcp-s 192.168.1.2-j DROP-s, the parameter is source (192.168.1.2) the DROP deletion rule iptables-d input 2 is used to delete the rule whose INPUT Chain number is 2.

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.