2017-07-17 2 views
0

J'ai eu des problèmes pour me connecter via un navigateur Web au serveur qui exécute Apache. J'ai découvert qu'en arrêtant le service d'iptables, je peux alors me connecter et charger une page Web du serveur. Cependant, je ne comprends pas ce qui me manque dans mes règles iptbales, car j'ai déjà opté pour le port 80.Le port 80 est ouvert mais Iptables empêche les connexions Apache

Quelqu'un peut-il voir quelque chose ici qui pourrait causer des problèmes?

-P INPUT ACCEPT 
-P FORWARD ACCEPT 
-P OUTPUT ACCEPT 
-N FORWARD_IN_ZONES 
-N FORWARD_IN_ZONES_SOURCE 
-N FORWARD_OUT_ZONES 
-N FORWARD_OUT_ZONES_SOURCE 
-N FORWARD_direct 
-N FWDI_public 
-N FWDI_public_allow 
-N FWDI_public_deny 
-N FWDI_public_log 
-N FWDO_public 
-N FWDO_public_allow 
-N FWDO_public_deny 
-N FWDO_public_log 
-N INPUT_ZONES 
-N INPUT_ZONES_SOURCE 
-N INPUT_direct 
-N IN_public 
-N IN_public_allow 
-N IN_public_deny 
-N IN_public_log 
-N OUTPUT_direct 
-A INPUT -p udp -m udp --dport 53 -m state --state NEW -j ACCEPT 
-A INPUT -p udp -m udp --dport 53 -m state --state NEW -j ACCEPT 
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 
-A INPUT -i lo -j ACCEPT 
-A INPUT -j INPUT_direct 
-A INPUT -j INPUT_ZONES_SOURCE 
-A INPUT -j INPUT_ZONES 
-A INPUT -p icmp -j ACCEPT 
-A INPUT -j REJECT --reject-with icmp-host-prohibited 
-A INPUT -p udp -m udp --dport 123 -j ACCEPT 
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT 
-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 
-A FORWARD -i lo -j ACCEPT 
-A FORWARD -j FORWARD_direct 
-A FORWARD -j FORWARD_IN_ZONES_SOURCE 
-A FORWARD -j FORWARD_IN_ZONES 
-A FORWARD -j FORWARD_OUT_ZONES_SOURCE 
-A FORWARD -j FORWARD_OUT_ZONES 
-A FORWARD -p icmp -j ACCEPT 
-A FORWARD -j REJECT --reject-with icmp-host-prohibited 
-A OUTPUT -j OUTPUT_direct 
-A OUTPUT -p udp -m udp --sport 123 -j ACCEPT 
-A FORWARD_IN_ZONES -i eno1 -g FWDI_public 
-A FORWARD_IN_ZONES -g FWDI_public 
-A FORWARD_OUT_ZONES -o eno1 -g FWDO_public 
-A FORWARD_OUT_ZONES -g FWDO_public 
-A FWDI_public -j FWDI_public_log 
-A FWDI_public -j FWDI_public_deny 
-A FWDI_public -j FWDI_public_allow 
-A FWDO_public -j FWDO_public_log 
-A FWDO_public -j FWDO_public_deny 
-A FWDO_public -j FWDO_public_allow 
-A INPUT_ZONES -i eno1 -g IN_public 
-A INPUT_ZONES -g IN_public 
-A IN_public -j IN_public_log 
-A IN_public -j IN_public_deny 
-A IN_public -j IN_public_allow 
-A IN_public_allow -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT 

EDIT ***

est ici la sortie de iptables -nvL tel que demandé par Bogdan Stoica:

Chain INPUT (policy ACCEPT 0 packets, 0 bytes) 
pkts bytes target  prot opt in  out  source    destination   
    6 396 ACCEPT  udp -- *  *  0.0.0.0/0   0.0.0.0/0   udp dpt:53 state NEW 
    0  0 ACCEPT  udp -- *  *  0.0.0.0/0   0.0.0.0/0   udp dpt:53 state NEW 
    22 1520 ACCEPT  all -- *  *  0.0.0.0/0   0.0.0.0/0   ctstate RELATED,ESTABLISHED 
    0  0 ACCEPT  all -- lo  *  0.0.0.0/0   0.0.0.0/0   
    16 2177 INPUT_direct all -- *  *  0.0.0.0/0   0.0.0.0/0   
    16 2177 INPUT_ZONES_SOURCE all -- *  *  0.0.0.0/0   0.0.0.0/0   
    16 2177 INPUT_ZONES all -- *  *  0.0.0.0/0   0.0.0.0/0   
    0  0 ACCEPT  icmp -- *  *  0.0.0.0/0   0.0.0.0/0   
    16 2177 REJECT  all -- *  *  0.0.0.0/0   0.0.0.0/0   reject-with icmp-host-prohibited 
    0  0 ACCEPT  udp -- *  *  0.0.0.0/0   0.0.0.0/0   udp dpt:123 
    0  0 ACCEPT  tcp -- *  *  0.0.0.0/0   0.0.0.0/0   tcp dpt:80 

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) 
pkts bytes target  prot opt in  out  source    destination   
    0  0 ACCEPT  all -- *  *  0.0.0.0/0   0.0.0.0/0   ctstate RELATED,ESTABLISHED 
    0  0 ACCEPT  all -- lo  *  0.0.0.0/0   0.0.0.0/0   
    0  0 FORWARD_direct all -- *  *  0.0.0.0/0   0.0.0.0/0   
    0  0 FORWARD_IN_ZONES_SOURCE all -- *  *  0.0.0.0/0   0.0.0.0/0   
    0  0 FORWARD_IN_ZONES all -- *  *  0.0.0.0/0   0.0.0.0/0   
    0  0 FORWARD_OUT_ZONES_SOURCE all -- *  *  0.0.0.0/0   0.0.0.0/0   
    0  0 FORWARD_OUT_ZONES all -- *  *  0.0.0.0/0   0.0.0.0/0   
    0  0 ACCEPT  icmp -- *  *  0.0.0.0/0   0.0.0.0/0   
    0  0 REJECT  all -- *  *  0.0.0.0/0   0.0.0.0/0   reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT 21 packets, 3720 bytes) 
pkts bytes target  prot opt in  out  source    destination   
    21 3720 OUTPUT_direct all -- *  *  0.0.0.0/0   0.0.0.0/0   
    0  0 ACCEPT  udp -- *  *  0.0.0.0/0   0.0.0.0/0   udp spt:123 

Chain FORWARD_IN_ZONES (1 references) 
pkts bytes target  prot opt in  out  source    destination   
    0  0 FWDI_public all -- eno1 *  0.0.0.0/0   0.0.0.0/0   [goto] 
    0  0 FWDI_public all -- *  *  0.0.0.0/0   0.0.0.0/0   [goto] 

Chain FORWARD_IN_ZONES_SOURCE (1 references) 
pkts bytes target  prot opt in  out  source    destination   

Chain FORWARD_OUT_ZONES (1 references) 
pkts bytes target  prot opt in  out  source    destination   
    0  0 FWDO_public all -- *  eno1 0.0.0.0/0   0.0.0.0/0   [goto] 
    0  0 FWDO_public all -- *  *  0.0.0.0/0   0.0.0.0/0   [goto] 

Chain FORWARD_OUT_ZONES_SOURCE (1 references) 
pkts bytes target  prot opt in  out  source    destination   

Chain FORWARD_direct (1 references) 
pkts bytes target  prot opt in  out  source    destination   

Chain FWDI_public (2 references) 
pkts bytes target  prot opt in  out  source    destination   
    0  0 FWDI_public_log all -- *  *  0.0.0.0/0   0.0.0.0/0   
    0  0 FWDI_public_deny all -- *  *  0.0.0.0/0   0.0.0.0/0   
    0  0 FWDI_public_allow all -- *  *  0.0.0.0/0   0.0.0.0/0   

Chain FWDI_public_allow (1 references) 
pkts bytes target  prot opt in  out  source    destination   

Chain FWDI_public_deny (1 references) 
pkts bytes target  prot opt in  out  source    destination   

Chain FWDI_public_log (1 references) 
pkts bytes target  prot opt in  out  source    destination   

Chain FWDO_public (2 references) 
pkts bytes target  prot opt in  out  source    destination   
    0  0 FWDO_public_log all -- *  *  0.0.0.0/0   0.0.0.0/0   
    0  0 FWDO_public_deny all -- *  *  0.0.0.0/0   0.0.0.0/0   
    0  0 FWDO_public_allow all -- *  *  0.0.0.0/0   0.0.0.0/0   

Chain FWDO_public_allow (1 references) 
pkts bytes target  prot opt in  out  source    destination   

Chain FWDO_public_deny (1 references) 
pkts bytes target  prot opt in  out  source    destination   

Chain FWDO_public_log (1 references) 
pkts bytes target  prot opt in  out  source    destination   

Chain INPUT_ZONES (1 references) 
pkts bytes target  prot opt in  out  source    destination   
    16 2177 IN_public all -- eno1 *  0.0.0.0/0   0.0.0.0/0   [goto] 
    0  0 IN_public all -- *  *  0.0.0.0/0   0.0.0.0/0   [goto] 

Chain INPUT_ZONES_SOURCE (1 references) 
pkts bytes target  prot opt in  out  source    destination   

Chain INPUT_direct (1 references) 
pkts bytes target  prot opt in  out  source    destination   

Chain IN_public (2 references) 
pkts bytes target  prot opt in  out  source    destination   
    16 2177 IN_public_log all -- *  *  0.0.0.0/0   0.0.0.0/0   
    16 2177 IN_public_deny all -- *  *  0.0.0.0/0   0.0.0.0/0   
    16 2177 IN_public_allow all -- *  *  0.0.0.0/0   0.0.0.0/0   

Chain IN_public_allow (1 references) 
pkts bytes target  prot opt in  out  source    destination   
    0  0 ACCEPT  tcp -- *  *  0.0.0.0/0   0.0.0.0/0   tcp dpt:22 ctstate NEW 

Chain IN_public_deny (1 references) 
pkts bytes target  prot opt in  out  source    destination   

Chain IN_public_log (1 references) 
pkts bytes target  prot opt in  out  source    destination   

Chain OUTPUT_direct (1 references) 
pkts bytes target  prot opt in  out  source    destination   
+0

pouvez-vous fournir la sortie de 'iptables -nvL' lorsque toutes les règles de pare-feu sont actives? –

+0

qui a été ajouté maintenant, vive, – nmh

Répondre

0

Je ne peux pas vraiment suivre parce que vous avez tant de chaînes (et Je ne sais pas exactement ce que chaque chaîne est censée faire ... mais je peux le deviner mais mes suppositions peuvent être fausses. En règle générale, vous devriez avoir:

1) la politique par défaut est DROP et vous permettre strictement ce que vous avez besoin 2) essayez de mettre à jour vos règles d'autorisation comme suit:

iptables -A IN_public_allow -p udp -m udp --dport 53 -m state --state NEW -j ACCEPT 
iptables -A IN_public_allow -p udp -m udp --dport 53 -m state --state NEW -j ACCEPT 

Il ressemble à une mauvaise configuration :

-A IN_public -j IN_public_log 
-A IN_public -j IN_public_deny 
-A IN_public -j IN_public_allow 

Fondamentalement, vous ne définissez pas de stratégie pour ces chaînes. Je reconfigurer le pare-feu entièrement. Vous devez tout mettre sur papier dès le départ, de quelles chaînes avez-vous besoin, pourquoi vous en avez besoin, quelles sont les politiques que chaque chaîne est supposée avoir. Ensuite, vous pouvez créer des règles et les ajouter à leurs chaînes spécifiques