rpsimoes
(usa Debian)
Enviado em 27/10/2011 - 03:16h
Pessoal,
Preciso acessar do meu trabalho duas maquinas distintas via SSH: O servidor internet (192.168.0.1) e outra maquina linux (192.168.0.51).
A primeira serah acessada pela porta 22, a segunda, pela porta 2222, ocorre que consigo acessar apenas o servidor mas não a maquina Linux.
Por favor deem uma olhada no script abaixo para apontar onde estou errando.
#!/bin/sh
#Internet=eth0
#Rede Interna=eth1, ppp0
# Ativa modulos
modprobe ip_tables
modprobe iptable_nat
modprobe ip_conntrack
modprobe ip_nat_ftp
modprobe ipt_REJECT
modprobe ipt_MASQUERADE
# Zera regras
iptables -F
iptables -X
iptables -F -t nat
iptables -X -t nat
iptables -F -t filter
iptables -X -t filter
# Determina a politica padrao
iptables -P INPUT DROP
iptables -P FORWARD DROP
# Aceita os pacotes que realmente devem entrar
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Controle de acesso IP X MAC
# Cliente 1: iktvs-001 (Micro Linux)
iptables -t filter -A FORWARD -d 0/0 -s 192.168.0.51 -m mac --mac-source 00:BF:C6:F9:A9:B1 -j ACCEPT
iptables -t filter -A FORWARD -d 192.168.0.51 -s 0/0 -j ACCEPT
iptables -t filter -A INPUT -s 192.168.0.51 -d 0/0 -m mac --mac-source 00:BF:C6:F9:A9:B1 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.0.51 -o ppp0 -j MASQUERADE
# Cliente 2: iktvs-002 (Micro Windows)
iptables -t filter -A FORWARD -d 0/0 -s 192.168.0.52 -m mac --mac-source A0:0E:A6:9F:41:99 -j ACCEPT
iptables -t filter -A FORWARD -d 192.168.0.52 -s 0/0 -j ACCEPT
iptables -t filter -A INPUT -s 192.168.0.52 -d 0/0 -m mac --mac-source A0:0E:A6:9F:41:99 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.0.52 -o ppp0 -j MASQUERADE
# Cliente 3: iktvs-003 (Notebook) - Rede Cabeada
iptables -t filter -A FORWARD -d 0/0 -s 192.168.0.53 -m mac --mac-source 80:EE:73:0C:87:B5 -j ACCEPT
iptables -t filter -A FORWARD -d 192.168.0.53 -s 0/0 -j ACCEPT
iptables -t filter -A INPUT -s 192.168.0.53 -d 0/0 -m mac --mac-source 80:EE:73:0C:87:B5 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.0.53 -o ppp0 -j MASQUERADE
#
# Aceita ping externo
#
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
#
# Aceita conexao externa via SSH
#
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
#
# Redirecionamento de portas
#
# O REDIRECIONAMENTO ABAIXO NAO ESTAH DANDO CERTO (SSH PORTA 2222)
# Redirecionando a porta 2222 (SSH) na conexao com a internet (ppp0) para o micro 192.168.0.51 (Micro Linux)
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 2222 -j DNAT --to-dest 192.168.0.51
iptables -A FORWARD -p tcp -i ppp0 --dport 2222 -d 192.168.0.51 -j ACCEPT
# Redirecionando a porta 3389 (Windows Terminal Server) na conexao com a internet (ppp0) para o micro 192.168.0.54 (Notebook-Windows)
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 3389 -j DNAT --to-dest 192.168.0.52
iptables -A FORWARD -p tcp -i ppp0 --dport 3389 -d 192.168.0.52 -j ACCEPT
# Compartilha a conexao
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 80 -j REDIRECT --to 3128
#Fecha o resto
iptables -A INPUT -j DROP
iptables -A FORWARD -j DROP