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

Re: Redirecionar conexão com iptables



Tenta Assim

iptables -A INPUT -p tcp --dport 80 -j ACCEPT # aceita conexões na
porta 80
iptables -A FORWARD -p tcp --dport 80 -j ACCEPT # libera FOWARD da
porta 80
iptables -A FORWARD -i eth0 -s 192.168.6.0/24 -o eth1 -d 0/0 -j ACCEPT
# libera o FOWARD da eth0 para a eth1 caso tenha mais de uma placa de
rede
iptables -t nat -A PREROUTING -d 192.168.6.6 -p tcp --dport 80 -j DNAT
--to 192.168.6.205:80 # redireciona todo o trafego da porta 80 do ip
192.168.6.6 para 192.168.6.205
iptables -t nat -A POSTROUTING -s 192.168.6.205 -p tcp --sport 80 -j
SNAT --to 192.168.6.6:80 # redireciona a resposta na porta 80 do ip
192.168.6.205 para 192.168.6.6

On 25 jan, 17:00, Márcio Erli <marcioe...@gmail.com> wrote:
> 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: marcioe...@gamil.com
> Site:www.marcioerli.com.br
> MSN: merlipa...@hotmail.com
> Skype: merlipaula
> Telefone: (31)8864-4917


Reply to: