GNU/Linux >> Linux Esercitazione >  >> Cent OS

Risoluzione dei problemi di "connessione rifiutata" da server remoti in CentOS/RHEL 7 (problema del servizio Firewalld o iptables)

Il problema

Un'applicazione riceve la "connessione rifiutata" da altri server. L'applicazione è accessibile da localhost e ascolta anche la porta prevista.

La soluzione

Questo potrebbe essere un caso in cui Firewall sul server locale interrompe i tentativi di connessione in entrata da altri server. Per impostazione predefinita, CentOS/RHEL 7 utilizza il servizio FIREWALLD per gestire le regole IPTABLES. Il vecchio sottosistema IPTABLES è ancora disponibile e può essere utilizzato direttamente se il servizio FIREWALLD è disabilitato.

Determina se viene utilizzato il servizio FIREWALLD

Per vedere se la destinazione firewalld è attiva sul sistema, utilizzare il comando seguente:

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

Come puoi vedere dall'output sopra, il servizio firewalld è attivo e in esecuzione.

Determina se viene utilizzato il servizio IPTABLES

Per determinare se il servizio iptables è in esecuzione sul sistema, utilizzare il comando seguente.

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

Come si vede dall'output sopra, la destinazione di iptables è in stato disabilitato.

Attenzione :il controllo del firewall tramite “iptables -L” non è sufficiente.

Prima di CentOS/RHEL 7, il controllo del firewall di sistema utilizzando il comando iptables era sufficiente per sapere se veniva utilizzato un firewall. Ad esempio, il controllo con il comando seguente è stato sufficiente per determinare come controllare le regole del firewall:

# 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

Con CentOS/RHEL 7, il nuovo servizio FIREWALLD o il vecchio IPTABLES-SERVICE potrebbero controllare le regole del firewall.


Cent OS
  1. Installa desktop remoto xrdp su CentOS 6 / RHEL 6

  2. Come riavviare il servizio di rete su CentOS 8 o RHEL 8

  3. CentOS / RHEL 7:come passare a iptables da firewalld

  4. CentOS / RHEL 7:Guida per principianti a firewalld

  5. CentOS / RHEL 7:non eseguire mai il servizio iptables e il servizio FirewallD contemporaneamente!

RHEL 8 / CentOS 8 abilita il servizio ssh

5 strumenti per abilitare l'accesso al desktop remoto su RHEL/CentOS 7

Risoluzione dei problemi di kdump in CentOS/RHEL

Come migrare le regole di CentOS/RHEL 6 iptables su CentOS/RHEL 7 firewalld

Come consentire tutto il traffico da un server utilizzando firewalld in CentOS/RHEL

Problema durante l'apertura di una porta Firewalld in CentOS/RHEL 8