thiagomartins
(usa Debian)
Enviado em 10/11/2009 - 16:37h
Gente como faço apra liberar um MAC de passar pelo firewall?
tentei varias opções e não conseguir, vai meu script para analise
Ajude ai
#!/bin/bash
echo "Ativando firewall."
#"Ativando..."
# Interface da Internet:
ifinternet="eth0"
# Interface da rede local
iflocal="eth1"
# Faixa de IP
ifip="192.168.1.0/24"
iniciar(){
# Ativando compartilhamento
modprobe iptable_nat
modprobe ip_nat_ftp
modprobe ipt_layer7
echo 1 > /proc/sys/net/ipv4/ip_forward
# Regra de roteamento, redireciona todos os pacotes da rede local para internet.
#iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
# Limite de pings de 2 segundos..
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 2/s -j ACCEPT
# Protegem contra IP spoofing.
echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter
iptables -A INPUT -m state --state INVALID -j DROP
# Autoriza pacotes da loopback(lo) e rede local.
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i $iflocal -j ACCEPT
# Prioriza trafego na porta 80
#iptables -t mangle -A INPUT -p tcp --dport 80 -j TOS --set-tos 16
# Liberações de portas
#
# Libera Banesfacil
# Abre uma porta FTP (inclusive para a Internet)
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
iptables -A FORWARD -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 20 -j ACCEPT
iptables -A FORWARD -p tcp --dport 20 -j ACCEPT
# Abre uma porta (inclusive para a Internet)
iptables -A INPUT -p tcp --dport 4226 -d 200.242.1.11 -j ACCEPT
iptables -A INPUT -p udp --dport 4226 -d 200.242.1.11 -j ACCEPT
iptables -A FORWARD -p udp --dport 4226 -d 200.242.1.11 -j ACCEPT
iptables -A INPUT -p tcp --dport 4226 -d 200.165.48.11 -j ACCEPT
iptables -A INPUT -p udp --dport 4226 -d 200.165.48.11 -j ACCEPT
iptables -A FORWARD -p udp --dport 4226 -d 200.165.48.11 -j ACCEPT
# Abrindo conexao ftp em modo passivo e ativo
iptables -A INPUT -p tcp --sport 20 -m state --state NEW,ESTABLISHED,RELATED -d 200.242.1.11 -j ACCEPT
iptables -A FORWARD -p tcp --sport 20 -m state --state NEW,ESTABLISHED,RELATED -d 200.242.1.11 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 20 -m state --state ESTABLISHED -d 200.242.1.11 -j ACCEPT
iptables -A INPUT -p tcp --sport 20 -m state --state NEW,ESTABLISHED,RELATED -d 200.165.48.11 -j ACCEPT
iptables -A FORWARD -p tcp --sport 20 -m state --state NEW,ESTABLISHED,RELATED -d 200.165.48.11 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 20 -m state --state ESTABLISHED -d 200.165.48.11 -j ACCEPT
iptables -A INPUT -p tcp --sport 21 -m state --state NEW,ESTABLISHED,RELATED -d 200.165.48.11 -j ACCEPT
iptables -A FORWARD -p tcp --sport 21 -m state --state NEW,ESTABLISHED,RELATED -d 200.165.48.11 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 21 -m state --state ESTABLISHED,RELATED -d 200.165.48.11 -j ACCEPT
iptables -A INPUT -p tcp --sport 21 -m state --state NEW,ESTABLISHED,RELATED -d 200.242.1.11 -j ACCEPT
iptables -A FORWARD -p tcp --sport 21 -m state --state NEW,ESTABLISHED,RELATED -d 200.242.1.11 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 21 -m state --state ESTABLISHED,RELATED -d 200.242.1.11 -j ACCEPT
iptables -A INPUT -p tcp --sport 1024: --dport 1024: -m state --state ESTABLISHED -d 200.242.1.11 -j ACCEPT
iptables -A FORWARD -p tcp --sport 1024: --dport 1024: -m state --state ESTABLISHED -d 200.242.1.11 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 1024: --dport 1024: -m state --state ESTABLISHED,RELATED -d 200.242.1.11 -j ACCEPT
iptables -A INPUT -p tcp --sport 1024: --dport 1024: -m state --state ESTABLISHED -d 200.165.48.11 -j ACCEPT
iptables -A FORWARD -p tcp --sport 1024: --dport 1024: -m state --state ESTABLISHED -d 200.165.48.11 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 1024: --dport 1024: -m state --state ESTABLISHED,RELATED -d 200.165.48.11 -j ACCEPT
#FIM BANESFACIL
#Maquinas Liberada pelo MAC
iptables -t nat -A PREROUTING -p tcp -m mac --mac-source 00:XX:70:XX:08:XX -j ACCEPT (Tambem tentei mas nao deu certo)
#Libera pelo IP
iptables -A FORWARD -i eth0 -s 192.168.1.102 -j ACCEPT #(tentei mas não deu certo)
# Libera HTTP e HTTPS
iptables -A INPUT -p tcp --dport 80 -j LOG
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j LOG
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# Liberando DNS
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
# Libera conexão via ssh.
iptables -A INPUT -p tcp --dport 22 -j LOG
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 22 -i eth0 -j ACCEPT
# Libera portas pop e smtp
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -A INPUT -p tcp --dport 110 -j ACCEPT
iptables -A INPUT -p tcp --dport 111 -j ACCEPT
iptables -A INPUT -p tcp --dport 113 -j ACCEPT
iptables -A INPUT -p tcp --dport 143 -j ACCEPT
iptables -A INPUT -p tcp --dport 465 -j ACCEPT
iptables -A INPUT -p tcp --dport 587 -j ACCEPT
iptables -A INPUT -p tcp --dport 993 -j ACCEPT
iptables -A INPUT -p tcp --dport 995 -j ACCEPT
#Libera NO-IP
iptables -A INPUT -p tcp --dport 8245 -j ACCEPT
# Libera o acesso via RDP
iptables -A INPUT -i $ifinternet -p tcp -m tcp --dport 3389 -j ACCEPT
# Redireciona RDP porta 3389
#iptables -t nat -A PREROUTING -i $ifinternet -p tcp -m tcp --dport 3389 -j DNAT --to 192.168.1.254
# Redireciona porta do msn para msn-proxy
iptables -t nat -A PREROUTING -i $iflocal -p tcp --dport 1863 -j REDIRECT --to-port 1863
# Redirecionando acesso porta 5900 (VNC) para micro da rede local
#iptables -t nat -A PREROUTING -p tcp -i $ifinternet --dport 5900 -j DNAT --to-destination 192.168.0.1:5900
# Redirecionando acesso porta 5901 (VNC) para micro da rede local
#iptables -t nat -A PREROUTING -p tcp -i $ifinternet --dport 5901 -j DNAT --to-destination 192.168.0.2:5901
# Redirecionamento das Cameras
#iptables -t nat -A PREROUTING -p tcp -i $ifinternet --dport 999 -j DNAT --to-destination 192.168.0.3:999
# Bloqueios
iptables -A FORWARD -m layer7 --l7proto bittorrent -j DROP
# Bloqueando Orkut.
iptables -A FORWARD -d orkut.com -s $ifip -p tcp --dport 80 -j DROP
iptables -A FORWARD -d
www.orkut.com.br">
www.orkut.com.br -s $ifip -p tcp --dport 80 -j DROP
# Bloqueia Orkut pela porta 443
#iptables -t nat -A PREROUTING -s $ifip -d
www.orkut.com -p tcp -m tcp --dport 443 -j DROP
# Bloqueando IloveIM
iptables -A FORWARD -d
www.iloveim.com -p tcp --dport 80 -j DROP
# Bloquenado Ebuddy
iptables -A FORWARD -d
www.ebuddy.com -p tcp --dport 80 -j DROP
iptables -A FORWARD -d
www.ebuddy.com.br -p tcp --dport 80 -j DROP
# Bloquenado MessengerFX
iptables -A FORWARD -d
www.messengerfx.com -p tcp --dport 80 -j DROP
# Bloquenado Webmessbrasil
iptables -A FORWARD -d webmessbrasil.googlepages.com -p tcp --dport 80 -j DROP
# Bloquenado Meebo
iptables -A FORWARD -d
www.meebo.com -p tcp --dport 80 -j DROP
iptables -A FORWARD -d
www.meebo.com.br -p tcp --dport 80 -j DROP
# Bloquenado KoollM
iptables -A FORWARD -d
www.koolim.com -p tcp --dport 80 -j DROP
# Bloquenado Easy Messenger
iptables -A FORWARD -d easymessenger.net -p tcp --dport 80 -j DROP
# Bloqueando Communicatin Tube
iptables -A FORWARD -d
www.communicationtube.net -p tcp --dport 80 -j DROP
# Bloquenado Imunitive
iptables -A FORWARD -d
www.imunitive.com -p tcp --dport 80 -j DROP
# Bloquenado Imo
iptables -A FORWARD -d imo.im -p tcp --dport 80 -j DROP
# Bloqueando Batepapo UOL
iptables -A FORWARD -d batepapo.uol.com.br -p tcp --dport 80 -j DROP
# Bloqueando Batepapo Terra
iptables -A FORWARD -d chat.terra.com.br -p tcp --dport 80 -j DROP
# Bloqueando YouTube
iptables -A FORWARD -d br.youtube.com -p tcp --dport 80 -j DROP
iptables -A FORWARD -d
www.youtube.com -p tcp --dport 80 -j DROP
# Bloqueando
[*****] Tube
iptables -A FORWARD -d
www.pornotube.com -p tcp --dport 80 -j DROP
#bloqueando Perolas do Orkut
iptables -A FORWARD -d
www.perolasdoorkut.com.br -p tcp --dport 80 -j DROP
# Bloqueando Powerscrap.com
iptables -A FORWARD -d
www.power.com -p tcp --dport 80 -j DROP
iptables -A FORWARD -d
www.powerscrap.com -p tcp --dport 80 -j DROP
# Bloqueando Globo Videos
iptables -A FORWARD -d video.globo.com -p tcp --dport 80 -j DROP
# Bloquenado MSN e HOTMAIL
#iptables -A FORWARD -d contacts.msn.com -p tcp --dport 80 -j REJECT
#iptables -A FORWARD -d storage.msn.com -p tcp --dport 80 -j REJECT
#iptables -A FORWARD -d c.msn.com -p tcp --dport 80 -j REJECT
#iptables -A FORWARD -d messenger.msn.com -p tcp --dport 80 -j REJECT
#iptables -A FORWARD -d g.msn.com -p tcp --dport 80 -j REJECT
#iptables -A FORWARD -d messenger.hotmail.com -p tcp --dport 1863 -j REJECT
#iptables -A FORWARD -d edge.messenger.live.com -p tcp --dport 80 -j REJECT
#iptables -A FORWARD -p tcp --dport 1863 -j REJECT
#iptables -A FORWARD -d 64.4.13.0/24 -j REJECT
#iptables -A FORWARD -d 64.12.174.0/24 -j REJECT
#iptables -A FORWARD -d 64.12.163.0/24 -j REJECT
#iptables -A FORWARD -d hotmail.com -p tcp --dport 80 -j REJECT
#iptables -A FORWARD -d mail.live.com -p tcp --dport 80 -j REJECT
#iptables -A FORWARD -d login.live.com -p tcp --dport 80 -j REJECT
# Bloqueando GMAIL
# iptables -A FORWARD -d gmail.com -p tcp --dport 80 -j REJECT
# iptables -A FORWARD -d mail.google.com -p tcp --dport 80 -j REJECT
#Bloquenado Trojans e Virus
iptables -A INPUT -s $ifip -p TCP --dport 666 -j REJECT
iptables -A FORWARD -s $ifip -p TCP --dport 666 -j REJECT
iptables -A FORWARD -s $ifip -p TCP --dport 4000 -j REJECT
iptables -A INPUT -s $ifip -p TCP --dport 4000 -j REJECT
iptables -A FORWARD -s $ifip -p TCP --dport 6000 -j REJECT
iptables -A INPUT -s $ifip -p TCP --dport 6000 -j REJECT
iptables -A FORWARD -s $ifip -p TCP --dport 6006 -j REJECT
iptables -A FORWARD -s $ifip -p TCP --dport 1660 -j REJECT
iptables -A INPUT -s $ifip -p TCP --dport 6006 -j REJECT
iptables -A INPUT -s $ifip -p TCP --dport 1660 -j REJECT
#Bloqueando Emule
iptables -A FORWARD -p tcp -m multiport --dport 4661,4711,4662,4665,4672 -j DROP
iptables -A FORWARD -p udp -m multiport --dport 4662,4672,4665 -j DROP
# Bloqueando IMesh
iptables -A FORWARD -d 216.35.208.0/24 -j DROP
# Bloqueando Bearshare
iptables -A FORWARD -p tcp --dport 6346 -j DROP
# Bloqueando ToadNode
iptables -A FORWARD -p tcp --dport 6346 -j DROP
# Bloqueando WinMX
iptables -A FORWARD -d 209.61.186.0/24 -j DROP
iptables -A FORWARD -d 64.49.201.0/24 -j DROP
# Bloqueando Napigator
iptables -A FORWARD -d 209.25.178.0/24 -j DROP
# Bloqueando Morpheus
iptables -A FORWARD -d 206.142.53.0/24 -j DROP
iptables -A FORWARD -p tcp --dport 1214 -j DROP
# Bloqueando KaZaA
iptables -A FORWARD -d 213.248.112.0/24 -j DROP
iptables -A FORWARD -p tcp --dport 1214 -j DROP
# Bloqueando Limewire
iptables -A FORWARD -p tcp --dport 6346 -j DROP
# Bloqueando Audiogalaxy
iptables -A FORWARD -d 64.245.58.0/23 -j DROP
# Bloqueando AIM
iptables -A FORWARD -p tcp --dport 5190 -j DROP
iptables -A FORWARD -d 64.12.161.153/24 -j DROP
# Bloqueando ICQ
iptables -A FORWARD -p tcp --dport 5190 -j DROP
iptables -A FORWARD -d 205.188.153.121/24 -j DROP
# Bloqueando Yahoo Messenger
iptables -A FORWARD -d 216.136.233.138/24 -j DROP
# Bloqueando Napster
iptables -A FORWARD -d 64.124.41.0/24 -j DROP
# Bloqueando Bittorent
iptables -A FORWARD -p tcp --dport 6881:6889 -j DROP
iptables -A FORWARD -p tcp --dport 6881:6889 -j DROP
echo "Regras ATIVA"
}
parar(){
iptables -F
iptables -F FORWARD
iptables -F -t nat
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -X
echo "Regras DESATIVADA"
}
case "$1" in
"start") iniciar ;;
"stop") parar ;;
"restart") parar; iniciar ;;
*) echo "Use os parâmetros start ou stop"
esac