entendendo como fazer um firewall pessoal
DESCRIPTION
Palestra ministrada no II Liberdade Interativa (www.tux-es.org) sobre como constuir um firewall caseiro/pessoal com iptables.TRANSCRIPT
![Page 1: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/1.jpg)
IptablesIptablesEntendendo como fazer um firewall pessoal Entendendo como fazer um firewall pessoal
![Page 2: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/2.jpg)
![Page 3: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/3.jpg)
![Page 4: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/4.jpg)
![Page 5: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/5.jpg)
Você tem Você tem twitter?twitter?
![Page 6: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/6.jpg)
Você tem Twitter?
![Page 7: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/7.jpg)
Será que estouSerá que estou protegido?protegido?
![Page 8: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/8.jpg)
nmap Superscan
Port Scanner
![Page 9: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/9.jpg)
OpenSSHOpenSSH
![Page 10: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/10.jpg)
PostgreSQLPostgreSQL
![Page 11: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/11.jpg)
![Page 12: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/12.jpg)
SysAdminSysAdmin
![Page 13: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/13.jpg)
Filtro de Pacotes
![Page 14: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/14.jpg)
Tô de olho!
![Page 15: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/15.jpg)
Vaza!Vaza!
![Page 16: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/16.jpg)
MotivosMotivos
![Page 17: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/17.jpg)
![Page 18: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/18.jpg)
ControleControle
![Page 19: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/19.jpg)
![Page 20: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/20.jpg)
Acesso NegadoAcesso Negado
![Page 21: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/21.jpg)
![Page 22: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/22.jpg)
SegurançaSegurança
![Page 23: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/23.jpg)
ObservadorObservador
![Page 24: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/24.jpg)
![Page 25: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/25.jpg)
VigilânciaVigilância
![Page 26: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/26.jpg)
![Page 27: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/27.jpg)
./comofás ?./comofás ?
![Page 28: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/28.jpg)
Calma! Não é tão difícil assim!
![Page 29: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/29.jpg)
Kernel com suporte
![Page 30: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/30.jpg)
Iptables (claro!)
![Page 31: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/31.jpg)
![Page 32: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/32.jpg)
![Page 33: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/33.jpg)
ObjetivoObjetivo
![Page 34: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/34.jpg)
Conexão PPP e ninguém Conexão PPP e ninguém bisbilhotandobisbilhotando
![Page 35: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/35.jpg)
33 – Fazer log do restante – Fazer log do restante
1 –1 – Bloquear tudo que vem Bloquear tudo que vem de fora.de fora.
22 – Liberar serviços (se – Liberar serviços (se desejar)desejar)
![Page 36: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/36.jpg)
Caminho do pacoteCaminho do pacote
![Page 37: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/37.jpg)
1. 1. Sequência de RegrasSequência de Regras
2. 2. Análise e comparaçãoAnálise e comparação
3. 3. Define o destino do pacoteDefine o destino do pacote
4. 4. Análise da política da Análise da política da chainchain
![Page 38: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/38.jpg)
Nosso focoNosso foco
Chain INPUT INPUT
![Page 39: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/39.jpg)
![Page 40: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/40.jpg)
Bloquear acessos Bloquear acessos externosexternos
![Page 41: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/41.jpg)
Definir políticaDefinir políticada chainda chain
![Page 42: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/42.jpg)
# iptables -P# iptables -P
Não vai subir ninguém!
INPUTINPUT DROPDROP
![Page 43: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/43.jpg)
![Page 44: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/44.jpg)
Liberando acesso localLiberando acesso local
iptables -A iptables -A INPUTINPUT
iptables -A iptables -A INPUTINPUT -i -i lolo -j -j ACCEPTACCEPT
-j -j ACCEPTACCEPT
-m -m statestate--state --state RELATED,ESTABLISHEDRELATED,ESTABLISHED
Pacotes relacionadosPacotes relacionados
Adicionar de regraAdicionar de regraAdicionar de regraAdicionar de regra
![Page 45: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/45.jpg)
![Page 46: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/46.jpg)
Liberar serviçosLiberar serviçosnecessáriosnecessários
![Page 47: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/47.jpg)
Liberando SSHLiberando SSH
iptables -A iptables -A INPUTINPUT-j -j ACCEPTACCEPT
-p -p tcptcp ––dportdport 22 22
Adicionar Regra
![Page 48: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/48.jpg)
Serviços e PortasServiços e Portas
cat /etc/servicescat /etc/services
![Page 49: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/49.jpg)
![Page 50: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/50.jpg)
Guardar logs de Guardar logs de bloqueiosbloqueios
![Page 51: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/51.jpg)
Log, log, log...Log, log, log...
iptables -A iptables -A INPUTINPUT -m -m limitlimit --limit --limit 1/m -j 1/m -j LOGLOG --log-prefix --log-prefix "INPUT: ""INPUT: "
![Page 52: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/52.jpg)
Olhando o logOlhando o log
tail -f /var/log/messagestail -f /var/log/messages
![Page 53: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/53.jpg)
Ver as regras ativasVer as regras ativas
-v-viptables -Liptables -L -n-n
Listar
Não resolver nomes
Verboso
![Page 54: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/54.jpg)
![Page 55: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/55.jpg)
E se eu fizer besteira?E se eu fizer besteira?
iptables -I INPUT -p iptables -I INPUT -p tcp –dport 22tcp –dport 22 -j -j ACCEPTACCEPT
iptables -D iptables -D 11
iptables -D INPUT -p iptables -D INPUT -p tcp –dport 22tcp –dport 22 -j ACCEPT-j ACCEPT
![Page 56: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/56.jpg)
Desfazer “tuto”!Desfazer “tuto”!
iptables -F iptables -F INPUTINPUT
iptables -P iptables -P INPUT INPUT ACCEPTACCEPT
Apagar todas as regrasApagar todas as regras
Define a políticaDefine a política
![Page 57: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/57.jpg)
E se eu quiser mais?E se eu quiser mais?
http://www.netfilter.org/documentation/http://www.netfilter.org/documentation/
![Page 58: Entendendo como fazer um firewall pessoal](https://reader033.vdocuments.pub/reader033/viewer/2022051412/54bae7cf4a7959fc4f8b46b3/html5/thumbnails/58.jpg)
Valeu Valeu galera!galera!