vlcunes
(usa Debian)
Enviado em 15/08/2013 - 15:42h
Pronto!!
Segue Script pronto!!
Agradeço por todos que ajudaram.
Estou à disposição para qualquer consulta ou observação referente ao script abaixo.
#!/bin/sh -e
##Firewall Criado por Vitor Lucas
# Inicio (31/07)
## INTERFACES
#ifacenet="eth1"
#ifacelocal="eth2"
## LIMPAR REGRAS
iptables -F
iptables -X
iptables -t nat -F
## POLITICAS PADRAO
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
#############################
####### TABELA FILTER #######
############################
##### INPUT #####
#Liberando interfaces loopback
iptables -A INPUT -i lo -j ACCEPT
#Liberar conexoes estabelecidas e relatadas
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#Acesso SSH ao servidor pelo IP citado.
iptables -A INPUT -s 192.168.50.3 -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -s 192.168.50.0/255.255.255.0 -p tcp --dport 3128 -j ACCEPT
#iptables -A INPUT -s 192.168.50.1 -j ACCEPT
##### FORWARD #####
iptables -A FORWARD -s 192.168.50.1 -j ACCEPT
iptables -A FORWARD -s 192.168.50.0/255.255.255.0 -m multiport -p tcp --dport 25,53,110,443,587,80,8291 -j ACCEPT
iptables -A FORWARD -s 192.168.50.0/255.255.255.0 -p udp --dport 53 -j ACCEPT
#Liberar conexoes estabelecidas e Relatadas
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 3128 -j ACCEPT
#############################
##### TABELA NAT ###########
#############################
#REDIRECIONAMENTO PROXY SQUID
#iptables -t nat -A PREROUTING -i eth2 -p tcp --dport 80 -j REDIRECT --to-port 3128
#COMPARTILHAR A INTERNET
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 192.168.50.0/255.255.255.0 -o eth1 -j MASQUERADE