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

Dúvidas com as Políticas do Iptables



 

Bom dia.

 

Pessoal gostaria de um help com relação as políticas do Iptables. Abaixo configurei as políticas mas após subir a máquina não foi possível acessar os serviços, acho que está bloqueando tudo pois sem as políticas o acesso é possível. Alguém poderia dar uma dica ?

 

 

Firewall - Iptables

 

Política de Firewall

 

# Definir política padrão: 

 iptables ?t filter -P INPUT DROP

 iptables ?t filter -P OUTPUT ACCEPT

 iptables ?t filter -P FORWARD DROP

 

# Habilitar repasse de pacote

 echo 1 > /proc/sys/net/ipv4/ip_forward

 

# Liberar acesso a internet para as redes

 iptables -t nat -A POSTROUTING -s 192.168.xx.0/24 -o eth0 -j MASQUERADE

 iptables -t nat -A POSTROUTING -s 192.168.xx.0/24 -o eth0 -j MASQUERADE

 iptables -t nat -A POSTROUTING -s 192.168.xx.0/24 -o eth0 -j MASQUERADE

 iptables -t nat -A POSTROUTING -s 192.168.xx.0/24 -o eth0 -j MASQUERADE

 iptables -t nat -A POSTROUTING -s 192.168.xx.0/24 -o eth0 -j MASQUERADE

 

# interface externa = eth0

 

# Liberar roteamento entre as redes

 iptables -A FORWARD -s 192.168.xx.0/24 -j ACCEPT

 iptables -A FORWARD -s 192.168.xx.0/24 -j ACCEPT

 iptables -A FORWARD -s 192.168.xx.0/24 -j ACCEPT

 iptables -A FORWARD -s 192.168.xx.0/24 -j ACCEPT

 iptables -A FORWARD -s 192.168.xx.0/24 -j ACCEPT

 

# Redirecionar saída a internet para o servidor proxy

 iptables -t nat -A PREROUTING  -s 192.168.xx.0/24 ?p tcp -?dport 80 ?j REDIRECT ?-to-port 3128

 iptables -t nat -A PREROUTING  -s 192.168.xx.0/24 ?p tcp -?dport 80 ?j REDIRECT ?-to-port 3128

 iptables -t nat -A PREROUTING  -s 192.168.xx.0/24 ?p tcp -?dport 80 ?j REDIRECT ?-to-port 3128

 iptables -t nat -A PREROUTING  -s 192.168.xx.0/24 ?p tcp -?dport 80 ?j REDIRECT ?-to-port 3128

 iptables -t nat -A PREROUTING  -s 192.168.xx.0/24 ?p tcp -?dport 80 ?j REDIRECT ?-to-port 3128

 

# Redirecionar emails direto para o Servidor SMTP

 iptables ?A PREROUTING ?t nat ?p tcp ?d 200.xxx.xx.xx -?dport 25 ?j DNAT -?to 192.168.xx.xx:25

 iptables ?A PREROUTING ?t nat ?p tcp ?d 200.xxx.xx.xx -?dport 110 ?j DNAT -?to 192.168.xx.xx:110

 

 # Redirecionar p/ Webmail  

 iptables ?A PREROUTING ?t nat ?p tcp ?d 200.xxx.xx.xx -?dport 80 ?j DNAT -?to 192.168.xx.xx:80

 iptables ?A PREROUTING ?t nat ?p tcp ?d 200.xxx.xx.xx -?dport 81 ?j DNAT -?to 192.168.xx.xx:81

 iptables ?A PREROUTING ?t nat ?p tcp ?d 200.xxx.xx.xx -?dport 443 ?j DNAT -?to 192.168.xx.xx:443

  

# Redirecionar p/ ftp *

 iptables ?A PREROUTING ?t nat ?p tcp ?d 200.xxx.xx.180 -?dport 21 ?j DNAT -?to 192.168.xx.xx:21

 iptables ?A PREROUTING ?t nat ?p tcp ?d 200.xxx.xx.180 -?dport 20 ?j DNAT -?to 192.168.xx.xx:20

 

* Obs.: Nessa última regra não é possível acessar o conteúdo do ftp pois no retorno da conexão, o ip está sendo mascarado novamente com o ip da interface eth0.

 

 

 

 

 


Reply to: