Debian9 Apache2 - iptables INPUT Problem

Einrichten des lokalen Netzes, Verbindung zu anderen Computern und Diensten.
Antworten
linuxxxxx
Beiträge: 1
Registriert: 04.05.2019 18:39:14

Debian9 Apache2 - iptables INPUT Problem

Beitrag von linuxxxxx » 04.05.2019 18:46:31

Guten Tag,

ich habe einen Debian 9 Server mit Webserver Apache2. Der Server hat eine routbare Adresse, jedoch schaffe ich es nicht die richtige INPUT-Regel in iptables einzubauen. Meines Erachtens sollte diese Regel funktionieren:

iptables -A INPUT -p tcp -m multiport --dports 80,443 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT

Tut Sie aber nicht... Was kann ich tun?

Hier meine iptables Rules:

#iptables -L | more
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
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
ACCEPT tcp -- anywhere anywhere multiport dports http,https ctstate NEW,ESTABLISHED

Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
FORWARD_direct all -- anywhere anywhere
FORWARD_IN_ZONES_SOURCE all -- anywhere anywhere
FORWARD_IN_ZONES all -- anywhere anywhere
FORWARD_OUT_ZONES_SOURCE all -- anywhere anywhere
FORWARD_OUT_ZONES all -- anywhere anywhere
DROP all -- anywhere anywhere ctstate INVALID
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
OUTPUT_direct all -- anywhere anywhere

Chain FORWARD_IN_ZONES (1 references)
target prot opt source destination
FWDI_block all -- anywhere anywhere
FWDI_block all -- anywhere anywhere

Chain FORWARD_IN_ZONES_SOURCE (1 references)
target prot opt source destination

Chain FORWARD_OUT_ZONES (1 references)
target prot opt source destination
FWDO_block all -- anywhere anywhere
FWDO_block all -- anywhere anywhere

Chain FORWARD_OUT_ZONES_SOURCE (1 references)
target prot opt source destination

Chain FORWARD_direct (1 references)
target prot opt source destination

Chain FWDI_block (2 references)
target prot opt source destination
FWDI_block_log all -- anywhere anywhere
FWDI_block_deny all -- anywhere anywhere
FWDI_block_allow all -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain FWDI_block_allow (1 references)
target prot opt source destination

Chain FWDI_block_deny (1 references)
target prot opt source destination

Chain FWDI_block_log (1 references)
target prot opt source destination

Chain FWDO_block (2 references)
target prot opt source destination
FWDO_block_log all -- anywhere anywhere
FWDO_block_deny all -- anywhere anywhere
FWDO_block_allow all -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain FWDO_block_allow (1 references)
target prot opt source destination

Chain FWDO_block_deny (1 references)
target prot opt source destination

Chain FWDO_block_log (1 references)
target prot opt source destination

Chain INPUT_ZONES (1 references)
target prot opt source destination
IN_block all -- anywhere anywhere
IN_block all -- anywhere anywhere

Chain INPUT_ZONES_SOURCE (1 references)
target prot opt source destination

Chain INPUT_direct (1 references)
target prot opt source destination

Chain IN_block (2 references)
target prot opt source destination
IN_block_log all -- anywhere anywhere
IN_block_deny all -- anywhere anywhere
IN_block_allow all -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

Chain IN_block_allow (1 references)
target prot opt source destination
ACCEPT tcp -- x.x.0.0/16 anywhere tcp dpt:ssh ctstate NEW

Chain IN_block_deny (1 references)
target prot opt source destination

Chain IN_block_log (1 references)
target prot opt source destination

Chain OUTPUT_direct (1 references)
target prot opt source destination

mat6937
Beiträge: 2925
Registriert: 09.12.2014 10:44:00

Re: Debian9 Apache2 - iptables INPUT Problem

Beitrag von mat6937 » 04.05.2019 19:25:17

linuxxxxx hat geschrieben: ↑ zum Beitrag ↑
04.05.2019 18:46:31
..., jedoch schaffe ich es nicht die richtige INPUT-Regel in iptables einzubauen. Meines Erachtens sollte diese Regel funktionieren:

iptables -A INPUT -p tcp -m multiport --dports 80,443 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT

Tut Sie aber nicht... Was kann ich tun?

Hier meine iptables Rules:

Code: Alles auswählen

#iptables -L | more
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere
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
ACCEPT     tcp  --  anywhere             anywhere             multiport dports http,https ctstate NEW,ESTABLISHED
Evtl. hast Du die Regel nicht an der richtigen Stelle bzw. nicht in der richtigen/geeigneten Reihenfolge.
BTW: Von wo hast Du diese ganzen iptables-Regeln?

eggy
Beiträge: 3331
Registriert: 10.05.2008 11:23:50

Re: Debian9 Apache2 - iptables INPUT Problem

Beitrag von eggy » 04.05.2019 19:55:34

Regeln werden "von oben nach unten" angewandt: wenn etwas zuvor bereits mit REJECT oder DROP behandelt wurde, hilft auch kein nachträgliches ACCEPT mehr.
-A fügt unten an (append)
-I am Anfang oder mit Angabe des Zielorts zwischendrin (insert)

mat6937
Beiträge: 2925
Registriert: 09.12.2014 10:44:00

Re: Debian9 Apache2 - iptables INPUT Problem

Beitrag von mat6937 » 04.05.2019 20:01:10

eggy hat geschrieben: ↑ zum Beitrag ↑
04.05.2019 19:55:34
... wenn etwas zuvor bereits mit REJECT oder DROP behandelt wurde, hilft auch kein nachträgliches ACCEPT mehr.
Der TE hat:

Code: Alles auswählen

ACCEPT     all  --  anywhere             anywhere
_vor_ der:

Code: Alles auswählen

ACCEPT     tcp  --  anywhere             anywhere             multiport dports http,https ctstate NEW,ESTABLISHED
als letzte Regel in der INPUT chain.

eggy
Beiträge: 3331
Registriert: 10.05.2008 11:23:50

Re: Debian9 Apache2 - iptables INPUT Problem

Beitrag von eggy » 04.05.2019 20:16:09

Ja, aber wie Du schon zuvor richtig bemerkt hattest, sind die Regeln an sich "komisch". Fängt ja schon viel eher an

Code: Alles auswählen

ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
Ich hab den Eindruck, dass linuxxxxx die von mir genannten Informationen noch zum Verständnis Deines Kommentars gefehlt haben könnten, daher "kontextfrei".

mat6937
Beiträge: 2925
Registriert: 09.12.2014 10:44:00

Re: Debian9 Apache2 - iptables INPUT Problem

Beitrag von mat6937 » 04.05.2019 21:53:22

eggy hat geschrieben: ↑ zum Beitrag ↑
04.05.2019 20:16:09
Fängt ja schon viel eher an

Code: Alles auswählen

ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
Für den state ESTABLISHED ja, aber für den state NEW nicht.

eggy
Beiträge: 3331
Registriert: 10.05.2008 11:23:50

Re: Debian9 Apache2 - iptables INPUT Problem

Beitrag von eggy » 04.05.2019 22:21:37

die obere ist überflüssig

Antworten