franklin.farias
(usa CentOS)
Enviado em 03/02/2011 - 10:17h
Não consigo acessar FTP, há algo errado na configuração do firewall?
#!/bin/bash
IPTABLES=iptables
ETHLAN=eth0
ETHWAN=eth1
SERVERCBB=10.1.1.2
SERVERINTERNET=10.1.1.4
LAN=10.1.1.0/32
IPINTERNET=$ip_dedicado_fornecido_operadora$
echo ---------------------------------------
### Inicio do Script ###
echo Iniciando Script de Seguranca - Firewall
echo Limpando configuracoes antigas
$IPTABLES -F
$IPTABLES -X
$IPTABLES -P INPUT ACCEPT
$IPTABLES -t nat -F
$IPTABLES -t nat -X
$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -P OUTPUT ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT
### ICMP ###
echo ICMP :: Liberando
$IPTABLES -A INPUT -p icmp -j ACCEPT
$IPTABLES -t nat -A POSTROUTING -p icmp -j MASQUERADE
### IP nao passar pelo Firewall ###
echo IPs sem Firewall
#$IPTABLES -t nat -I PREROUTING -s 192.168.0.105 -j ACCEPT
#$IPTABLES -t nat -A POSTROUTING -s 192.168.0.105 -o $ETHWAN -p tcp -j MASQUERADE
### Conectividade Social ###
echo Conectividade Social
$IPTABLES -t nat -A POSTROUTING -s $LAN -d 200.201.174.0/24 -j SNAT --to-source $IPINTERNET
$IPTABLES -A INPUT -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -s $LAN -d 0/0 -p tcp --dport 80
$IPTABLES -A INPUT -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -s $LAN -d 0/0 -p tcp --dport 3128
### FTP ###
echo FTP :: Liberando
$IPTABLES -A INPUT -p tcp --dport 20 -s $LAN -j ACCEPT
$IPTABLES -A INPUT -p tcp --dport 21 -s $LAN -j ACCEPT
$IPTABLES -A INPUT -p udp --dport 20 -s $LAN -j ACCEPT
$IPTABLES -A INPUT -p udp --dport 21 -s $LAN -j ACCEPT
$IPTABLES -t nat -A POSTROUTING -s $LAN -p udp --dport 20 -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -s $LAN -p tcp --dport 21 -j MASQUERADE
### SSH ###
echo SSH :: Liberando
$IPTABLES -A INPUT -p tcp --dport 22 -s $LAN -j ACCEPT
#$IPTABLES -A INPUT -p tcp --dport 22 -j ACCEPT
### DNS ###
echo DNS :: Liberando
$IPTABLES -A INPUT -p udp --dport 53 -j ACCEPT
$IPTABLES -A INPUT -p tcp --dport 53 -j ACCEPT
$IPTABLES -A INPUT -p udp --sport 53 -j ACCEPT
$IPTABLES -A INPUT -p tcp --sport 53 -j ACCEPT
$IPTABLES -t nat -A POSTROUTING -p udp --dport 53 -j MASQUERADE
### SQUID ###
echo SQUID :: Liberando
$IPTABLES -A INPUT -p tcp --dport 3128 -i $ETHLAN -j ACCEPT
echo SQUID :: Proxy Transparente
$IPTABLES -t nat -A PREROUTING -i $ETHLAN -p tcp --dport 80 -j REDIRECT --to-port 3128
echo SQUID :: Bloqueando Acesso Externo
$IPTABLES -A INPUT -p tcp -i $ETHWAN --dport 3128 -j DROP
$IPTABLES -A INPUT -i $ETHWAN -m state --state ! ESTABLISHED,RELATED -j DROP
### SSL ###
echo SSL :: Liberando
$IPTABLES -A INPUT -p tcp --dport 443 -j ACCEPT
$IPTABLES -A INPUT -p tcp --sport 443 -j ACCEPT
### Portas utilizadas por alguns sites ###
echo PORTAS SITES :: Liberando
$IPTABLES -A INPUT -p tcp --dport 8000:8088 -j ACCEPT
$IPTABLES -A INPUT -p tcp --sport 8000:8088 -j ACCEPT
### Nat MAIL ###
echo NAT Mail
$IPTABLES -t nat -A POSTROUTING -p tcp --dport 25 -s $LAN -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -p tcp --dport 110 -s $LAN -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -p udp --dport 110 -s $LAN -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -p tcp --dport 465 -s $LAN -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -p udp --dport 465 -s $LAN -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -p tcp --dport 995 -s $LAN -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -p udp --dport 995 -s $LAN -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -p tcp --dport 587 -s $LAN -j MASQUERADE
### Forward TerminalService ###
echo Terminal Server :: Liberando
$IPTABLES -t nat -A PREROUTING -i $ETHWAN -p tcp --sport 1024:65535 --dport 3389 -j DNAT --to-destination $SERVERCBB
$IPTABLES -A FORWARD -i $ETHWAN -o $ETHLAN -p tcp --sport 1024:65535 --dport 3389 -m state --state NEW -j ACCEPT
### Forward VNC ###
echo VNC :: Liberando
$IPTABLES -t nat -A PREROUTING -i $ETHWAN -p tcp --sport 1024:65535 --dport 5800 -j DNAT --to-destination $SERVERINTERNET
$IPTABLES -A FORWARD -i $ETHWAN -o $ETHLAN -p tcp --sport 1024:65535 --dport 5800 -m state --state NEW -j ACCEPT
$IPTABLES -t nat -A PREROUTING -i $ETHWAN -p tcp --sport 1024:65535 --dport 5900 -j DNAT --to-destination $SERVERINTERNET
$IPTABLES -A FORWARD -i $ETHWAN -o $ETHLAN -p tcp --sport 1024:65535 --dport 5900 -m state --state NEW -j ACCEPT
### Bloquear todas as outras portas
echo Bloquear todas as outras portas
#$IPTABLES -P INPUT DROP
#$IPTABLES -t nat -A POSTROUTING -j MASQUERADE
echo Fim da configuração do Firewall...
echo ---------------------------------------
Fiz a liberação da porta 21, mas mesmo assim não consigo acessar. Preciso liberar este acesso para toda a minha rede.