Estou tentando configurar o firewall em um servidor Web que executa o Apache usando comandos iptables. Tomei a abordagem de bloquear todas as conexões de saída, exceto aquelas que são necessárias. Tudo parece estar funcionando bem, embora nos logs do firewall eu veja algumas conexões de saída bloqueadas com a porta de origem do 443:
IPTables-Dropped: IN= OUT=eth0 SRC={SERVERIP} DST={DESTIP} LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=36863 DF PROTO=TCP SPT=443 DPT=37096 WINDOW=0 RES=0x00 RST URGP=0
No meu arquivo de configuração do firewall, uso a seguinte regra:
iptables -A OUTPUT -p tcp --sport 443 -m state --state ESTABLISHED,RELATED -j ACCEPT
O fato de que os pacotes estão sendo descartados sugere que a conexão da porta 443 tem que ser uma conexão NEW, que eu quero bloquear, já que não vejo a razão pela qual o meu servidor deve se conectar a qualquer outra máquina dessa maneira. .
Os IPs de destino mudam e se parecem com IPs de clientes comuns, com base em sua localização e informações whois.
O que estou perdendo aqui? Esse comportamento esperado é de alguma forma determinado pela conexão HTTPS ou essas conexões são suspeitas? Devo ACEITAR NOVAS conexões também?
TLDR; O servidor da Web parece estar tentando estabelecer NOVAS conexões da porta 443 para vários clientes, conforme indicado pelo log do firewall. Isso deveria estar acontecendo? Devo permitir este tráfego? Qual poderia ser sua fonte?
EDIT: Estamos executando o Ubuntu Server 12.04
apache2 -v
Server version: Apache/2.2.22 (Ubuntu)
Server built: Jul 12 2013 13:37:10
iptables -V
iptables v1.4.12
iptables -L -v
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
814 86082 ACCEPT all -- lo any anywhere anywhere
2382K 99M ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED
2 108 ACCEPT tcp -- any any anywhere anywhere tcp dpt:ssh
0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:ssh
1404 77906 ACCEPT tcp -- any any anywhere anywhere tcp dpt:https
0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:https
286 15356 ACCEPT tcp -- any any anywhere anywhere tcp dpt:http
0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:http
0 0 ACCEPT udp -- any any anywhere anywhere udp spt:domain dpts:1024:65535 state ESTABLISHED
0 0 ACCEPT tcp -- any any anywhere anywhere tcp spt:domain dpts:1024:65535 state ESTABLISHED
1 83 ACCEPT udp -- any any anywhere anywhere udp spts:1024:65535 dpt:domain state NEW,ESTABLISHED
0 0 ACCEPT udp -- any any anywhere anywhere udp spt:domain dpt:domain state NEW,ESTABLISHED
0 0 ACCEPT icmp -- any any anywhere anywhere icmp echo-reply state RELATED,ESTABLISHED
47 3892 ACCEPT icmp -- any any anywhere anywhere icmp echo-request state NEW,RELATED,ESTABLISHED
94 28900 LOGGING all -- any any anywhere anywhere
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- any lo anywhere anywhere
0 0 ACCEPT all -- any any anywhere anywhere ctstate RELATED,ESTABLISHED
Chain OUTPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
527 34635 ACCEPT udp -- any any anywhere anywhere udp spts:1024:65535 dpt:domain state NEW,ESTABLISHED
0 0 ACCEPT tcp -- any any anywhere anywhere tcp spts:1024:65535 dpt:domain state NEW,ESTABLISHED
407 60108 ACCEPT udp -- any any anywhere anywhere udp spt:domain dpts:1024:65535 state ESTABLISHED
0 0 ACCEPT udp -- any any anywhere anywhere udp spt:domain dpt:domain state ESTABLISHED
0 0 ACCEPT tcp -- any any anywhere anywhere tcp dpt:ssh state NEW,ESTABLISHED
1634 206K ACCEPT tcp -- any any anywhere anywhere tcp dpt:https state NEW,ESTABLISHED
0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:https state NEW,ESTABLISHED
0 0 ACCEPT tcp -- any any anywhere anywhere tcp dpt:http state NEW,ESTABLISHED
0 0 ACCEPT udp -- any any anywhere anywhere udp dpt:http state NEW,ESTABLISHED
25185 42M ACCEPT tcp -- any any anywhere anywhere tcp spt:https state NEW,RELATED,ESTABLISHED
0 0 ACCEPT udp -- any any anywhere anywhere udp spt:https state NEW,RELATED,ESTABLISHED
1198 260K ACCEPT tcp -- any any anywhere anywhere tcp spt:http state NEW,RELATED,ESTABLISHED
0 0 ACCEPT udp -- any any anywhere anywhere udp spt:http state NEW,RELATED,ESTABLISHED
4891K 358M ACCEPT tcp -- any any anywhere anywhere tcp spt:ssh state ESTABLISHED
0 0 ACCEPT udp -- any any anywhere anywhere udp spt:ssh state ESTABLISHED
0 0 ACCEPT icmp -- any any anywhere anywhere icmp echo-request state NEW,RELATED,ESTABLISHED
47 3892 ACCEPT icmp -- any any anywhere anywhere icmp echo-reply state RELATED,ESTABLISHED
69 2831 LOGGING all -- any any anywhere anywhere
Chain LOGGING (2 references)
pkts bytes target prot opt in out source destination
89 16387 LOG all -- any any anywhere anywhere limit: avg 15/min burst 5 LOG level warning prefix "IPTables-Dropped: "
163 31731 DROP all -- any any anywhere anywhere