GNU/Linux >> Tutoriales Linux >  >> Cent OS

Aplicación de servidor Obteniendo "conexión rechazada" de servidores remotos [debido a firewalld o iptables] – CentOS/RHEL 7

El problema

Una aplicación está recibiendo "conexión rechazada" de otros servidores. Se puede acceder a la aplicación desde localhost y también escucha el puerto esperado.

La solución

El cortafuegos en el servidor local está eliminando los intentos de conexión entrantes de otros servidores.

Nota :De manera predeterminada, CentOS/RHEL 7 usa el servicio FIREWALLD para administrar las reglas de IPTABLES. El subsistema IPTABLES anterior todavía está disponible y se puede usar directamente si el servicio FIREWALLD está deshabilitado.

1. Determine si se está utilizando el servicio FIREWALLD.

# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since Thu 2017-12-21 15:03:59 EST; 4s ago 
Docs: man:firewalld(1)
Main PID: 18880 (firewalld)
CGroup: /system.slice/firewalld.service
└─18880 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Dec 21 15:03:58 testserver systemd[1]: Starting firewalld - dynamic firewall daemon...
Dec 21 15:03:59 testserver systemd[1]: Started firewalld - dynamic firewall daemon.
Dec 21 15:04:01 testserver firewalld[18880]: WARNING: ICMP type 'beyond-scope' is not supported by the kernel for ipv6.
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.

2. Determine si se está utilizando el servicio IPTABLES.

# systemctl status iptables.service
* iptables.service - IPv4 firewall with iptables
Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)
Active: active (exited) since Thu 2017-12-21 17:51:12 UTC; 26min ago 
Process: 440 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)
Main PID: 440 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/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.
Precaución :verificar el firewall usando "iptables -L" no es suficiente.

3. Antes de CentOS/RHEL 7, bastaba con comprobar el cortafuegos del sistema mediante el comando iptables para saber si se estaba utilizando un cortafuegos. Por ejemplo, consultando con:

# 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

fue suficiente para determinar cómo controlar las reglas del firewall. Con CentOS/RHEL 7, el servicio FIREWALLD más reciente o el SERVICIO IPTABLES más antiguo podrían controlar las reglas del firewall. Por lo tanto, ambos deben verificarse para estar seguros.


Cent OS
  1. CentOS/RHEL 7:¿Cómo abrir un puerto en el firewall con firewall-cmd?

  2. CentOS / RHEL 7:Cómo abrir el puerto de Firewall para el servidor Samba usando FirewallD

  3. Solución de problemas de "conexión rechazada" desde servidores remotos en CentOS/RHEL 7 (ya sea un problema de servicio de Firewalld o iptables)

  4. “-bash:firewall:comando no encontrado” – Cómo resolver en CentOS/RHEL 7

  5. Cómo cambiar la zona horaria de CST a EST en el servidor CentOS/RHEL 7

Cómo detener/iniciar el firewall en RHEL 8 / CentOS 8

Instale Nginx en CentOS 7 / RHEL 7

CentOS 8:configuración inicial del servidor

Cómo instalar varios servidores CentOS/RHEL utilizando fuentes de red FTP

"El servidor se negó a asignar pty":no se puede iniciar sesión en CentOS/RHEL

Cómo deshabilitar el servidor VNC de Xinetd en CentOS/RHEL 7