CentOS 7.x开始,CentOS开始使用systemd服务来代替daemon,原来管理系统启动和管理系统服务的相关命令全部由systemctl命令来代替。service命令只保留下了极少部分使用,大部分命令都要改用systemctl使用。  

[root@localhost ~]# service iptables save
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

  关闭防火墙  

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl mask firewalld    ----注销服务
Created symlink from /etc/systemd/system/firewalld.service to /dev/null.

  安装iptables  

[root@localhost ~]# yum install iptables
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirror.bit.edu.cn
 * updates: mirrors.huaweicloud.com
Running transaction
  Updating   : iptables-1.4.21-34.el7.x86_64                                                        1/2 
  Cleanup    : iptables-1.4.21-18.0.1.el7.centos.x86_64                                             2/2 
  Verifying  : iptables-1.4.21-34.el7.x86_64                                                        1/2 
  Verifying  : iptables-1.4.21-18.0.1.el7.centos.x86_64                                             2/2 

Updated:
  iptables.x86_64 0:1.4.21-34.el7                                                                       

Complete!

  设置iptables开机启动  

[root@localhost ~]# systemctl enable iptables

  重启iptables服务

systemctl restart iptables.service 

  再次执行保存命令,成功

[root@localhost ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

 

posted on 2020-09-23 16:52  星痕1216  阅读(252)  评论(0编辑  收藏  举报