alptpa
(usa Debian)
Enviado em 19/03/2013 - 19:29h
Boa noite pessoal,
Sou novo aki no forum e preciso de ajuda. Apos procurar muito na net, nao consegui configurar o server para compartilhar 2 links.
Link1: eth1 ip fixo, usado apenas para acesso externo ao ts
Link2: ppp0, usado pelas maquinas da rede interna
Segue abaixo as confg do meu firewall:
#!/bin/bash
#ScrIPT FIreWALL
################################################################################
#26/04/2008
#Configuracao de rede
sleep 1
#limpa todas as regras
iptables -t filter -F
iptables -t nat -F
iptables -t mangle -F
#exclui chains criadas
iptables -t filter -X
iptables -t nat -X
iptables -t mangle -X
#zera contador
iptables -t filter -Z
iptables -t nat -Z
iptables -t mangle -Z
#Habilitando o repasse de pacotes
echo "Habilitando o repasse de pacotes..."
echo 1 > /proc/sys/net/ipv4/ip_forward
#iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o ppp0 -j MASQUERADE
#iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
#iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth1 -j MASQUERADE
#iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth2 -j MASQUERADE
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE
# Modulos
modprobe ip_gre
modprobe ip_tables
modprobe iptable_filter
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_conntrack_irc
modprobe iptable_nat
modprobe ip_nat_ftp
modprobe ipt_LOG
modprobe ipt_state
modprobe ipt_MASQUERADE
modprobe iptable_mangle
#### Definicao de Policiamento ####
echo "Definicao de Policiamento... [OK]"
#--> Tabela NAT <--#
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
# Tabela filter
iptables -t filter -P INPUT ACCEPT
iptables -t filter -P OUTPUT ACCEPT
iptables -t filter -P FORWARD ACCEPT
# Tabela mangle
iptables -t mangle -P PREROUTING ACCEPT
iptables -t mangle -P OUTPUT ACCEPT
#### Filter ####
# Aceita todo o trafego vindo do loopback e indo para o loopback
iptables -A INPUT -i lo -j ACCEPT
# Todo o trafego vindo da rede interna tambem e aceito
iptables -A INPUT -s 192.168.0.0/24
iptables -A INPUT -p ALL -s 127.0.0.1 -i lo -j ACCEPT
#Aqui eu libero as respostas do DNS para o meu firewall:
iptables -A INPUT -p udp -s 200.153.0.68 --sport 53 -j ACCEPT
iptables -A INPUT -p udp -s 200.153.0.196 --sport 53 -j ACCEPT
iptables -A INPUT -p udp -s 200.162.112.125 --sport 53 -j ACCEPT
iptables -A INPUT -p udp -s 200.204.0.138 --sport 53 -j ACCEPT
iptables -A INPUT -p udp -s 201.77.112.3 --sport 53 -j ACCEPT
iptables -A INPUT -p udp -s 201.77.112.9 --sport 53 -j ACCEPT
iptables -A INPUT -p udp -s 192.168.0.220 --sport 53 -j ACCEPT
iptables -A INPUT -p udp -s 8.8.8.8 --sport 53 -j ACCEPT
#Liberando as portas
echo "Liberando as portas... [OK]"
iptables -A INPUT -j ACCEPT -p tcp --dport 1723
iptables -A INPUT -j ACCEPT -p tcp --dport 230
iptables -A INPUT -j ACCEPT -p tcp --dport 200
iptables -A INPUT -j ACCEPT -p tcp --dport 10000
#lendo liberando entrada e saida do protocolo GRE
iptables -A INPUT -j ACCEPT -p gre
iptables -A OUTPUT -j ACCEPT -p gre
iptables -A INPUT -p 47 -j ACCEPT
iptables -A OUTPUT -p 47 -j ACCEPT
# Bloqueando HTTPS - Geral
echo "Bloqueando HTTPS - Geral... [OK]"
#IPS Liberados para HTTPS
iptables -A FORWARD -s 192.168.0.100 -p tcp --dport 443 -j ACCEPT
iptables -A FORWARD -s 192.168.0.101 -p tcp --dport 443 -j ACCEPT
# Daniel regra para bloquear HTTPS
iptables -A FORWARD -p tcp --dport 443 -j DROP
#Cameras
echo "Redirecionando DVR... [OK]"
iptables -A FORWARD -i ppp0 -p tcp --dport 3000 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i ppp0 --dport 3000 -j DNAT --to 192.168.0.221:3000
iptables -A POSTROUTING -t nat -p tcp --dport 3000 -j MASQUERADE
# Redirecionamento VoiP
#iptables -t nat -A PREROUTING -p udp -s 0.0.0.0/0 -d 187.9.7.130 --dport 5060 -j DNAT --to 192.168.0.124:5060
#iptables -t nat -A PREROUTING -p udp -s 0.0.0.0/0 -d 187.9.7.130 --dport 5062 -j DNAT --to 192.168.0.124:5062
#iptables -t nat -A PREROUTING -p tcp -s 0.0.0.0/0 -d 187.9.7.130 --dport 5060 -j DNAT --to 192.168.0.124:5060
#iptables -t nat -A PREROUTING -p tcp -s 0.0.0.0/0 -d 187.9.7.130 --dport 5062 -j DNAT --to 192.168.0.124:5062
#iptables -t nat -A PREROUTING -p tcp -s 0.0.0.0/0 -d 187.9.7.130 --dport 5100:10000 -j DNAT --to 192.168.0.124
#iptables -t nat -A PREROUTING -p udp -s 0.0.0.0/0 -d 187.9.7.130 --dport 5100:10000 -j DNAT --to 192.168.0.124
# Squid
echo "Redirecionando Squid... [OK]"
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3128
# Conectividade Social #########################################################
echo "Liberando Conectividade Social Caixa... [OK]"
iptables -t nat -I PREROUTING -p tcp -d 200.201.0.0/16 -j ACCEPT
iptables -I FORWARD -p tcp -d 200.201.0.0/16 -j ACCEPT
iptables -t nat -A PREROUTING -i ppp0 -p tcp -d 200.201.0.0/16 --dport 80 -j REDIRECT --to-port 3128
################################################################################
echo "Outros redirecionamentos de portas... [OK]"
#Redirecionando TS DO IP 187.9.7.130:3389
iptables -A FORWARD -i eth1 -p tcp --dport 3389 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 3389 -j DNAT --to 192.168.0.220:3389
iptables -A POSTROUTING -t nat -p tcp --dport 3389 -j MASQUERADE
#Redirecionando TS DO IP 201.77.115.168:3389
iptables -A FORWARD -i ppp0 -p tcp --dport 3389 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i ppp0 --dport 3389 -j DNAT --to 192.168.0.220:3389
iptables -A POSTROUTING -t nat -p tcp --dport 3389 -j MASQUERADE
#Redirecionando TS DO IP 187.9.7.130:3390
iptables -A FORWARD -i eth1 -p tcp --dport 3390 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 3390 -j DNAT --to 192.168.0.200:3390
iptables -A POSTROUTING -t nat -p tcp --dport 3390 -j MASQUERADE
#Redirecionando TS DO IP 201.77.115.168:3390
iptables -A FORWARD -i ppp0 -p tcp --dport 3390 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i ppp0 --dport 3390 -j DNAT --to 192.168.0.200:3390
iptables -A POSTROUTING -t nat -p tcp --dport 3390 -j MASQUERADE
iptables -A FORWARD -i eth1 -p tcp --dport 21 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 21 -j DNAT --to 192.168.0.220:21
iptables -A FORWARD -i eth1 -p tcp --dport 4000:4010 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 4000:4010 -j DNAT --to 192.168.0.220