#!/bin/sh
##NOTAS:
##eth2 ES LA INTERFAZ CONTECTADA AL ROUTER Y eth1 A LA LAN
#Activacion de el reenvio
echo 1 > /proc/sys/net/ipv4/ip_forward
#FLUSH de reglas
iptables -F
iptables -X
iptables -t nat -F
#Establecemos politica por defecto
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
#acceso localhost
/sbin/iptables -A INPUT -i lo -j ACCEPT
#Redirecciona puertos de forma local. ( en el mismo equipo )
#iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 80 -j REDIRECT --to 192.168.2.x:9050
# Se aplica la mascara 192.168.1.x a los paquetes que tengan red de origen 192.168.2.0/24 y que tengan salida por eth2
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o eth2 -j SNAT --to 192.168.1.x
# PREROUTING de puertos para llegar hasta servidores internos de forma remota.
iptables -t nat -A PREROUTING -p tcp --dport 80 -i eth2 -j DNAT --to 192.168.2.x
iptables -t nat -A PREROUTING -p udp --dport 80 -i eth2 -j DNAT --to 192.168.2.x
iptables -t nat -A PREROUTING -p tcp --dport 9050 -i eth2 -j DNAT --to 192.168.2.x
iptables -t nat -A PREROUTING -p tcp --dport 22 -i eth2 -j DNAT --to 192.168.2.x
iptables -t nat -A PREROUTING -p tcp --dport 5900 -i eth2 -j DNAT --to 192.168.2.x
#IP's CON ACCESO
iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
#IP's EXTRAS
iptables -t filter -A FORWARD -s 192.168.2.5 -p ALL -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.2.21 -p ALL -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.2.31 -p ALL -j ACCEPT
#SERVIDORES
iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
#TELEFONOS
iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
iptables -t filter -A FORWARD -s 192.168.2.x -p ALL -j ACCEPT
# Permite Web
iptables -t filter -A FORWARD -d x.x.x.x -p ALL -j ACCEPT
# Permite a una ip interna navegar a un sitio bloqueado para el resto
iptables -t filter -A FORWARD -s 192.168.2.27 -d login.live.com -p ALL -j ACCEPT
# Permite Google y Deniega Gmail y Youtube
iptables -t filter -A FORWARD -d 74.125.224.52 -p ALL -j ACCEPT
iptables -t filter -A FORWARD -d 74.125.224.51 -p ALL -j ACCEPT
iptables -t filter -A FORWARD -d 74.125.224.50 -p ALL -j ACCEPT
iptables -t filter -A FORWARD -d 74.125.224.49 -p ALL -j ACCEPT
iptables -t filter -A FORWARD -d 74.125.224.48 -p ALL -j ACCEPT
iptables -t filter -A FORWARD -d 74.125.224.0/24 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 74.125.239.0/24 -p ALL -j REJECT
# Bloque FACEBOOK
iptables -t filter -A FORWARD -d 69.171.0.0/16 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 69.171.228.0/24 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 69.171.224.0/24 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 69.171.229.11 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 69.171.242.11 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 66.220.149.11 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 66.220.158.11 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 66.220.147.44 -p ALL -j REJECT
# Bloqueo Hotmail
iptables -t filter -A FORWARD -d 65.55.72.0/24 -p ALL -j REJECT
# Bloqueo MSN Live Messenger
iptables -t filter -A FORWARD -d 65.55.60.123 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 65.54.239.211 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 65.54.186.0/24 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 65.54.165.0/24 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 65.54.227.242 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 64.4.45.62 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 64.4.56.183 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 64.4.56.199 -p ALL -j REJECT
# Bloqueo Fotolog
iptables -t filter -A FORWARD -d 63.171.185.196 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 63.166.124.68 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 207.109.73.99 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 207.109.73.106 -p ALL -j REJECT
# Bloqueo elblogdelnarco
iptables -t filter -A FORWARD -d 64.202.189.170 -p ALL -j REJECT
# BLOQUE WEB BASED MESSENGER
iptables -t filter -A FORWARD -d 38.99.72.233 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 38.99.72.232 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 74.63.220.238 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 64.13.161.61 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 74.114.28.110 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 208.81.191.110 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 208.109.186.152 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 99.192.249.209 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 85.17.78.163 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 74.208.12.174 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 173.45.74.55 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 66.135.39.98 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 82.98.86.167 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 174.142.232.238 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 74.86.15.130 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 205.186.183.218 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 72.233.64.227 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 75.103.119.199 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 68.180.190.124 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 74.86.129.114 -p ALL -j REJECT
# Bloque Chatroom
iptables -t filter -A FORWARD -d 74.207.248.124 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 204.62.114.37 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 72.249.29.17 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 91.121.36.253 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 63.150.3.212 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 74.201.112.85 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 74.201.113.175 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 74.201.154.149 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 188.40.80.245 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 184.173.90.186 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 50.23.244.0/24 -p ALL -j REJECT
iptables -t filter -A FORWARD -d 50.23.245.0/24 -p ALL -j REJECT
# Bloquear Puertos MSN
iptables -t filter -A FORWARD -d 0/0 -p tcp --dport 1863 -j REJECT
iptables -t filter -A FORWARD -d 0/0 -p udp --dport 1863 -j REJECT
iptables -t filter -A FORWARD -d 0/0 -p tcp --dport 6891:6900 -j REJECT
echo "EJECUTA iptables -L -n PARA COMPROBAR LAS REGLAS"
echo ""