renatodamasio
(usa Debian)
Enviado em 12/04/2017 - 08:49h
Bom dia,
Estou montando um firewall e o mesmo esta navegando somente via HTTPS e ja tentei de tudo e nada de navegar gostaria de ajuda.
Script de firewall
#!/bin/bash
#
#
#/etc/init.d/firewall.sh
#
################
## Variaveis ##
################
# Rede externa eth1 off-board
WAN="187.49.235.140"
# Rede interna eth0 on-board
LAN="192.168.0.235"
#Range de Rede
REDE="192.168.0.0/24"
# Modulos #
modprobe iptable_nat
####################
### Funcao START ###
####################
firewall_start() {
echo "Iniciando o Firewall IPTABLES"
echo ""
echo "---------- Script Feito pelos Gestores ----------"
echo ""
echo "---------- Renato Damasio e Sergio Abrantes ----------"
echo ""
#####################
## Limpa as regras ##
#####################
iptables -X
iptables -Z
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -F -t nat
iptables -F -t mangle
######################
## Politicas padrao ##
######################
iptables -t filter -P INPUT DROP
iptables -t filter -P OUTPUT ACCEPT
iptables -t filter -P FORWARD ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t mangle -P PREROUTING ACCEPT
iptables -t mangle -P OUTPUT ACCEPT
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
echo " ATIVA O REDIRECIONAMENTO NO ARQUIVO IP_FORWARD."
echo "ON ..................................................... [ OK ]"
echo ""
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
echo " IP MASQUERADING."
echo "ON ..................................................... [ OK ]"
echo ""
## Aceita todo o trafego vindo do loopback e indo pro loopback ##
iptables -A INPUT -i lo -j ACCEPT
echo "ACEITA TODO TRAFEGO VINDO DE LOOPBACK E INDO PRA LOOPBACK"
echo "ON ..................................................... [ OK ]"
echo ""
#habilitando o fluxo interno entre os processos
#iptables -I INPUT -i $LanInt -j ACCEPT
#iptables -I OUTPUT -o $LanInt -j ACCEPT
echo "ATIVANDO O FLUXO INTERNO ENTRE OS PROCESSOS"
echo "ON ..................................................... [ OK ]"
echo ""
# Proxy transparente #
i#iptables -t nat -A PREROUTING -s $REDE -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
echo " REDIRECT DA PORTA 80 PARA PORTA 3128."
echo "ON ..................................................... [ OK ]"
echo ""
#-----------------------------------------------------------
#--- Destino INTERNO DE FORA INTERNET --> FIREWALL ----
#-----------------------------------------------------------
# Liberando Porta 6622 (SSH)
iptables -A INPUT -d $WAN -p tcp --dport 6622 -j ACCEPT
# Liberando Porta 80 (http)
iptables -A INPUT -d $WAN -p tcp --dport 80 -j ACCEPT
# Liberando porta 53 (DNS)
iptables -A INPUT -d $WAN -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -d $WAN -p udp --dport 53 -j ACCEPT
# Liberando Porta 21 (ftp)
iptables -A INPUT -d $WAN -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -d $WAN -p tcp --dport 20 -j ACCEPT
#-----------------------------------------------------------
#--- DESTINO INTERNO LAN --> FIREWALL ----
#-----------------------------------------------------------
# Libera o proxy 3128 (teste)
iptables -A INPUT -d $REDE -p tcp --dport 3128 -j ACCEPT
# Liberando Porta 80 (http)
iptables -A INPUT -d $REDE -p tcp --dport 80 -j ACCEPT
# DNS - Libera a resolucao de nomes
iptables -A INPUT -p tcp -s $REDE --dport 53 -j ACCEPT
iptables -A INPUT -p udp -s $REDE --dport 53 -j ACCEPT
#-----------------------------------------------------------
#--- DESTINO EXTERNO LAN --> INTERNET ----
#-----------------------------------------------------------
# HTTP/HTTPS
iptables -A FORWARD -i $LAN -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -i $LAN -p tcp --dport 443 -j ACCEPT
# Faz o mascaramento da rede local
iptables -t nat -A POSTROUTING -o $WAN -j MASQUERADE
# Statefull inspection
# Manter conexoes jah estabelecidas para nao parar
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#Fim das Recgas
echo "Regras Limpas e Firewall desabilitado"
}
firewall_stop() {
echo "Firewall Parado"
}
firewall_restart() {
echo "Reiniciando Firewall"
firewall_stop
sleep 3
firewall_start
echo "Firewall Reiniciado"
}
case "$1" in
'start')
firewall_start
echo "Firewall Iniciado"
;;
'stop')
firewall_stop
;;
'restart')
firewall_restart
;;
*)
esac