On Jan 26, 2005, at 9:36 AM, Nelson Lopez wrote:

Hola amigos;


Hola

Sistema : Debian Sarge 3.1
Kernel : 2.4.27-1-386


lindo

les escribo este email pidiendo ayuda a ustedes ya que me he quebrado la
cabeza ya mas de 3 dias enteros sin descanso ni siquiera colacion =/..


les cuento tengo la necesidad de montar en mi trabajo un firewall que
proteja mis servidores y mi red interna por ejemplo



                   inet
                     |
                     |
                   eth0 ( ip publica fija )
                     |
                     |
               -------------
               | linux box |-------- eth2 ( LAN )------ XXXXX
               -------------
              /
             /
            eth1 ( dmz )
           192.168.10.99/255.255.255.0
            |
            |
            |
          eth0 ( WWW )
192.168.10.100/255.255.255.0


Este correo posiblemente est'e fuera de lugar, me disculpo por anticipado si lo creen as'i. Pero hay dos cosas que me llaman la atenci'on: "oficina" y "3 dias enteros sin descanso": y siento empat'ia por ti.


Si lo tienes que hacer en tu trabajo, yo te sugiero que utilices algo que te ordene mejor las cosas. En el tiempo, no solo necesitar'as colocar una DMZ, sino que de repente necesitar'as hacer redirecciones, cambios de puertos y proxies a nivel de aplicaci'on. Despu'es vendr'an las VPNs, despu'es vendr'a el ruteo din'amico y despu'es el failover y el split access. Depu'es la VoIP y con ello el tema de servicios diferenciados y calidad de servicio. Depu'es vendr'a alguien que quiere saber el uso (y abuso) de Internet y te pedir'a un registro, y luego alguien m'as te pedir'a los registros resumidos. Despu'es alguien te querr'a vender un IDS pero tu lo resolver'as con tu firewall en Debian, etc. etc. etc. .... y nunca acaba.

Trabajar directamente con iptables, ip, tc o ipsec puede ser frustrante. Yo te sugiero que uses una herramienta hecha para hacer firewalls. Shorewall ha sido una gran ayuda en tiempos como los que seguramente vives hoy. Todos los archivos est'an muy bien documentados y tienen ejemplos.

Paso 1: apt-get install shorewall
Paso 2: cp /usr/share/doc/shorewall/default-config/* /etc/shorewall/
Paso 3: cd /etc/shorewall; gunzip *gz
Paso 4: Coloca las lineas
eth0    eth1
eth0    eth2
en masq
Paso 5: Coloca las lineas
net eth0
loc eth2
dmz eth1
en interfaces
Paso 6: Coloca (antes del final) de policies
fw all ACCEPT
Paso 7: Coloca una linea del tipo DNAT por cada servicio, en rules

Paso N: continua investigando hasta encontrar la configuracion que te corresponda.

al final pueden ver lo que queda.

El punto que trato de probar es el siguiente. No importa que sea muy complicada o que no sea 'optima, me sirve porque me ordena. El resto la empresa lo compensa con m'as hardware.

Trabajar con iptables es divertido, tambi'en compilar un nucleo y optimizar un sistema. Lo se porque lo hice. Pero eso no puede tomar la totalidad de tu dia, especialmente si tienes otras cosas que hacer. Si quieres hacerlo, participa directamente en el shorewall de debian o en otras herramientas que seguramente son igualmente buenas.

en mi insrtalacion queda lo siguiente. (solo en la tabla de filter: no incluyo las tablas de nat, de manglel, el tc, el ipsec, el openvpn, las interfaces vituales y las otras cosas)

Tambi'en he quitado las referencias a los IPs publicos.


Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
DROP !icmp -- 0.0.0.0/0 0.0.0.0/0 state INVALID
eth0_in all -- 0.0.0.0/0 0.0.0.0/0
eth1_in all -- 0.0.0.0/0 0.0.0.0/0
common all -- 0.0.0.0/0 0.0.0.0/0
LOG all -- 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 6 prefix `Shorewall:INPUT:REJECT:'
reject all -- 0.0.0.0/0 0.0.0.0/0


Chain FORWARD (policy DROP)
target prot opt source destination
DROP !icmp -- 0.0.0.0/0 0.0.0.0/0 state INVALID
TCPMSS tcp -- 0.0.0.0/0 0.0.0.0/0 tcp flags:0x06/0x02 TCPMSS clamp to PMTU
eth0_fwd all -- 0.0.0.0/0 0.0.0.0/0
eth1_fwd all -- 0.0.0.0/0 0.0.0.0/0
common all -- 0.0.0.0/0 0.0.0.0/0
LOG all -- 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 6 prefix `Shorewall:FORWARD:REJECT:'
reject all -- 0.0.0.0/0 0.0.0.0/0


Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
DROP !icmp -- 0.0.0.0/0 0.0.0.0/0 state INVALID
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpts:67:68
fw2all all -- 0.0.0.0/0 0.0.0.0/0
fw2loc all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0


Chain all2all (1 references)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
common all -- 0.0.0.0/0 0.0.0.0/0
LOG all -- 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 6 prefix `Shorewall:all2all:REJECT:'
reject all -- 0.0.0.0/0 0.0.0.0/0


Chain common (4 references)
target prot opt source destination
icmpdef icmp -- 0.0.0.0/0 0.0.0.0/0
reject udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:135
reject udp -- 0.0.0.0/0 0.0.0.0/0 udp dpts:137:139
reject udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:445
reject tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:139
reject tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:445
reject tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:135
DROP udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:1900
DROP all -- 0.0.0.0/0 255.255.255.255
DROP all -- 0.0.0.0/0 224.0.0.0/4
reject tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:113
DROP udp -- 0.0.0.0/0 0.0.0.0/0 udp spt:53 state NEW
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp flags:0x10/0x10
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp flags:0x04/0x04
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp flags:0x01/0x01
DROP all -- 0.0.0.0/0 200.87.125.199
DROP all -- 0.0.0.0/0 192.168.1.255


Chain dynamic (4 references)
target     prot opt source               destination

Chain eth0_fwd (1 references)
target     prot opt source               destination
dynamic    all  --  0.0.0.0/0            0.0.0.0/0          state NEW
net2loc    all  --  0.0.0.0/0            0.0.0.0/0

Chain eth0_in (1 references)
target     prot opt source               destination
dynamic    all  --  0.0.0.0/0            0.0.0.0/0          state NEW
net2fw     all  --  0.0.0.0/0            0.0.0.0/0

Chain eth1_fwd (1 references)
target     prot opt source               destination
dynamic    all  --  0.0.0.0/0            0.0.0.0/0          state NEW
loc2net    all  --  0.0.0.0/0            0.0.0.0/0

Chain eth1_in (1 references)
target prot opt source destination
dynamic all -- 0.0.0.0/0 0.0.0.0/0 state NEW
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpts:67:68
loc2fw all -- 0.0.0.0/0 0.0.0.0/0


Chain fw2all (2 references)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0


Chain fw2loc (1 references)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT tcp -- 0.0.0.0/0 192.168.1.62 state NEW tcp dpt:22
ACCEPT tcp -- 0.0.0.0/0 192.168.1.62 state NEW tcp dpt:80
fw2all all -- 0.0.0.0/0 0.0.0.0/0


Chain icmpdef (1 references)
target     prot opt source               destination

Chain loc2fw (1 references)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:25
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 state NEW udp dpt:53
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:53
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:110
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:143
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0


Chain loc2loc (0 references)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT tcp -- 0.0.0.0/0 192.168.1.62 state NEW tcp dpt:22
ACCEPT tcp -- 0.0.0.0/0 192.168.1.62 state NEW tcp dpt:80
all2all all -- 0.0.0.0/0 0.0.0.0/0


Chain loc2net (1 references)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0


Chain net2all (2 references)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
common all -- 0.0.0.0/0 0.0.0.0/0
LOG all -- 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 6 prefix `Shorewall:net2all:DROP:'
DROP all -- 0.0.0.0/0 0.0.0.0/0


Chain net2fw (1 references)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:25
ACCEPT tcp -- XXXXX 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp -- XXXX 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp -- 1XXX 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT all -- 166.XXXX 0.0.0.0/0 state NEW
ACCEPT tcp -- XXXXX 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp -- XXXXX 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp -- 20XXXX4.26 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp -- 20XXXX.50 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT all -- 20XXXX1 0.0.0.0/0 state NEW
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 state NEW udp dpt:53
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:53
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:110
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:143
ACCEPT all -- 20XXXX95 0.0.0.0/0 state NEW
ACCEPT all -- 20XXXXX96 0.0.0.0/0 state NEW
ACCEPT all -- 20XXXXX97 0.0.0.0/0 state NEW
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 state NEW udp dpt:5060
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:5060
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:4569
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 state NEW udp dpt:4569
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 state NEW udp dpts:17400:25000
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 state NEW udp dpts:23000:24999
net2all all -- 0.0.0.0/0 0.0.0.0/0


Chain net2loc (1 references)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
ACCEPT tcp -- 0.0.0.0/0 192.168.1.62 state NEW tcp dpt:22
ACCEPT tcp -- 0.0.0.0/0 192.168.1.62 state NEW tcp dpt:80
net2all all -- 0.0.0.0/0 0.0.0.0/0


Chain reject (10 references)
target prot opt source destination
REJECT tcp -- 0.0.0.0/0 0.0.0.0/0 reject-with tcp-reset
REJECT udp -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
REJECT icmp -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-unreachable
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited





para esto he estado probando muchos scripts y otros que he ido haciendo
yo y que no funcionan. *raro* ya que las reglas se ven si hago un
*iptables -nvL � iptables -t nat -nvL*, sinceramente no se que pasa !.

pueden echarme una mano amigos ? � quisas darme alguna guia o algo por
el estilo ?.-.


aqui pego el ultimo script que estube probando,


rei:~# cat dmz_fwl_lan
#!/bin/bash
################## Habilitando eht1 ####################
puerto_dmz="eth1"
ip_dmz="192.168.10.99"
ifconfig $puerto_dmz down
ifconfig $puerto_dmz $ip_dmz netmask 255.255.255.0 up
#ifconfig $puerto_dmz up
#########################################################
################## Reglas de Basicas ####################
iptables -F
#iptables -X
iptables -F -t nat
#iptables -X -t nat
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE -s 192.168.10.0/24
iptables -P FORWARD DROP
iptables -A FORWARD -j ACCEPT -p UDP
iptables -A FORWARD -j ACCEPT -p ICMP
iptables -A FORWARD -mstate --state NEW,ESTABLISH,RELATED -j ACCEPT


modprobe ip_nat_irc
modprobe ip_nat_ftp
modprobe ip_conntrack_ftp
modprobe ip_conntrack_irc

echo "1" > /proc/sys/net/ipv4/ip_forward
#########################################################
################ Servicios ###############################
PORT_USR="21 22 25 53 80 110 443 8080"
   for PORT in $PORT_USR; do
   iptables -A FORWARD -p tcp --dport $PORT -j ACCEPT
   done
##########################################################
################ DMZ #####################################
IP_EXT="200.72.xxx.yyy"
IP_DMZ="192.168.10.100"
PORT_DMZ="80 20 21 22 25 110 443 8080"
   for PORT_DEMEZETA in $PORT_DMZ; do
     iptables -t nat -A PREROUTING -i eth0 -d $IP_EXT -p TCP --dport
$PORT_DEMEZ ETA -j DNAT --to-destination $IP_DMZ
   done

##########################################################
rei :~#

Disculpen lo largo de este Email. pero ya me he vuelto loco :(..

Nelson Lopez V.



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Responder a