Problemas com masquerade [RESOLVIDO]

1. Problemas com masquerade [RESOLVIDO]

Miguel Henrique Meyer Cantarella
miguelmeyerc

(usa Debian)

Enviado em 24/02/2014 - 20:16h

Pessoal,

Estou configurando um gateway usando um Debian 7.

Nesse Debian já configurei minhas interfaces eth0 para ligar ao roteador e a eth1 para rede interna.

Já configurei o servidor de DHCP, Bind9 e squid (que funcionou antes de eu tentar usa-lo como proxy transparente).

As maquinas da rede conseguem receber configuração por dhcp e conseguem resolver nomes pelo bind9, mas não estou conseguindo compartilhar a internet usando o proxy.

Abaixo vai a minha configuração inicial do iptables para compartilhar a internet e direcionar para o squid.


#!/bin/bash
#
#
#inicia o processo
start(){


# redirecionando para squid
iptables -t nat -A PREROUTING -i eth1 -p TCP --dport 80 -j REDIRECT --to-port 3128

# compartilhando internet
iptables -t nat -A POSTROUTING -s 10.1.3.0/24 -o eth0 -j MASQUERADE
echo "1"> /proc/sys/net/ipv4/ip_forward
echo "Ativando configuracoes de firewall e compartilhamento de rede ..."

}
#mata o processo
stop(){
echo "Desativando configurações de firewall..."
# desativando as configurações de firewall
iptables -F
iptables -t nat -F
iptables -t mangle -F
modprobe iptable_nat

}
#reinicia o processo
restart(){

stop
sleep 1
start

}

case $1 in
start)
start
exit 0
;;
stop)
stop
exit 0
;;
restart)
restart
exit 0
;;
*)
echo -e "Use $0 start|stop|restart\n"
exit 1
;;
esac

#################################################################################

Segue configuração do squid

################################################################

#configuração do proxy transparente
http_port 3128 transparent
visible_hostname server

################################################################

#configurações do cache

#cache de memoria
cache_mem 64 MB
maximum_object_size_in_memory 96 KB

#cache de hd
cache_dir ufs /var/spool/squid 4096 16 256
maximum_object_size 120 MB

#uso do cache
cache_swap_low 90
cache_swap_high 95

#fim da configuração de cache
################################################################

#ativa o squidGuard
#url_rewrite_program /usr/bin/squidGuard -c /etc/squid/squidGuard.conf
#url_rewrite_children 6

# Regras de acesso
# acl - Recomendadas
#*******************
#
>>>>acl all src 0.0.0.0/0.0.0.0<<<<
acl manager proto cache_object
>>>>acl localhost src 127.0.0.1/255.255.255.255<<<<
>>>>acl to_localhost dst 127.0.0.0/8<<<<
acl SSL_ports port 443 563 # https, snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl purge method PURGE
acl CONNECT method CONNECT
#

# acl - Personalizadas
# Define a rede interna (Intranet)
acl workgroup src 192.168.10.0/24
#

################################################################
#Define o acesso atraves das regras criadas anteriormente

# http_access - Recomendadas
#
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports


# http_access - Personalizadas
#*****************************
http_access allow localhost
>>>>http_access allow workgroup<<<<
#

#Nega tudo que não foi liberado ou negado
http_access deny all


  


2. Re: Problemas com masquerade [RESOLVIDO]

André Canhadas
andrecanhadas

(usa Debian)

Enviado em 24/02/2014 - 20:31h

Poste o arquivo /etc/network/interfaces e também o /etc/bind/named.conf.options

e também fale das configurações de rede que estão sendo definidas nas estações como IP, gateway e DNS


3. Re: Problemas com masquerade [RESOLVIDO]

Miguel Henrique Meyer Cantarella
miguelmeyerc

(usa Debian)

Enviado em 25/02/2014 - 08:43h

#/etc/network/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# The secondary network interface
auto eth1
#iface eth1 inet dhcp
#allow-hotplug eth1
iface eth1 inet static
address 10.1.3.17
netmask 255.255.255.0
network 10.1.3.0
broadcast 10.1.3.255
# gateway 10.1.3.17

###############################################################

#/etc/bind/named.conf.options

options {
directory "/var/cache/bind";

// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113

// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.

forwarders {
// OpenDNS servers
208.67.222.222;
208.67.220.220;
// Google DNS
8.8.8.8;
8.8.4.4;
};

// Security options
listen-on port 53 { 127.0.0.1; 10.1.3.17; };
allow-query { 127.0.0.1; 10.1.3.0/24; };
allow-recursion { 127.0.0.1; 10.1.3.0/24; };
allow-transfer { none; };

//========================================================================
// If BIND logs error messages about the root key being expired,
// you will need to update your keys. See https://www.isc.org/bind-keys
//========================================================================
dnssec-validation auto;

auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
};

##########################################################################

Do que mais você precisa meu amigo ??


4. Re: Problemas com masquerade [RESOLVIDO]

André Canhadas
andrecanhadas

(usa Debian)

Enviado em 25/02/2014 - 09:08h

miguelmeyerc escreveu:

#/etc/network/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# The secondary network interface
auto eth1
#iface eth1 inet dhcp
#allow-hotplug eth1
iface eth1 inet static
address 10.1.3.17
netmask 255.255.255.0
network 10.1.3.0
broadcast 10.1.3.255
# gateway 10.1.3.17

###############################################################

#/etc/bind/named.conf.options

options {
directory "/var/cache/bind";

// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113

// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.

forwarders {
// OpenDNS servers
208.67.222.222;
208.67.220.220;
// Google DNS
8.8.8.8;
8.8.4.4;
};

// Security options
listen-on port 53 { 127.0.0.1; 10.1.3.17; };
allow-query { 127.0.0.1; 10.1.3.0/24; };
allow-recursion { 127.0.0.1; 10.1.3.0/24; };
allow-transfer { none; };

//========================================================================
// If BIND logs error messages about the root key being expired,
// you will need to update your keys. See https://www.isc.org/bind-keys
//========================================================================
dnssec-validation auto;

auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
};

##########################################################################

Do que mais você precisa meu amigo ??


Bom faltou dizer as configurações de rede das maquinas do usuários mas ja deu pra ver que esta usando DHCP na placa eth0 (Rede local).
Se não estiver pegando um IP fixo via dhcp e as maquinas da rede não estejam setados os gateways como sendo este IP da sua eth0 não vai funcionar.

acl workgroup src 192.168.10.0/24 seu IP da eth0 pela logica deveria estar nesta faixa de IP ex: 192.168.10.1 e as estações usarem 192.168.10.1 como gateway.



5. Re: Problemas com masquerade [RESOLVIDO]

Miguel Henrique Meyer Cantarella
miguelmeyerc

(usa Debian)

Enviado em 25/02/2014 - 11:04h

Consegui resolver o problema... Você me deu o caminho das pedras, meu range e o router no dhcpd.conf estavam errados. Alterei pros valores corretos e TCHARAM, funcionou !!!

Obrigado pela ajuda, abraço...






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts