Centos7 close firewalld and open iptables

Introduction

       Centos 7 is basically the current mainstream system. After all, many middlewares need high version support, but the default firewalld is estimated that many people are not used to it (at least I am not used to it), so I have to find a way to continue using the original iptables Yeah!

ps: There is no essential difference between firewalld and iptables, but the encapsulation syntax is different, so there is no need to talk about performance, protection capabilities, the bottom layer is similar, there is no difference, it depends on your personal habits or

The first step: kill firewalld

[root@mt ~]# systemctl stop firewalld  ##停止防火墙 firewalld
[root@mt ~]# systemctl disable firewalld  ##禁用防火墙 firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[root@mt ~]# systemctl status firewalld  ##查看防火墙状态
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Easily kill, ban the boot, the first step is completed

Step 2: Enable iptables

[root@mt ~]# yum install -y iptables-services iptables-devel.x86_64 iptables.x86_64 
[root@mt ~]# systemctl enable iptables  ##启用iptables
Created symlink from /etc/systemd/system/basic.target.wants/iptables.service to /usr/lib/systemd/system/iptables.service.
[root@mt ~]# systemctl start iptables  ##启动iptables

[root@mt ~]# systemctl status iptables  ##查看iptables状态
● iptables.service - IPv4 firewall with iptables
   Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)
   Active: active (exited) since 三 2020-10-28 13:39:40 CST; 3 weeks 2 days ago
 Main PID: 4625 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/iptables.service

10月 28 13:39:40 center systemd[1]: Starting IPv4 firewall with iptables...
10月 28 13:39:40 center iptables.init[4625]: iptables: Applying firewall rules: [  OK  ]
10月 28 13:39:40 center systemd[1]: Started IPv4 firewall with iptables.

PS: Centos7 default /etc/rc.local is not effective, try to use systemctl for management

The second part is complete, Job Done!

to sum up

There is not much difference between the two. In fact, the firewalld syntax is very straightforward. It looks more intuitive than the four tables and five chains of iptables.

Guess you like

Origin blog.51cto.com/14839701/2552856