Centos7 禁止firewalld並使用iptables 作默認防火牆


一、停止並禁用firewalld

[root@test ~]# systemctl stop firewalld
[root@test ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

二、查看iptables 列表,並安裝service 軟件

[root@test ~]# yum list all iptables*
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.neusoft.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.sina.cn
已安裝的軟件包
iptables.x86_64                                   1.4.21-16.el7                           @base
可安裝的軟件包
iptables.i686                                     1.4.21-16.el7                           base 
iptables-devel.i686                               1.4.21-16.el7                           base 
iptables-devel.x86_64                             1.4.21-16.el7                           base 
iptables-services.x86_64                          1.4.21-16.el7                           base 
iptables-utils.x86_64                             1.4.21-16.el7                           base 

安裝service

[root@test ~]# yum install iptablesyum install iptables-services.x86_64 -y

 

三、啟動iptables服務,並檢查狀態

[root@test ~]# systemctl start iptables
[root@test ~]# systemctl status iptables
● iptables.service - IPv4 firewall with iptables
   Loaded: loaded (/usr/lib/systemd/system/iptables.service; disabled; vendor preset: disabled)
   Active: active (exited) since 五 2016-08-05 07:54:57 CST; 9s ago
  Process: 8164 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)
 Main PID: 8164 (code=exited, status=0/SUCCESS)

8月 05 07:54:56 test systemd[1]: Starting IPv4 firewall with iptables...
8月 05 07:54:57 test iptables.init[8164]: iptables: Applying firewall rules: [  OK  ]
8月 05 07:54:57 test systemd[1]: Started IPv4 firewall with iptables.

四、加入開機自啟動

[root@test ~]# systemctl enable iptables
Created symlink from /etc/systemd/system/basic.target.wants/iptables.service to /usr/lib/systemd/system/iptables.service.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM