Iniciante configuração de firewall iptables. [RESOLVIDO]

1. Iniciante configuração de firewall iptables. [RESOLVIDO]

Rafael R.
raafa

(usa Debian)

Enviado em 07/04/2012 - 01:42h

Galera to querendo configura um firewall aqui em meu desk pois uso Linux débian kernel atualizado 3.3.1 gnome 2.30.2;
E queria ter um nivel de segurança...enfim como eu configuro?poderiam me dar um passo a passo ae?
sigo essa dica do amigo no tópico http://www.vivaolinux.com.br/artigo/Firewall-bridge-+-iptables-+-layer7-+-ipp2p ou alguem me indicaria ae?vlw


  


2. Re: Iniciante configuração de firewall iptables. [RESOLVIDO]

Rafael R.
raafa

(usa Debian)

Enviado em 07/04/2012 - 13:13h

alguem?


3. Link

André Canhadas
andrecanhadas

(usa Debian)

Enviado em 07/04/2012 - 15:08h

raafa escreveu:

alguem?

Tem um bem agressivo:
http://www.vivaolinux.com.br/script/Firewall-Iptables-Agressivo-Para-Desktop



4. Re: Iniciante configuração de firewall iptables. [RESOLVIDO]

Rafael R.
raafa

(usa Debian)

Enviado em 07/04/2012 - 15:25h

obg amigo, mas nos comentarios estão citando uma certa falha no firewall aonde pode prejudicar certas conexoes...concorda?!


5. Discordo

André Canhadas
andrecanhadas

(usa Debian)

Enviado em 07/04/2012 - 18:12h

raafa escreveu:

obg amigo, mas nos comentarios estão citando uma certa falha no firewall aonde pode prejudicar certas conexoes...concorda?!

Discordo. a menos que o invasor esteja conectado a sua rede local ele não vai conseguir executar o comando sugerido.

Claro que deve ler antes:
http://www.guiafoca.org/?page_id=14

Bom mas como aquele ta muito cheio de regras inúteis para um Desktop la vai:


#!/bin/bash

################################################################################
#################### Inicio Firewall - Desktop ##############################
################################################################################
/sbin/modprobe ip_nat
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ip_queue
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ip_tables
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_nat
/sbin/modprobe iptable_mangle
/sbin/modprobe ipt_state
/sbin/modprobe ipt_limit
/sbin/modprobe ipt_multiport
/sbin/modprobe ipt_mac
/sbin/modprobe ipt_string
## Limpando as Regras existentes #######
/sbin/iptables -F
/sbin/iptables -t nat -F
/sbin/iptables -t mangle -F
/sbin/iptables -t filter -F
/sbin/iptables -X
/sbin/iptables -Z

## Definindo politica padrão (Nega entrada e permite saida)
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT

# Variaveis: (Coloque aqui sua placa de rede)
iface_ext=eth0
iface_int=eth1

################################################################################
######################## Protege contra ataques diversos #######################
################################################################################

###### Protege contra synflood
/sbin/iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT
echo 1 > /proc/sys/net/ipv4/tcp_syncookies

###### Protecao contra ICMP Broadcasting
#echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
#echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
###### Prote.. Contra IP Spoofing
echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter

###### Protecao diversas contra portscanners, ping of death, ataques DoS, pacotes danificados e etc.
#/sbin/iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
#/sbin/iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
#/sbin/iptables -A INPUT -i $iface_ext -p icmp --icmp-type echo-reply -m limit --limit 1/s -j DROP
/sbin/iptables -A FORWARD -p tcp -m limit --limit 1/s -j ACCEPT
/sbin/iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
/sbin/iptables -A FORWARD --protocol tcp --tcp-flags ALL SYN,ACK -j DROP
/sbin/iptables -A INPUT -m state --state INVALID -j DROP
/sbin/iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -N VALID_CHECK
/sbin/iptables -A VALID_CHECK -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
/sbin/iptables -A VALID_CHECK -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
/sbin/iptables -A VALID_CHECK -p tcp --tcp-flags ALL ALL -j DROP
/sbin/iptables -A VALID_CHECK -p tcp --tcp-flags ALL FIN -j DROP
/sbin/iptables -A VALID_CHECK -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
/sbin/iptables -A VALID_CHECK -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
/sbin/iptables -A VALID_CHECK -p tcp --tcp-flags ALL NONE -j DROP


################################################################################
######################### Fim da regras de contra ataques ######################
################################################################################

## Estabelece relação de confiança entre maquinas da rede local eth1(rede local)
#/sbin/iptables -A INPUT -i $iface_int -s 192.168.0.0/255.255.255.0 -j ACCEPT

# Permite conexões de entrada iniciadas por você
/sbin/iptables -A INPUT -i $iface_ext -m state --state NEW -j ACCEPT
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

## liberando o INPUT externo para o firewall ##

## Portas ##

# SSH
#/sbin/iptables -A INPUT -i $iface_ext -p tcp -m multiport --dport 22,80 -j ACCEPT


################################################################################
################################# Bloqueio de entrada ##########################
################################################################################
/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A INPUT -i $iface_ext -j ACCEPT
/sbin/iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
#/sbin/iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
/sbin/iptables -A INPUT -i $iface_ext -j REJECT
## Liberar ping ## 0=on 1=off
echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all

################################################################################
############################ Compartilhamento Internet #########################
################################################################################

#/sbin/iptables -t nat -A POSTROUTING -o $iface_ext -j MASQUERADE
#echo 1 > /proc/sys/net/ipv4/ip_forward

echo "Firewall Ativado"
################################################################################
######################################## Fim ###################################
################################################################################




6. Re: Iniciante configuração de firewall iptables. [RESOLVIDO]

Josue de Jesus Santos
JJSantos

(usa Gentoo)

Enviado em 16/04/2012 - 01:51h

Se conseguiu, marque como resolvido!






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts