abiazon
(usa Red Hat)
Enviado em 31/05/2017 - 12:19h
Boa tarde senhores.
Iniciei meus trabalhos em linux, utilizando o Oracle Linux Server release 6.9, versão do kernel 2.6.39-400.294.3.el6uek.i686, provedor de internet Embratel(link dedicado). Meu problema é que quando inseri os logs do iptables e utilizei a politica drop para o INPUT, este log surgiu:
May 31 12:08:47 localhost kernel: iptables-Dropped: IN=eth0 OUT= MAC=00:19:d1:36:46:9a:c4:ca:d9:31:a5:c6:08:00 SRC=109.242.243.49 DST=(ip do servidor, placa de rede eth0) LEN=40 TOS=0x00 PREC=0x00 TTL=239 ID=38797 PROTO=TCP SPT=46887 DPT=81 WINDOW=14600 RES=0x00 SYN URGP=0
(alternando na mensagem o DPT e SPT)
Gostaria de criar uma regra onde esta mensagem não aparecesse mais e caso o script do firewall possa ser melhorado, em questões de segurança, eu agradeço a ajuda . Obrigado !
Segue iptables:
#!/bin/sh
#carregar modulos
modprobe iptable_nat
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
modprobe ipt_LOG
#limpar regras
iptables -F
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -t mangle -F
iptables -t nat -F
iptables -X
iptables -Z
echo "Iniciando Firewall"
###politica padrao
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
#Politicas de segurança ###
echo "Implementação de politicas de segurança"
#impede falsear pacote
echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route
#Pedido de descobrimento de rotas de roteamento
echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects
#Risco de DoS
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
#So inicia a conexao quando recebe a confirmacao, diminuindo a banda gasta
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
#Protecao contra spoof de IP
echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter
###INPUT
iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state INVALID -j DROP
#liberar ssh interno
iptables -A INPUT -p tcp -i eth1 --dport 22 -j ACCEPT
#libera loopback e interface interna
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth1 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 3128 -j ACCEPT
iptables -A INPUT -i eth1 -p udp --dport 53 -j ACCEPT
#echo "Liberando o Samba"
iptables -A INPUT -i eth1 -p tcp --dport 137 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 138 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 445 -j ACCEPT
iptables -A INPUT -i eth1 -p udp --dport 137 -j ACCEPT
iptables -A INPUT -i eth1 -p udp --dport 138 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 139 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 901 -j ACCEPT
iptables -A INPUT -i eth1 -p udp --dport 901 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 631 -j ACCEPT
iptables -A INPUT -i eth1 -p udp --dport 631 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 389 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 528 -j ACCEPT
iptables -A INPUT -i eth1 -p tcp --dport 151 -j ACCEPT
###forward
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i lo -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp --dport 21 -j ACCEPT
iptables -A FORWARD -i eth0 -p tcp --dport 20 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 25 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 465 -j ACCEPT
iptables -A FORWARD -i eth1 -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 110 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 443 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 995 -j ACCEPT
iptables -A FORWARD -i eth1 -p tcp --dport 587 -j ACCEPT
### Liberando FTP porta 2121
iptables -A FORWARD -p tcp --dport 2121 -j ACCEPT
iptables -A FORWARD -p tcp -i eth1 --dport 1024:65000 -j ACCEPT
#RECEITA FEDERAL
iptables -A FORWARD -p tcp --dport 3456 -j ACCEPT
iptables -A FORWARD -p udp --dport 3456 -j ACCEPT
# transmissao Conectividade Social
iptables -A FORWARD -p tcp --dport 2361 -j ACCEPT
# Transmissao RAIS
iptables -A FORWARD -p tcp --dport 3007 -j ACCEPT
###OUTPUT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 3128 -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -A OUTPUT -p udp --sport 53 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
###POSTROUTING
#echo 1 > /proc/sys/net/ipv4/ip_forward gravado no arquivo /etc/sysctl.conf
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
###PREROUTING
#liberar sites para nao passar pelo squid
for i in $(cat /etc/init.d/sites_noproxy)
do
iptables -t nat -A PREROUTING -s 192.168.0.0/16 -d $i -p tcp --dport 80 -j ACCEPT
done
#proxy transparente
iptables -t nat -A PREROUTING -s 192.168.0.0/16 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -p tcp --dport 21 -j DNAT --to 192.168.0.202:21
iptables -t nat -A PREROUTING -p tcp --dport 20 -j DNAT --to 192.168.0.202:20
#log iptables
iptables -N LOGGING
iptables -A INPUT -j LOGGING
iptables -A OUTPUT -j LOGGING
iptables -A LOGGING -m limit --limit 2/min -j LOG --log-prefix "iptables-Dropped: " --log-level 4
iptables -A LOGGING -j DROP