rubens_web
(usa Debian)
Enviado em 11/01/2012 - 08:36h
#/etc/init.d/firewall.sh
-------------------------------------------------------
#! /bin/sh
### BEGIN INIT INFO
# Provides: Firewallbit
# Required-Start: $network $syslog
# Required-Stop: $network
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Description: Start or stop the Firewallbit server
### END INIT INFO
# ------------------------------------------------------
#! /bin/bash
start(){
echo "Firewall iniciando ....................... [OK]";
#limpa as regras
iptables -F
iptables -X
iptables -Z
iptables -F INPUT
iptables -F FORWARD
iptables -F OUTPUT
iptables -t nat -F
iptables -t nat -X
iptables -t nat -Z
iptables -t mangle -F
iptables -t mangle -X
iptables -t mangle -Z
# eht0 = redelocal (onboard)
# eth1 = web (offboard)
##########POLITICA PADRAO
#-------------------------
echo "Politica padrao ativada";
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
#-------------------------
##########HABILITANDO COMPARTILHAMENTO DA INTERNET
#---------------------------------------------------
echo "Compartilhamento Ativado";
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
#---------------------------------------------------
##########LIBERA PORTAS
#---------------------------------------------------
#LIBERA SSH (PUTTY)
echo "Portas ssh liberadas";
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 22 -j ACCEPT
iptables -A FORWARD -p tcp --dport 22 -j ACCEPT
#---------------------------------------------------
echo "Firewall ativado! ........................ [OK]";
}
stop (){
#limpa as regras
iptables -F
iptables -X
iptables -Z
iptables -F INPUT
iptables -F FORWARD
iptables -F OUTPUT
iptables -t nat -F
iptables -t nat -X
iptables -t nat -Z
iptables -t mangle -F
iptables -t mangle -X
iptables -t mangle -Z
#Politica padrao
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
echo "Firewall desativado .............................. [OK]";
}
case "$1" in
"start") start ;;
"stop") stop ;;
"reload") stop; start ;;
*)
echo "Use parametros start | stop | reload" ;;
esac
#------------------------------------------------------------------------
-------------------------
#/etc/network/interfaces
-------------------------
auto lo
iface lo inet loopback
##########INTERFACE REDE LOCAL (onboard)
auto eth0
iface eth0 inet static
address 192.168.1.50
netmask 255.255.255.0
##########INTERFACE FIBRA (MEGATELECOM)
auto eth1
iface eth1 inet static
address xxx.xxx.xx.xx
netmask 255.255.255.248
gateway xxx.xxx.xx.xx
##########DNS FIBRA
dns-nameservers xxx.xxx.xx.xx xxx.xxx.xx.xx
#---------------------------------------------------------------------------
************* Reiniciei o servidor mas NÃO funcionou!