networking - 如何在 centos 7 上使用 iptables?

标签 networking centos iptables systemd

<分区>


这个问题似乎不是关于 a specific programming problem, a software algorithm, or software tools primarily used by programmers 的.如果您认为这个问题是关于 another Stack Exchange site 的主题,您可以发表评论以说明问题可能在哪里得到解答。

关闭 4 年前

我安装了最低配置的 CentOS 7(操作系统 + 开发工具)。我正在尝试为 httpd 服务打开 80 端口,但是我的 iptables 服务出了点问题……它出了什么问题?我究竟做错了什么?

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

最佳答案

使用 RHEL 7/CentOS 7,firewalld被引入来管理 iptables。恕我直言,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

关于networking - 如何在 centos 7 上使用 iptables?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24756240/

上一篇:macos - VirtualBox:mount.vboxsf:安装失败,错误:没有这样的设备

下一篇:amazon-ec2 - EC2 增加大小后无法调整卷的大小

相关文章:

timeout - ip_conntrack_tcp_timeout_established 未应用于整个子网

spring-boot - Spring Boot、Debian、Embedded Tomcat 关闭外部端口

android - 玩具VPN : unable to settup vpn server and connecting to it also no rule is appearing the nat table

android - Android 后端支持的最佳实践

python - 路由器后面的服务器

java - 超时异常使用 JSCH 意外结束我的代码

linux - 为 perl 安装模块

c - 如何确保服务器在可能的情况下监听 IPv6 而在其他情况下监听 IPv4?

linux - TZ(时区)在 "/etc/crontab"中不起作用

nginx - 高负载下502网关错误(nginx/php-fpm)