如何在centos 7上使用iptables? [英] How can i use iptables on centos 7?
问题描述
我使用最少的配置(os +开发工具)安装了CentOS 7。我试图打开80端口 httpd
服务,但是我的iptables服务出了什么问题呢?我做错了什么?
#ifconfig / sbin / service iptables save
bash:ifconfig / sbin / service:没有这样的文件或目录
#/ sbin / service iptables save
service命令仅支持基本的LSB动作(start,stop,restart,try-restart,reload,force-reload,status)。对于其他操作,请尝试使用systemctl。
#sudo service iptables status
重定向到/ bin / systemctl status iptables.service
iptables.service
加载:not-found(原因:没有这样的文件或目录)
活动:非活动(死)
#/ sbin / service iptables save
服务命令仅支持基本LSB操作(启动,停止,重新启动,重新加载,强制重新加载,状态)。对于其他操作,请尝试使用systemctl。
#sudo service iptables start
重定向到/ bin / systemctl start iptables.service
无法发出方法调用:Unit iptables.service无法加载:没有这样的文件或目录。使用RHEL 7 / CentOS 7, https://fedoraproject.org/wiki/FirewallD\"> firewalld
被介绍来管理iptables。 IMHO,firewalld更适合工作站而不是服务器环境。
可以回到一个更经典的iptables设置。首先,停止并屏蔽firewalld服务:
systemctl stop firewalld
systemctl mask firewalld
然后,安装iptables-services软件包:
yum install iptables-services
在启动时启用服务:
systemctl enable iptables
管理服务
systemctl [stop | start | restart] iptables
保存防火墙规则的操作方式如下:
service iptables save
或
/usr/libexec/iptables/iptables.init save
I installed CentOS 7 with minimal configuration (os + dev tools). I am trying to open 80 port for httpd
service, but something wrong with my iptables service ... what's wrong with it? What am I doing wrong?
# ifconfig/sbin/service iptables save
bash: ifconfig/sbin/service: No such file or directory
# /sbin/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.
# sudo service iptables status
Redirecting to /bin/systemctl status iptables.service
iptables.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
# /sbin/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.
# sudo service iptables start
Redirecting to /bin/systemctl start iptables.service
Failed to issue method call: Unit iptables.service failed to load: No such file or directory.
解决方案 With RHEL 7 / CentOS 7, firewalld was introduced to manage iptables. IMHO, firewalld is more suited for workstations than for server environments.
It is possible to go back to a more classic iptables setup. First, stop and mask the firewalld service:
systemctl stop firewalld
systemctl mask firewalld
Then, install the iptables-services package:
yum install iptables-services
Enable the service at boot-time:
systemctl enable iptables
Managing the service
systemctl [stop|start|restart] iptables
Saving your firewall rules can be done as follows:
service iptables save
or
/usr/libexec/iptables/iptables.init save
这篇关于如何在centos 7上使用iptables?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!