Enable, disable, and open specified ports for CentOS 6.2 Firewall

Source: Internet
Author: User

Enable, disable, and open the specified port of the CentOS 6.2 firewall. d/iptables stop: View 114 again at www.2cto.com. 80. *. *: 8080 (ip: 8080) was successful. However, it seems that security risks are greatly increased ...... Use/etc/init. d/iptables status to view the firewall information. The opened port is displayed. It is feasible to open the port to be used. The command is as follows: /sbin/iptables-I INPUT-p tcp -- dport 8080-j ACCEPT #8080 indicates the specified port/etc/rc. d/init. d/iptables save # save the changes/etc/init. d/iptables restart # restart the firewall to make the change take effect. Of course, if you don't feel any trouble, restart the system (command: reboot). Of course, in addition, add a line directly in/etc/sysconfig/iptables: -A RH-Firewall-1-INPUT-p tcp-m state -- state NEW-m tcp -- dport 8080-j ACCEPT summary about CentOS firewall (for other Linux distributions, see) view Firewall Information/etc/init. d/iptables status: Enable the specified port /Sbin/iptables-I INPUT-p tcp -- dport 8080-j ACCEPT/etc/rc. d/init. d/iptables save or edit/etc/sysconfig/iptables to Add rows: -A RH-Firewall-1-INPUT-p tcp-m state -- state NEW-m tcp -- dport 80-j ACCEPT # can also be changed using-I INPUT-p tcp -- dport 8080-j ACCEPT firewall effective/etc/init. d/iptables restart # It is not recommended to restart the system to disable the Firewall Service/etc/init. d/iptables stop permanently disable the firewall chkconfig-level 35 iptables off # This method is from the network and has not been tested. Therefore, you are not allowed to use this method for security reasons: www.2cto.com -------------------------- When we use the CentOS system, the CentOS firewall sometimes needs to change the settings. The CentOS firewall is enabled by default. You can set the open port of the CentOS firewall as follows: Open the iptables configuration file vi/etc/sysconfig/iptables to modify the CentOS Firewall: be sure to leave a path for yourself and leave a VNC Management port and an SSh Management port. The following is an example of iptables: # Firewall configuration written by system-config-securitylevel # Manual customization of this file is not recommended. * filter: input accept [0: 0]: forward accept [0: 0]: output accept [0: 0]: RH-Firewall-1-INPUT-[0: 0]-a input-j RH-Firewall-1-INPUT-A FORWARD-j RH-Firewall-1-INPUT-A RH-Firewall-1-INPUT-I lo-j ACCEPT-A RH-Firewall-1-INPUT ACCEPT-A-p icmp-type any-j RH-Firewall-1-INPUT ACCEPT-A RH-Firewall-1-INPUT-p 50-j ACCEPT-A RH-Firewall-1-INPUT-p 51-j-m state-state ESTABLISHED, RELATED-j ACCEPT-A RH-Firewall-1-INPUT-m state-state NEW-m tcp-p tcp-dport 53-j ACCEPT-A RH-Firewall-1-INPUT-m state-state NEW-m udp-p udp-dport 53 -J ACCEPT-A RH-Firewall-1-INPUT-m state-state NEW-m tcp-p tcp-dport 22-j ACCEPT-A RH-Firewall-1-INPUT-m state-state NEW-m tcp-p tcp-dport 25-j ACCEPT-A RH-Firewall-1-INPUT-m state-state NEW-m tcp-p tcp-dport 80-j ACCEPT-A RH-Firewall-1-INPUT ACCEPT-A-m state-state NEW-m tcp-p tcp-dport 443-j RH-Firewall-1-INPUT -j REJECT-reject-with icmp-host-prohibitedCOMMIT required to modify CentOS Firewall Note that you must modify the file based on your server. For example, if you do not want to open port 80 to provide web services, delete the line accordingly: -A RH-Firewall-1-INPUT-m state-state NEW-m tcp-p tcp-dport 80-j ACCEPT all after modification restart iptables: service iptables restart: You can verify whether all the rules have taken effect: iptables-L. In this way, the settings of the CentOS firewall are modified.

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.