• 解决service iptables save出错please try to use systemctl.


    [html] view plain copy
     
    1. # service iptables save  
    2. 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.  

    出错信息如上所示

    本人原来使用的是CentOS6.X版本的Linux,后来为了学习更多内容选择更换CentOS7.X,然后在配置防火墙的时候出现了上面所示的错误,原因:CentOS 7.x开始,CentOS开始使用systemd服务来代替daemon,原来管理系统启动和管理系统服务的相关命令全部由systemctl命令来代替。service命令只保留下了极少部分使用,大部分命令都要改用systemctl使用。

    在RHEL 7 / CentOS 7中,firewalld被引入来管理iptables。个人觉得, firewalld更适合于工作站而不是服务器环境。
    可以回到更经典的iptables设置来解决上面的问题

    下面就谈谈上面错误的解决方案。

    首先停止防火墙

    [html] view plain copy
     
    1. 1.systemctl stop firewalld  
    [html] view plain copy
     
    1. 2.systemctl mask firewalld  

    然后安装iptables-services

    [html] view plain copy
     
    1. 3.yum install iptables-services  

    设置开机启动防火墙

    [html] view plain copy
     
    1. 4.systemctl enable iptables  

    可以使用下面命令管理iptables

    [html] view plain copy
     
    1. 5.systemctl [stop|start|restart] iptables  

    这时可以保存防火墙规则了

    [html] view plain copy
     
    1. 6.service iptables save  
    2. or  
    3. /usr/libexec/iptables/iptables.init save  
    问题就解决了,至于需不需要sudo权限,根据具体环境而定
  • 相关阅读:
    Apple Tree(树状数组+线段树)
    平衡阵容(RMQ st表算法)
    一起去打CS
    夜归

    淋雨
    大马戏
    雨中行船
    弄堂里
    夜游天安门
  • 原文地址:https://www.cnblogs.com/xiaofengfeng/p/9171516.html
Copyright © 2020-2023  润新知