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!