Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Este script pode ser usado em outras distribuicoes Linux que utilizam o Kernel 2.4 em diante
- # Por militares da secao de informatica bo 62 BI
- firewall_start(){
- # Compartilhando a conexao
- modprobe iptable_nat
- echo 1 > /proc/sys/net/ipv4/ip_forward
- iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
- # Ativando proxy transparente
- iptables -t nat -A PREROUTING -i eth3 -p tcp --dport 80 -j REDIRECT --to-port 3128
- # Abre para uma faixa de enderecos da rede local
- iptables -A INPUT -s 192.168.0.0/255.255.255.0 -j ACCEPT
- ###########################################################################
- #----- A regra abaixo bloqueia qualquer host da rede ao conectar no MSN --#
- ###########################################################################
- # Bloqueando os Demais
- #iptables -A FORWARD -s 192.168.0.0/24 -p tcp --dport 1863 -j REJECT
- #iptables -A FORWARD -s 192.168.0.0/24 -d loginnet.passport.com -j REJECT
- #-------------------------- Hosts Liberados ------------------------------#
- # impressao
- #iptables -A FORWARD -s 192.168.0.3/24 -p tcp --dport 1863 -j ACCEPT
- #iptables -A FORWARD -s 192.168.0.3/24 -d loginnet.passport.com -j ACCEPT
- # secinfoweb
- #iptables -A FORWARD -s 192.168.0.5/24 -p tcp --dport 1863 -j ACCEPT
- #iptables -A FORWARD -s 192.168.0.5/24 -d loginnet.passport.com -j ACCEPT
- # secinfomnt
- #iptables -A FORWARD -s 192.168.0.7/24 -p tcp --dport 1863 -j ACCEPT
- #iptables -A FORWARD -s 192.168.0.7/24 -d loginnet.passport.com -j ACCEPT
- # secinfochf
- #iptables -A FORWARD -s 192.168.0.8/24 -p tcp --dport 1863 -j ACCEPT
- #iptables -A FORWARD -s 192.168.0.8/24 -d loginnet.passport.com -j ACCEPT
- # secinfoadm
- #iptables -A FORWARD -s 192.168.0.9/24 -p tcp --dport 1863 -j ACCEPT
- #iptables -A FORWARD -s 192.168.0.9/24 -d loginnet.passport.com -j ACCEPT
- # ajudchf
- #iptables -A FORWARD -s 192.168.0.14/24 -p tcp --dport 1863 -j ACCEPT
- #iptables -A FORWARD -s 192.168.0.14/24 -d loginnet.passport.com -j ACCEPT
- # ajud1
- #iptables -A FORWARD -s 192.168.0.16/24 -p tcp --dport 1863 -j ACCEPT
- #iptables -A FORWARD -s 192.168.0.16/24 -d loginnet.passport.com -j ACCEPT
- #------------------- Bloqueando WebMensseger ------------------------------#
- #iptables -A FORWARD -s 192.168.0.0/24 -d webmessenger.msn.com -j REJECT
- #--------------- Hosts Liberados webmessenger -----------------------------#
- # impressao
- #iptables -A FORWARD -s 192.168.0.3/24 -d webmessenger.msn.com -j ACCEPT
- # secinfoweb
- #iptables -A FORWARD -s 192.168.0.5/24 -d webmessenger.msn.com -j ACCEPT
- # secinfomnt
- #iptables -A FORWARD -s 192.168.0.7/24 -d webmessenger.msn.com -j ACCEPT
- #secinfochf
- #iptables -A FORWARD -s 192.168.0.8/24 -d webmessenger.msn.com -j ACCEPT
- #secinfoadm
- #iptables -A FORWARD -s 192.168.0.9/24 -d webmessenger.msn.com -j ACCEPT
- #ajudchf
- #iptables -A FORWARD -s 192.168.0.14/24 -d webmessenger.msn.com -j ACCEPT
- #ajud1
- #iptables -A FORWARD -s 192.168.0.16/24 -d webmessenger.msn.com -j ACCEPT
- # Bloqueando os Demais webmessenger
- #iptables -A FORWARD -s 192.168.0.0/24 -d webmessenger.msn.com -j REJECT
- ###############################################################################
- ###############################################################################
- #################################################################################
- #################################################################################
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 2631 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 21 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 22 -j ACCEPT
- # Abre uma porta (para acesso externo via ssh)
- iptables -A INPUT -p tcp -s 0/0 --dport 22 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 25 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 53 -j ACCEPT
- iptables -A INPUT -p udp --dport 53 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 80 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 138 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 139 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 137 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 143 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 389 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 631 -j ACCEPT
- iptables -A INPUT -p udp --dport 631 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 110 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 1024 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 123 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 143 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 443 -j ACCEPT
- iptables -A INPUT -p udp --dport 443 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 1194 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 5901 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 80 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 53 -j ACCEPT
- iptables -A INPUT -p udp --dport 53 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 1080 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 1028 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 1723 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p udp --dport 1701 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 47 -j ACCEPT
- iptables -A INPUT -p udp --dport 47 -j ACCEPT
- # -------------------- SERPRO
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 23 -j ACCEPT
- iptables -A OUTPUT -p tcp --dport 23 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 8999 -j ACCEPT
- iptables -A OUTPUT -p tcp --dport 8999 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 23000 -j ACCEPT
- iptables -A OUTPUT -p tcp --dport 23000 -j ACCEPT
- # --------------------
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 1863 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p tcp --dport 2631 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p udp --dport 67 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p udp --dport 3456 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p udp --dport 465 -j ACCEPT
- # Abre uma porta (inclusive para a Internet)
- iptables -A INPUT -p udp --dport 955 -j ACCEPT
- # Ignora pings
- echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
- # Protecao contra IP spoofing
- echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter
- # Protege contra synflood
- echo "1" > /proc/sys/net/ipv4/tcp_syncookies
- # Protecao contra ICMP Broadcasting
- echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
- # Bloqueia traceroute
- iptables -A INPUT -p udp --dport 33435:33525 -j DROP
- # Protecoes diversas contra portscanners, ping of death, ataques DoS, etc.
- iptables -A INPUT -m state --state INVALID -j DROP
- # Abre para a interface de loopback.
- # Esta regra e essencial para o KDE e outros programas graficos funcionarem adequadamente.
- iptables -A INPUT -i lo -j ACCEPT
- # Fecha as portas udp de 1 a 1024
- iptables -A INPUT -p udp --dport 1:1024 -j DROP
- iptables -A INPUT -p udp --dport 59229 -j DROP
- # Esta regra e o coracao do firewall do Debian-Lenny,
- # ela bloqueia qualquer conexao que nao tenha sido permitida acima, justamente por isso ela e a ultima da cadeia.
- iptables -A INPUT -p tcp --syn -j DROP
- echo "O Firewall 62 BI esta sendo carregado..."
- sleep 1
- echo "Tudo pronto!"
- sleep 1
- }
- firewall_stop(){
- iptables -F
- iptables -X
- iptables -P INPUT ACCEPT
- iptables -P FORWARD ACCEPT
- iptables -P OUTPUT ACCEPT
- }
- case "$1" in
- "start")
- firewall_start
- ;;
- "stop")
- firewall_stop
- echo "O Firewall 62 BI esta sendo desativado"
- sleep 2
- echo "ok."
- ;;
- "restart")
- echo "O Firewall 62 BI esta sendo desativado"
- sleep 1
- echo "ok."
- firewall_stop; firewall_start
- ;;
- *)
- iptables -L -n
- esac
Add Comment
Please, Sign In to add comment