Queridos debianeros me pasa que cuando quiero usar el sacript que lo muestro
mas abajo, no anda tambien como deberia por como esta armado el tema es que
tengo 2 ip publicas con 2 servidores, uno de mail y otro de web y puse un
firewall adelante para solo abrir los puertos que uso el tema es que sola
mente me manda todo prar una sola cpu y no se por que cuando apunto a una ip
y tendria que ir al server de mail anda perfecto pero cuando apunto a el
server web no funca o me manda a el otro servidor (mail) y no quiero, asi
que por eso los molesto si serian tan amables de darme una ayudita les
agradeceria y por favor no me gasten al decirme man iptables por que ya lo
lei y no le encuentro la manera.

Saludos.

SCRIPT

#!/bin/bash
IP='iptables'

# cargo los modulos
# marcalos con numeral si ya estan cargados
#insmod ip_tables
#insmod ip_conntrack
#insmod iptable_nat
#insmod ipt_MASQUERADE
#Placa eth0= IP externa x.x.x.x/x (server Web)
#Placa eth1= IP externa x.x.x.x/x (server Mail)
#Placa eth2= IP Interna 192.168.0.1/24 (Firewall)
#IP server Web  192.168.2.18/24
#IP server Mail 192.168.2.19/24

# borro todas las reglas anteriores
$IP -F
$IP -t nat -F

# en la tabla nat  (-t nat), agrego la regla (-A) routing
# (POSTROUTING) para que todos los paquetes salgan por eth0 (-o eth0 o eth1)
# MASQUERADE la coneccion (-j MASQUERADE).

$IP -t nat -A POSTROUTING -o eth0 -j MASQUERADE
$IP -t nat -A POSTROUTING -o eth1 -j MASQUERADE


# ruteo 192.168.0.x'
$IP -t nat -A POSTROUTING -d ! 192.168.2.0/24 -j MASQUERADE

$IP -A FORWARD -s 192.168.2.0/24 -j ACCEPT
$IP -A FORWARD -d 192.168.2.0/24 -j ACCEPT
$IP -A FORWARD -s ! 192.168.2.0/24 -j DROP

# Disallow NEW e INVALID incoming or forwarded packets from eth0
$IP -A INPUT -i eth0 -m state --state NEW,INVALID -j DROP
$IP -A FORWARD -i eth0 -m state --state NEW,INVALID -j DROP

# Disallow NEW e INVALID incoming or forwarded packets from eth1
$IP -A INPUT -i eth1 -m state --state NEW,INVALID -j DROP
$IP -A FORWARD -i eth1 -m state --state NEW,INVALID -j DROP

# tiro todo lo que llega al port 113
$IP -A INPUT --protocol udp --source-port 113 -j DROP
$IP -A INPUT --protocol udp --destination-port 113 -j DROP

# arranco IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

# desvio las entradas de eth0 al port 80, hacia una
#maquina que existe ej.: 192.168.2.18:80 (server Web)
$IP -A PREROUTING -t nat -p tcp -i eth0 --dport 80 -j DNAT --to
192.168.2.18:80
$IP -A PREROUTING -t nat -p tcp -i eth0 --dport 21 -j DNAT --to
192.168.2.18:21
$IP -A PREROUTING -t nat -p tcp -i eth0 --dport 5631 -j DNAT --to
192.168.2.18:5631

# lo mismo con el port 21 y otros
#maquina que existe ej.: 192.168.2.19:110 (server Mail)
$IP -A PREROUTING -t nat -p tcp -i eth1 --dport 21 -j DNAT --to
192.168.2.19:21
$IP -A PREROUTING -t nat -p tcp -i eth1 --dport 110 -j DNAT --to
192.168.2.19:110
$IP -A PREROUTING -t nat -p tcp -i eth1 --dport 25 -j DNAT --to
192.168.2.19:25
$IP -A PREROUTING -t nat -p tcp -i eth1 --dport 143 -j DNAT --to
192.168.2.19:143
$IP -A PREROUTING -t nat -p tcp -i eth1 --dport 80 -j DNAT --to
192.168.2.19:80
$IP -A PREROUTING -t nat -p tcp -i eth1 --dport 5631 -j DNAT --to
192.168.2.19:5631

Responder a