NegroZed
(usa Ubuntu)
Enviado em 24/02/2012 - 03:40h
Cara não funcionou
Segue meu script;
#!/bin/bash
# Shell Script - Firewall
#
# // DEFINE AS VARIAVEIS
# ----------------------
IPT=/sbin/iptables # :> IPTABLES
WAN=eth0 # :> CONEXAO EXTERNA
LAN=eth1 # :> CONEXAO LOCAL
FWL=192.168.0.100 # :> IP DO FIREWALL
RDT=192.168.0.2 # :> REMOTE DESKTOP
DVR=192.168.0.3 # :> CAMERAS (DVR)
RED=192.168.0.0/24 # :> FAIXA DA REDE
#
# // CARREGANDO MODULOS
# ---------------------
module[0]="iptable_filter"
module[1]="iptable_nat"
module[2]="iptable_mangle"
for ((n=0;$n<=2;n++)); do
if [ "`lsmod | grep ${module[$n]}`" = "" ]; then
/sbin/modprobe ${module[$n]}
echo "Modulo ${module[$n]} carregado."
fi
done
. /lib/lsb/init-functions
#
# // MASCARAMENTO
# ---------------
$IPT -t nat -A POSTROUTING -o $WAN -j MASQUERADE
#
# // COMPARTILHA INTERNET
# -----------------------
echo 1 > /proc/sys/net/ipv4/ip_forward
do_start () {
#
# // POLITICA PADRAO
# ------------------
$IPT -P INPUT ACCEPT
$IPT -P OUTPUT ACCEPT
$IPT -P FORWARD ACCEPT
#
# // BLOQUEIO MSN & HOTMAIL
# -------------------------
$IPT -A FORWARD -s $RED -p tcp --dport 1863 -j REJECT
$IPT -A FORWARD -s $RED -d loginnet.passport.com -j REJECT
$IPT -A FORWARD -s $RED -d messenger.hotmail.com -j REJECT
$IPT -A FORWARD -s $RED -d webmessenger.msn.com -j REJECT
$IPT -A FORWARD -p tcp --dport 1080 -j DROP
$IPT -A FORWARD -s $RED -p tcp --dport 1080 -j REJECT
#
#
# // PROTECOES
# ------------
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
echo 1 > /icmp_echo_ignore_broadcasts
echo 1 > /icmp_ignore_bogus_error_responses
echo 0 > /accept_redirects
echo 0 > /accept_source_route
echo 1 > /log_martians
echo 1 > /rp_filter
#
# // LIBERA MAC'S DA DIRETORIA
# ----------------------------
# // PRISCILA
$IPT -t nat -I PREROUTING -i $LAN -m mac --mac-source 3C:07:54:20:5C:28 -p tcp --dport 80 -j ACCEPT
$IPT -t nat -I PREROUTING -i $LAN -m mac --mac-source 60:c5:47:8c:0a:3e -p tcp --dport 80 -j ACCEPT
# // JOIA
$IPT -t nat -I PREROUTING -i $LAN -m mac --mac-source 00:1A:92:EE:CF:1B -p tcp --dport 80 -j ACCEPT
# // REDIRECIONA PORTA DO PORTA SQUID
# -----------------------------------
$IPT -t nat -A PREROUTING -i $LAN -p tcp --dport 80 -j REDIRECT --to-port 3128
# // REDIRECIONA REQUISOCOES DO REMOTE DESKTOP
# --------------------------------------------
$IPT -t nat -A PREROUTING -p tcp -i $WAN --dport 3389 -j DNAT --to $RDT:3389
# // REDIRECIONA ACESSO EXTERNO - CAMERAS
# ----------------------------------------
#########
## $IPT -t nat -A PREROUTING -i $WAN -p tcp --dport 5193 -j DNAT --to $DVR:5193
## $IPT -t nat -A PREROUTING -i $WAN -p udp --dport 5193 -j DNAT --to $DVR:5193
## $IPT -t nat -A POSTROUTING -p tcp -d $DVR --dport 5193 -j SNAT --to $FWL
## $IPT -t nat -A POSTROUTING -p udp -d $DVR --dport 5193 -j SNAT --to $FWL
## --------------------------------------------------------
## $IPT -A FORWARD -p tcp -d $DVR --dport 5193 -j ACCEPT
## $IPT -t nat -A PREROUTING -p tcp -i $WAN --dport 5193 -j DNAT --to $DVR:5193
##########
$IPT -t nat -A PREROUTING -p tcp -i $WAN --dport $5193 -j DNAT --to $DVR:5193
$IPT -t nat -A PREROUTING -p udp -i $WAN --dport $5193 -j DNAT --to $DVR:5193
$IPT -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A FORWARD -p tcp --dport $5193 -j ACCEPT
$IPT -A FORWARD -p udp --dport $5193 -j ACCEPT
$IPT -t nat -A PREROUTING -p tcp -i $WAN --dport $6036 -j DNAT --to $DVR:6036
$IPT -t nat -A PREROUTING -p udp -i $WAN --dport $6036 -j DNAT --to $DVR:6036
$IPT -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A FORWARD -p udp --dport $6036 -j ACCEPT
# // LIBERA ACESSO EXTERNO AO FIREWALL
# ------------------------------------
$IPT -t nat -A PREROUTING -p tcp -i $WAN --dport 10000 -j DNAT --to $FWL:10000
$IPT -t nat -A PREROUTING -p tcp -i $WAN --dport 22 -j DNAT --to $FWL:22
#
}
do_stop () {
# Política
$IPT -P INPUT ACCEPT
$IPT -P OUTPUT ACCEPT
$IPT -P FORWARD ACCEPT
}
case "$1" in
start)
log_daemon_msg "Firewall Iniciado"
do_start
log_end_msg $?
;;
stop)
log_daemon_msg "Firewall Finalizado"
do_stop
log_end_msg $?
;;
reload)
exit 1
esac
exit 0