Open a specific port (iptables) to the CentOS firewall)
Source: Internet
Author: User
Iptables is the firewall and service name in linux. Serviceiptablesstatus view the firewall status serviceiptablesstart enable firewall iptables is the firewall in linux, and it is also the service name. 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: -A RH-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.
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.