coordti
(usa Fedora)
Enviado em 29/07/2009 - 17:50h
Olá!
Sou novato no linux, mas quero instalar um firewall aqui na minha empresa. Estou usando o fedora 11,
mas o firewall não funciona, segue meu script...
#EXTERNA = eth0
#INTERNA = eth1
ifup eth0
ifup eth1
echo "Iniciando Interfaces de Rede...................... [OK]"
### Carregando os modulos do iptables
modprobe ip_nat_ftp
modprobe ip_conntrack_ftp
modprobe iptable_mangle
modprobe iptable_nat
modprobe ipt_MASQUERADE
echo "Modulos Carregados ............................... [OK]"
### Limpando regras
iptables -F
iptables -X
iptables -Z
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -F -t nat
iptables -X -t nat
iptables -F -t mangle
iptables -X -t mangle
echo "Limpando Regras .................................. [OK]"
### Determinando a Politica
iptables -t filter -P INPUT ACCEPT
iptables -t filter -P FORWARD ACCEPT
iptables -t filter -P OUTPUT ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t mangle -P PREROUTING ACCEPT
iptables -t mangle -P POSTROUTING ACCEPT
iptables -t mangle -P OUTPUT ACCEPT
iptables -t mangle -P INPUT ACCEPT
iptables -t mangle -P FORWARD ACCEPT
echo "Politica Padrão................................... [OK]"
### Desabilitando o trafego IP entre as placas de rede
echo "0" >/proc/sys/net/ipv4/ip_forward
echo "Desabilitando trafego ............................ [OK]"
### Proteções
echo "1" >/proc/sys/net/ipv4/conf/default/rp_filter
echo "1" >/proc/sys/net/ipv4/tcp_syncookies
echo "1" >/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
iptables -A INPUT -p udp --dport 33435:33525 -j DROP
iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT
iptables -A INPUT -m state --state INVALID -j DROP
echo "Proteções ........................................ [OK]"
###
echo 1 >/proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
echo 0 >/proc/sys/net/ipv4/conf/all/accept_redirects
echo 0 >/proc/sys/net/ipv4/conf/all/accept_source_route
echo "Carregando Proteções de Segurança ................ [OK]"
### Loopback para Loopback
iptables -t filter -A INPUT -i lo -j ACCEPT
echo "Loopback ......................................... [OK]"
### Rede Interna
iptables -A INPUT -i eth1 -j ACCEPT
echo "Rede Interna ..................................... [OK]"
### Pacotes
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED,NEW -j ACCEPT
#iptables -A OUTPUT -m state --state ESTABLISHED, RELATED, NEW -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
echo "Pacotes .......................................... [OK]"
### Ativando o mascaramento (nat)
iptables -t nat -F POSTROUTING
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "Ativando Mascaramento ............................ [OK]"
### Abrindo Portas
iptables -A INPUT -p tcp --destination-port 22 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 26 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 80 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 587 -j ACCEPT
echo "Abrindo Portas ................................... [OK]"
### Abrindo Portas Email...
iptables -A FORWARD -p tcp -s 192.168.1.0/24 -d 201.76.xx.20 --dport 25 -j ACCEPT
iptables -A FORWARD -p tcp -s 192.168.1.0/24 -d 201.76.xx.20 --dport 110 -j ACCEPT
iptables -A FORWARD -p tcp -s 192.168.1.0/24 --dport 25 -j DROP
iptables -A FORWARD -p tcp -s 192.168.1.0/24 --dport 110 -j DROP
echo "Abrindo Portas email ............................. [OK]"
### Redireciona Proxy
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
echo "Redirecioando .................................... [OK]"
### Rede interna liberada
iptables -A FORWARD -i eth1 -j ACCEPT
echo "Rede Interna liberada ............................ [OK]"
### Libera DNS
iptables -A FORWARD -d 192.168.1.0/24 -p tcp --sport 53 -j ACCEPT
### Habilitando o trafego IP
echo "1" >/proc/sys/net/ipv4/ip_forward
echo "Firewall ......................................... [OK]"
Eu quero somente bloquear algumas portas e redirecionar a internet para o proxy...
Agradeço a ajuda desde já