Firewall iptables
Publicado por Pedro Henrique (última atualização em 15/12/2015)
[ Hits: 6.774 ]
Homepage:
Firewall simples, para uso doméstico construido usando o iptables, Vim <3, e o Ubuntu 14.04.
# <> <> Iptables configuration file <><> # <> <> developed by PHMUN4R1 <> <> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # limpando politicas e regras. # "Limpando politicas" iptables -X iptables -F # Configurando as politicas padroes. "FECHA TUDO" # (Por padrão ele nega tudo, depois tu vai liberando só o nescessario.) iptables -P INPUT DROP iptables -P OUTPUT DROP iptables -P FORWARD DROP # Previne ataques DoS iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT # "Bloqueia o pings" # iptables -A INPUT -p icmp --icmp-type echo-request -j DROP # Protege contra port scanners avançados (ex.: nmap): iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT # Politicas de segurança # "Implementando Politicas de segurança..." echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route # Impede falsear pacote # echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects # Perigo de descobrimento de rotas de roteamento (desativar em roteador) # echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts # Risco de DoS echo 1 > /proc/sys/net/ipv4/tcp_syncookies # Só inicia a conexão quando recebe a confirmação, diminuindo a banda gasta echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter # Faz o firewall responder apenas a placa de rede que recebeu o pacote iptables -A INPUT -m state --state INVALID -j DROP # Elimina os pacotes invalidos # "Liberando conexões estabelecidas" iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -m state --state RELATED,ESTABLISHED,NEW -j ACCEPT iptables -A OUTPUT -m state --state RELATED,ESTABLISHED,NEW -j ACCEPT iptables -A INPUT -i lo -j ACCEPT # Configurando portas de entrada iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT # Configurando portas de saida iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT #web iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT #Web iptables -A OUTPUT -p tcp --dport 21 -j ACCEPT #ftp iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT iptables -A OUTPUT -p udp --dport 53 -j ACCEPT #tcp echo "Firewall Ativo, você está protegido. :D " # para desativar o firewall... # Remove todas as regras existentes # iptables -F # iptables -X # iptables -t mangle -F # Reseta as politicas padrões, aceitar tudo # iptables -P INPUT ACCEPT # iptables -P OUTPUT ACCEPT # iptables -P FORWARD ACCEPT #echo "Firewall Resetado com sucesso, você está desprotegido!"
FIREWALL COM IPTABLES - PARA EMPRESAS E INTRANETS
Instalar o Navegador Tor em qualquer distribuição Linux
Shell Script / Perl para sincronizar base de usuários do AD com o Zimbra
Nenhum coment�rio foi encontrado.
Aprenda a Gerenciar Permissões de Arquivos no Linux
Como transformar um áudio em vídeo com efeito de forma de onda (wave form)
Como aprovar Pull Requests em seu repositório Github via linha de comando
Quebra de linha na data e hora no Linux Mint
Organizando seus PDF com o Zotero
tentando instalar em um notebook antigo o Linux LegacyOS_2023... [RESO... (9)
Problema com Conexão Outlook via Firewall (OpenSUSE) com Internet Fibr... (5)