Set up a centos firewall open port

Source: Internet
Author: User

When we use the CentOS system, the CentOS firewall sometimes needs to change the settings. The CentOS firewall is turned on by default, and the installation of the CentOS firewall open port method is as follows:

To open the Iptables configuration file:
Vi/etc/sysconfig/iptables
When modifying the CentOS Firewall Note: Be sure to leave a good posterior for yourself. A management port and SSH management port

The following is an example of a iptables:

# Firewall configuration written by System-config-securitylevel
# Manual Customization of this file are 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-p icmp–icmp-type any-j ACCEPT
-A rh-firewall-1-input-p 50-j ACCEPT
-A rh-firewall-1-input-p 51-j ACCEPT
-A rh-firewall-1-input-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-m state–state new-m tcp-p tcp–dport 443-j ACCEPT
-A rh-firewall-1-input-j Reject–reject-with icmp-host-prohibited
COMMIT

To modify the CentOS firewall, be aware that you have to modify the file according to your server's situation.

For example, if you do not want to open the 80 port to provide Web services, then you should delete this line accordingly:
-A rh-firewall-1-input-m state–state new-m tcp-p tcp–dport 80-j ACCEPT

Restart iptables after all modifications are completed:
Service Iptables Restart

You can verify that the rules are in effect: iptables-l

In this way, we have completed the setup modification of the CentOS firewall.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Set up a centos firewall open port

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.