[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Redirecionar conexão com iptables



O que esta de errado neste meu redirecionamento? Eu quero que toda vez que alguem vindo da minha rede 6 digitar no browser o endereço 192.168.6.6 seja exibido no browser a página hospedada no servidor 192.168.6.205

#------------------------------- Redireciona conexao --------------
iptables -t nat -A PREROUTING -s 192.168.6.0/24 -i eth0 -d 192.168.6.6 -p tcp --dport 80 -j DNAT --to 192.168.6.205
iptables -t nat -A POSTROUTING -s 192.168.6.0/24 -o eth0 -d 192.168.6.6 -p tcp --dport 80 -j SNAT --to 192.168.6.205


modprobe iptable_nat

#--------------------- Limpando regras ----------------------------
iptables -F
iptables -X
iptables -Z
iptables -t nat -F
iptables -t nat -X
iptables -t nat -Z
iptables -t mangle -F
iptables -t mangle -X

#----------------------- Negando todo trafico ---------------------
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

#----------------------- Liberando LO -----------------------------
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp --syn -s 127.0.0.1/255.0.0.0 -j ACCEPT

#--- Liberando pacotes que realmente devem estabelecer conexao ----
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT

#---------------------------- Liberando ping ----------------------
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT

#------------------------------ Liberar DNS -----------------------
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT

#------------------------------- Redireciona conexao --------------
iptables -t nat -A PREROUTING -s 192.168.6.0/24 -i eth0 -d 192.168.6.6 -p tcp --dport 80 -j DNAT --to 192.168.6.205
iptables -t nat -A POSTROUTING -s 192.168.6.0/24 -o eth0 -d 192.168.6.6 -p tcp --dport 80 -j SNAT --to 192.168.6.205

#------------------ Libera SSD para todo mundo --------------------
iptables -A INPUT -p tcp --dport 22 -j ACCEPT


--
-----------------------
Atenciosamente,
Márcio Erli
E-Mail: marcioerli@gamil.com
Site: www.marcioerli.com.br
MSN: merlipaula@hotmail.com
Skype: merlipaula
Telefone: (31)8864-4917

Reply to: