GNU/Linux >> Znalost Linux >  >> Cent OS

Serverová aplikace Získávání „připojení odmítnuto“ ze vzdálených serverů [kvůli firewallu nebo iptables] – CentOS/RHEL 7

Problém

Aplikace dostává „odmítnutí připojení“ z jiných serverů. Aplikace je přístupná z localhost a také naslouchá očekávanému portu.

Řešení

Firewall na místním serveru zahazuje pokusy o příchozí připojení z jiných serverů.

Poznámka :Ve výchozím nastavení používá CentOS/RHEL 7 službu FIREWALLD ke správě pravidel IPTABLES. Starší subsystém IPTABLES je stále dostupný a lze jej používat přímo, pokud je služba FIREWALLD zakázána.

1. Zjistěte, zda se používá služba 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. Zjistěte, zda se používá služba 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.
Pozor :kontrola firewallu pomocí „iptables -L“ nestačí.

3. Před CentOS/RHEL 7 stačila kontrola systémové brány firewall pomocí příkazu iptables, abyste zjistili, zda byla brána firewall používána. Například kontrola pomocí:

# 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

stačilo určit, jak ovládat pravidla brány firewall. S CentOS/RHEL 7 by mohla pravidla brány firewall řídit buď novější služba FIREWALLD, nebo starší služba IPTABLES-SERVICE. Obojí je tedy potřeba pro jistotu zkontrolovat.


Cent OS
  1. CentOS / RHEL 7 :Jak přepnout na iptables z firewalld

  2. CentOS / RHEL 7 :Jak otevřít port ve firewallu pomocí firewall-cmd?

  3. CentOS / RHEL 7 :Jak otevřít port firewallu pro server Samba pomocí FirewallD

  1. Rsyslog:Jak posílat soubory protokolu na vzdálený server v CentOS/RHEL 6,7

  2. Jak odeslat protokoly auditu na vzdálený server Rsyslog v CentOS/RHEL 6,7

  3. „-bash:firewall:příkaz nenalezen“ – Jak vyřešit v CentOS/RHEL 7

  1. Jak změnit časové pásmo z CST na EST na serveru CentOS/RHEL 7

  2. Jak povolit veškerý provoz ze serveru pomocí firewallu v CentOS/RHEL

  3. Nainstalujte MySQL 5.6 na CentOS 7 / RHEL 7