解決service iptables save出錯please try to use systemctl.

# 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.

出錯信息如上所示

本人原來使用的是CentOS6.X版本的Linux,後來爲了學習更多內容選擇更換CentOS7.X,然後在配置防火牆的時候出現了上面所示的錯誤,原因:CentOS 7.x開始,CentOS開始使用systemd服務來代替daemon,原來管理系統啓動和管理系統服務的相關命令全部由systemctl命令來代替。service命令只保留下了極少部分使用,大部分命令都要改用systemctl使用。

在RHEL 7 / CentOS 7中,firewalld被引入來管理iptables。個人覺得, firewalld更適合於工作站而不是服務器環境。
可以回到更經典的iptables設置來解決上面的問題

下面就談談上面錯誤的解決方案。

首先停止防火牆

1.systemctl stop firewalld

2.systemctl mask firewalld

然後安裝iptables-services

3.yum install iptables-services

設置開機啓動防火牆

4.systemctl enable iptables

可以使用下面命令管理iptables

5.systemctl [stop|start|restart] iptables

這時可以保存防火牆規則了

6.service iptables save
or
/usr/libexec/iptables/iptables.init save
問題就解決了,至於需不需要sudo權限,根據具體環境而定
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章