CentOS 7 干掉了iptables 改用 firewalld ,默认的 /etc/sysconfig/iptables 是没有的,可以通过以下办法停用 firewalld ,启用 iptables 。
linux 保存防火墙服务提示:
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload,force-reload, status)
出现该提示表示缺少 iptables 文件。
ps:对于 RHEL 7 / CentOS 7,用 firewalld 来管理 iptables / IMHO / firewalld 是比较合适方便的。
1、停止防火墙「firewalld」
安装 iptables 前,需要先停止 firewalld ,否则会打架,导致安装失败。
- systemctl stop firewalld
- systemctl mask firewalld
2、安装 iptables
- yum install iptables-services
3、添加 iptables 到开机启动
- systemctl enable iptables
3.1、管理 iptables 命令
通过 systemctl 或者 service 来管理。
- systemctl [stop停止|start启动|restart重启] iptables
- service iptables start|stop|restart
4、改回使用 firewalld
如果不想用 iptables 了,想改回 firewalld 。可以通过以下命令。
停止 iptables
- systemctl stop iptables
移除 iptables 自启动
- systemctl disable
反屏蔽 firewalld
- systemctl unmask firewalld
启动 firewalld
- systemctl start firewalld
完毕!
参考
http://blog.csdn.net/allenmyth/article/details/41410799