How to configure CentOSiptables firewall

Source: Internet
Author: User
CentOS (communitypoliciseoperatingsystem) is one of the Linux releases. when we use CentOS, we recommend that you configure an iptables. iptables is an IP information package filtering system integrated with the Linux kernel of the latest 2.6.x version. very easy to use. Next I will teach you how to configure iptables firewall in CentOS.

It is necessary to configure the iptables firewall in CentOS. Let's learn how to configure it!

Set the firewall in Linux. take CentOS as an example to open the iptables configuration file:


Vi/etc/sysconfig/iptables

Run the/etc/init. d/iptables status command to check whether port 80 is enabled. if port 80 is not enabled, you can use either of the following methods:

1. modify the vi/etc/sysconfig/iptables command to add the firewall to open port 80


-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT

2. Disable/enable/restart the firewall


/Etc/init. d/iptables stop # start enabled # restart
3. permanently disable the firewall


Chkconfig -- level 35 iptables off/etc/init. d/iptables stop iptables-P INPUT DROP

4. enable port 21 in active mode


Iptables-a input-p tcp -- dport 21-j ACCEPT
5. enable passive mode 49152 ~ Port 65534


Iptables-a input-p tcp -- dport 49152: 65534-j ACCEPT iptables-a input-I lo-j ACCEPT iptables-A INPUT-m state -- state ESTABLISHED-j ACCEPT

Note:

Be sure to leave a path for yourself and leave a VNC management port and an SSh management port.

You must modify the file based on your server.

After all the modifications, restart iptables:

Service iptables restart

You can verify whether all rules have taken effect:

Iptables-L

Through the introduction of this article, we have clearly understood the process of configuring iptables firewall in CentOS. I hope everyone can master it!

 

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.