问题
应用程序从其他服务器收到“连接被拒绝”。
该应用程序可从 localhost 访问,并且它还侦听预期的端口。
之路教程 https://onitr oad .com
解决方案
这可能是本地服务器上的防火墙丢弃来自其他服务器的入站连接尝试的情况。
默认情况下,CentOS/RHEL 7 使用 FIREWARLD 服务来管理 IPTABLES 规则。
旧的 IPTABLES 子系统仍然可用,如果 FIREWARLD 服务被禁用,则可以直接使用。
确定是否正在使用 FIREWARLD 服务
要查看系统上的 firewalld 目标是否处于活动状态,请使用以下命令:
# systemctl status firewalld.service Dec 21 15:04:01 testserver firewalld[18880]: WARNING: beyond-scope: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time. Dec 21 15:04:01 testserver firewalld[18880]: WARNING: ICMP type 'failed-policy' is not supported by the kernel for ipv6. Dec 21 15:04:01 testserver firewalld[18880]: WARNING: failed-policy: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time. Dec 21 15:04:01 testserver firewalld[18880]: WARNING: ICMP type 'reject-route' is not supported by the kernel for ipv6. Dec 21 15:04:01 testserver firewalld[18880]: WARNING: reject-route: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time.
从上面的输出中可以看出,firewalld 服务处于活动状态并正在运行。
确定是否正在使用 IPTABLES 服务
要确定系统上是否正在运行 iptables 服务,请使用以下命令。
# systemctl status iptables.service Dec 21 17:51:12 testserver systemd[1]: Starting IPv4 firewall with iptables... Dec 21 17:51:12 testserver iptables.init[440]: iptables: Applying firewall rules: [ OK ] Dec 21 17:51:12 testserver systemd[1]: Started IPv4 firewall with iptables.
从上面的输出可以看出,iptables 目标处于禁用状态。
在 CentOS/RHEL 7 之前,使用 iptables 命令检查系统防火墙足以知道是否正在使用防火墙。
例如,检查以下命令足以确定如何控制防火墙规则:
# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT udp -- anywhere anywhere udp dpt:domain ACCEPT tcp -- anywhere anywhere tcp dpt:domain ... INPUT_direct all -- anywhere anywhere INPUT_ZONES_SOURCE all -- anywhere anywhere INPUT_ZONES all -- anywhere anywhere DROP all -- anywhere anywhere ctstate INVALID REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
在 CentOS/RHEL 7 中,新的 FIREWARLD 服务或者旧的 IPTABLES-SERVICE 都可以控制防火墙规则。
日期:2020-09-17 00:13:00 来源:oir作者:oir