magnopeem_rj
(usa Ubuntu)
Enviado em 26/03/2012 - 08:44h
########inicio do arquivo created by 3minfo.com.br ################
#!/bin/bash
iniciar(){
#Modulos
modprobe ip_tables
modprobe iptable_nat
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
echo "Módulos
carregados!"
# Limpando as tabelas
iptables -F
iptables -X
iptables -F -t nat
iptables -X -t nat
iptables -A FORWARD -j LOG
echo "Tabelas
Limpas"
# Politica de Acesso
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t
nat -P PREROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
echo "Políticas Aplicadas"
# Redirecionamento de portas VPN
echo 1 >
/proc/sys/net/ipv4/ip_forward
iptables -A INPUT -p tcp -s 0.0.0.0/24 --dport
1194 -j ACCEPT
iptables -A OUTPUT -p tcp -s 0.0.0.0/24
--dport 1194 -j ACCEPT
iptables -A FORWARD -p tcp -s 0.0.0.0/24
--dport 1194 -j ACCEPT
echo "Porta 1194 liberada"
iptables -A
FORWARD -p udp -s 10.42.43.0/24 -d 0.0.0.0/24 --dport 53 -j ACCEPT
iptables -A FORWARD -p udp -s 0.0.0.0/24 --sport 53 -d 10.42.43.0/24 -j ACCEPT
iptables -A FORWARD -p tcp --sport 1194 -j ACCEPT
iptables -A FORWARD -p udp --sport 1194 -j ACCEPT
iptables -t nat -A POSTROUTING -j MASQUERADE
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
iptables -A INPUT -p tcp --dport 1194 -j ACCEPT
echo "Porta 1194 liberada"
# liberando
o loopback
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# liberando o que vier da rede local
iptables -A INPUT -s 10.42.43.0/255.255.255.0 -i eth0 -j ACCEPT
# Abre
portas usadas
iptables -A INPUT -p tcp --destination-port 80 -j ACCEPT
}
parar(){
iptables -F
iptables -t nat -F
echo "Regras de firewall e
compartilhamento desativados"
}
case
"$1" in
"start") iniciar ;;
"stop") parar ;;
"restart") parar; iniciar ;;
*) echo "Use os
parâmetros start ou stop"
esac
##### fim do arquivo created by 3minfo.com.br ################