settare firewall

Sicurezza del sistema: firewall, antispam, antivirus, ssh, patch, bug, eccetera.
Avatar utente
BarryLyndon
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 384
Iscrizione: domenica 1 aprile 2007, 9:16

Re: settare firewall

Messaggio da BarryLyndon »

Secondo te non l'ho fatto? Non ho trovato nulla..se lo sai non puoi dirmelo?
Linux user number 446022
Ubuntu User number is # 32680
Avatar utente
thaypan
Prode Principiante
Messaggi: 163
Iscrizione: mercoledì 28 febbraio 2007, 22:23

Re: settare firewall

Messaggio da thaypan »

BerryLyndon ha scritto: Secondo te non l'ho fatto? Non ho trovato nulla..se lo sai non puoi dirmelo?
http://forum.ubuntu-it.org/viewtopic.php?t=37126

oppure usa

Codice: Seleziona tutto

sudo update-rc.d firewall defaults
Ultima modifica di thaypan il martedì 3 aprile 2007, 22:51, modificato 1 volta in totale.
Do you really want to pay the Bill?
Ptah
Entusiasta Emergente
Entusiasta Emergente
Messaggi: 1269
Iscrizione: mercoledì 13 dicembre 2006, 13:19
Contatti:

Re: settare firewall

Messaggio da Ptah »

thaypan ha scritto: Salve, mi rivolgo a chi usa questo tool per chiedergli se loro hanno avuto problemi tipo Errore NAT" coi torrent?
Devi aprire le porte per Torrent :)
Non sono chi dico di essere ;) || Problema risolto?Metti [RISOLTO] nel titolo ;)
Script per Firewall Iptables
Guida Php ufficiale (in inglese)
Avatar utente
thaypan
Prode Principiante
Messaggi: 163
Iscrizione: mercoledì 28 febbraio 2007, 22:23

Re: settare firewall

Messaggio da thaypan »

Io le porte le ho aperte dalla 6881 a 6999, ma facendo il test delle porte con Azureus mi da errore NAT, e non avendo un router, non so proprio quale sia il problema.
Allora mi chiedevo se con questo script si avevano gli stessi problemi di NAT.

EDIT: sul mio modem ethernet/USB KIOWA CN410EU quando vi accedo tramite firefox alla pagina http://192.168.1.1 tra le voci ci sono:
"Port Forwardin" e "IP Filters" non è che devo mettere qui le porte che voglio aprire???
Ultima modifica di thaypan il mercoledì 4 aprile 2007, 12:01, modificato 1 volta in totale.
Do you really want to pay the Bill?
Avatar utente
Stealth
Tenace Tecnocrate
Tenace Tecnocrate
Messaggi: 17364
Iscrizione: martedì 31 gennaio 2006, 22:55
Desktop: Gnome
Distribuzione: Ubuntu 22.04 LTS

Re: settare firewall

Messaggio da Stealth »

thaypan ha scritto: [....]
EDIT: sul mio modem ethernet/USB KIOWA CN410EU quando vi accedo tramite firefox alla pagina http://192.168.1.1 tra le voci ci sono:
"Port Forwardin" e "IP Filters" non è che devo mettere qui le porte che voglio aprire???
Allora mettiamola così, il tuo modem (router?) ha un firewall integrato o no? Perchè se lo ha, come sembra dalle opzioni che puoi settare, ti conviene scegliere: o usi quello oppure iptables sulla macchina.
Non credo sia utile averne 2, rischi solo conflitti e confusione. Se fosse possibile, il mio consiglio è quello di usare quello del modem.....basta e avanza.
ciao

ps niente ti impedisce, nel frattempo e se ti interessa, di studiarti un po' iptables e provarlo....sempre disattivando l'altro per non avere falsi risultati  ;)
Avatar utente
thaypan
Prode Principiante
Messaggi: 163
Iscrizione: mercoledì 28 febbraio 2007, 22:23

Re: settare firewall

Messaggio da thaypan »

Caspiterina allora anche i modem ethernet possono avere il firewall integrato e non solo i router??
Do you really want to pay the Bill?
Avatar utente
BarryLyndon
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 384
Iscrizione: domenica 1 aprile 2007, 9:16

Re: settare firewall

Messaggio da BarryLyndon »

riesco a fare partire il firewall però non mi lasica entrare in mozzilla, amsn e amule, il problema è che ho cercato di capire come fare per dare il permesso a questi 3 ma non riesco a farlo.. :(
Linux user number 446022
Ubuntu User number is # 32680
Avatar utente
thaypan
Prode Principiante
Messaggi: 163
Iscrizione: mercoledì 28 febbraio 2007, 22:23

Re: settare firewall

Messaggio da thaypan »

BerryLyndon ha scritto: riesco a fare partire il firewall però non mi lasica entrare in mozzilla, amsn e amule, il problema è che ho cercato di capire come fare per dare il permesso a questi 3 ma non riesco a farlo.. :(
Devi sapere con precisione quali porte usano questi programmi e devi aprire le porte sia nello scripr che hai scaricato che sui programmi.
Do you really want to pay the Bill?
Avatar utente
BarryLyndon
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 384
Iscrizione: domenica 1 aprile 2007, 9:16

Re: settare firewall

Messaggio da BarryLyndon »

ok, grazie thaypan, adesso cercherò il modo per farlo..tu ormai mi odierai vero (yes)
Linux user number 446022
Ubuntu User number is # 32680
Avatar utente
thaypan
Prode Principiante
Messaggi: 163
Iscrizione: mercoledì 28 febbraio 2007, 22:23

Re: settare firewall

Messaggio da thaypan »

NO io ho fatto le tue stesse domande e pensa che le faccio pure ora.  (rotfl)


EDIT:Vedi se all'interno del file che hai scaricato firewall.sh c'è questo cidice

Codice: Seleziona tutto

        ########################
        # Apertura porte aMule #
        ########################
        $IPTABLES -A INPUT -p tcp  -i $IFEXT --dport 4662 -j ACCEPT
        $IPTABLES -A INPUT -p udp -i $IFEXT --dport 4662:4665 -j ACCEPT
        $IPTABLES -A INPUT -p udp -i $IFEXT --dport 4672 -j ACCEPTcosì 
Se non c'è copiacelo.
Ricorda però che la rete Kad ci mette un po' prima di capire di non essere più firewalled

Poi vai sui siti dei due programmi e cerca "porte" e ricopia i codici ma cambia le porte e le TCP e UDP.

Vai alla pagina http://192.168.1.1 o 1.2 dal tuo browser col modem accesso e tutto e accedi alle impostazioni del modem e vedi se c'è tra tutti i menu "port forwarding" se c'è vuol dire che anche il tuo modem ha un firewall e devi sbloccare quelle porte anche la.

Ciao
Ultima modifica di thaypan il giovedì 5 aprile 2007, 15:18, modificato 1 volta in totale.
Do you really want to pay the Bill?
Avatar utente
soulja
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 388
Iscrizione: mercoledì 7 marzo 2007, 2:22

Re: settare firewall

Messaggio da soulja »

>:( >:( >:(...Ma che casinooo..vorrei sapere una cosa..lo script di mizar che cosa fà?? blocca tutto sia in entrata che in uscita..o blocca solo in uscita??
Sempre su quello script è possibile configuarlo in modo che mi blocchi tutte le porte..e stabilire da me quali lasciare aperte? come lo posso configurare?? ??? ???
SOLO      AS      ROMA
Avatar utente
thaypan
Prode Principiante
Messaggi: 163
Iscrizione: mercoledì 28 febbraio 2007, 22:23

Re: settare firewall

Messaggio da thaypan »

soulja ha scritto: >:( >:( >:(...Ma che casinooo..vorrei sapere una cosa..lo script di mizar che cosa fà?? blocca tutto sia in entrata che in uscita..o blocca solo in uscita??
Sempre su quello script è possibile configuarlo in modo che mi blocchi tutte le porte..e stabilire da me quali lasciare aperte? come lo posso configurare?? ??? ???

1-Abilita il traffico interno + il traffico in entrata ma solo se relativo a pacchetti in risposta.
2- Si devi inserice dei comandi in cui elenchi le porte da aprire.

P.S. comunque se ti leggi tutte le pèagine di questo 3D saprai come fare.
Do you really want to pay the Bill?
Avatar utente
AlexSistemiFree
Entusiasta Emergente
Entusiasta Emergente
Messaggi: 1373
Iscrizione: venerdì 15 dicembre 2006, 9:43

Re: settare firewall

Messaggio da AlexSistemiFree »

soulja ha scritto: ..o blocca solo in uscita??
A quanto detto da thaypan aggiungo soltanto che lo script di Mizar permette tutto in uscita.

Ciao Ale :)
Avatar utente
BarryLyndon
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 384
Iscrizione: domenica 1 aprile 2007, 9:16

Re: settare firewall

Messaggio da BarryLyndon »

Secondo voi un buon firewall che porte deve avere aperte?

Io credo che debba avere aperte per internet:

22/tcp
53/tcp
53/UDP
80/tcp

per P2P
4711/tco Emule Web Server
6881/tcp per BitTorrent


voi che cosa togliereste o aggiungereste?
Linux user number 446022
Ubuntu User number is # 32680
Avatar utente
AlexSistemiFree
Entusiasta Emergente
Entusiasta Emergente
Messaggi: 1373
Iscrizione: venerdì 15 dicembre 2006, 9:43

Re: settare firewall

Messaggio da AlexSistemiFree »

Dipende dalle tue necessità.
Ad es. aprire la porta 22 (ssh) ha senso se si possiede una lan e si utilizza la criptazione oppure se si ha la fortuna di avere un hosting che ti fornisce questo accesso (di free non ne ho trovati nemmeno uno ...  >:( ).
La porta 80 ha senso tenerla aperta se si fornisce un web server accessibile da internet (cosa praticamente impossibile da normale utente in quanto la banda usata, quella in upload, è troppo bassa) mentre per un uso all'interno di una propria lan è ok.

Ciao Ale :)
Avatar utente
BarryLyndon
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 384
Iscrizione: domenica 1 aprile 2007, 9:16

Re: settare firewall

Messaggio da BarryLyndon »

beh ma se chiudo la porta 80 come faccio a vedere le pagine web?
(mi sa che incomincio a incasinarmi un sacco con tutte ste porte..)
Linux user number 446022
Ubuntu User number is # 32680
Avatar utente
Fantasmino
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 480
Iscrizione: giovedì 23 novembre 2006, 22:24

Re: settare firewall

Messaggio da Fantasmino »

Ciao a tutti!
Dopo mesi di utilizzo di ubuntu, passo dopo passo sono arrivato anche al settaggio del firewall, accantonato all'inizio per eccesso di difficoltà.
Ora molte cose sono chiare rispetto ad allora, e senza problemi ho installato lo script di Mizar/Ptah (lo incollo per chiarezza, visto che ci sono varie versioni):

Codice: Seleziona tutto

#!/bin/bash
#
# Firewall personale by Benjamin (Mizar)
# Modifyed by Ptah 16 Dec 2006
#
#########################################################
# Di default DROP su INPUT e FORWARD, tutto il traffico 
# in uscita consentito
#########################################################
# ATTENZIONE alle righe 114, 115 e 180. In queste righe
# ho abilitato alcuni servizi (ftp, www, ssh) in modo
# che siano accessibili solo da rete interna. Se non
# usate questi servizi, non avete una rete interna
# o volete che siano raggiungibili ANCHE da esterno
# dovete modificare le regole o commentarle
#########################################################

#########################
# Definizione Variabili #
#########################
IPTABLES="/sbin/iptables"
IFLO="lo"
IFEXT="eth0"			# Da sostituire con la propria interfaccia: $IFEXT, eth1, ppp0, etc

case "$1" in
  start)
	########################
	# Attivazione Firewall #
	########################
        echo -n "Attivazione Firewall:    "

	#################################
	# Caricamento Moduli del Kernel #
	#################################
	modprobe ip_tables
	modprobe iptable_nat
	modprobe ip_conntrack
	modprobe ip_conntrack_ftp
	modprobe ip_nat_ftp
	modprobe ipt_LOG
	modprobe ipt_MARK
	modprobe ipt_MASQUERADE
	modprobe ipt_REDIRECT
	modprobe ipt_REJECT
	modprobe ipt_TOS
	modprobe ipt_limit
	modprobe ipt_mac
	modprobe ipt_mark
	modprobe ipt_multiport
	modprobe ipt_state
	modprobe ipt_tos
	modprobe iptable_mangle
        #modprobe ipt_psd

	############################
        # Reset delle impostazioni #
	############################
        $IPTABLES -F
        $IPTABLES -F -t nat
        $IPTABLES -F -t mangle
        $IPTABLES -X
        $IPTABLES -X -t nat
        $IPTABLES -X -t mangle

	################################
        # Impostazione Policy standard #
	################################
        $IPTABLES -P INPUT   DROP
        $IPTABLES -P FORWARD DROP
        $IPTABLES -P OUTPUT  ACCEPT

	#################################
	# Abilitazione traffico interno #
	#################################
	$IPTABLES -A INPUT  -i $IFLO -j ACCEPT
	$IPTABLES -A OUTPUT -o $IFLO -j ACCEPT


	############################
	# creo una catena per ICMP #
	############################
	$IPTABLES -N icmp_in 

	########################################################
	# se il pacchetto icmp non è un ping allora lo accetta #
	# altrimenti (6-7 riga) logga e droppa                 #
	########################################################
	$IPTABLES -A icmp_in -i $IFEXT -p icmp -m icmp --icmp-type 0 -j REJECT --reject-with icmp-host-unreachable
	$IPTABLES -A icmp_in -i $IFEXT -p icmp -m icmp --icmp-type 8 -j REJECT --reject-with icmp-host-unreachable
	$IPTABLES -A icmp_in -i $IFEXT -p icmp -m icmp --icmp-type 3 -j REJECT --reject-with icmp-host-unreachable
	$IPTABLES -A icmp_in -i $IFEXT -p icmp -m icmp --icmp-type 5 -j REJECT --reject-with icmp-host-unreachable
	$IPTABLES -A icmp_in -i $IFEXT -p icmp -m icmp --icmp-type 11 -j REJECT --reject-with icmp-host-unreachable
	$IPTABLES -A icmp_in -p icmp -j LOG --log-prefix "ICMP drop:"
	$IPTABLES -A icmp_in -p icmp -j DROP

	#######################################
	# Istruisco iptable a usare la catena #
	# creata precedentemente              #
	#######################################
	$IPTABLES -A INPUT -i $IFEXT -p icmp -j icmp_in

	###########################
	# creo una catena per TCP #
	# pacchetti pericolosi    #
	###########################
	$IPTABLES -N bad_tcp

	######################################
	# Regole di controllo PORTSCAN TCP   #
	# sono commentate perchè non         #
	# ho il modulo psd disponibile. Se   #
	# lo avete potete abilitarle. Sono   #
	# regole aggiuntive per gli attacchi #
	# di tipo PORTSCAN                   #
	######################################
	#$IPTABLES -A bad_tcp -p tcp -m psd -j LOG --log-prefix "PORTSCAN TCP: "
	#$IPTABLES -A bad_tcp -p tcp -m psd -j REJECT --reject-with icmp-net-unreachable

	###########################################
	# Regole di controllo su alcune porte TCP #
	# Servizi che voglio rendere disponibili  #
	# solo ai computer della rete interna     #
	###########################################
        $IPTABLES -A bad_tcp -p tcp -m multiport --dports 80,21,22,10000 -i $IFEXT -m state -s ! 10.1.1.0/24 --state NEW -j REJECT --reject-with icmp-net-unreachable
        $IPTABLES -A bad_tcp -p tcp -m multiport --dports 445,3306 -i $IFEXT -m state -s ! 10.1.1.0/24 --state NEW -j REJECT --reject-with icmp-net-unreachable

	####################################
	# Regole di controllo sui flag TCP #
	####################################
	$IPTABLES -A bad_tcp -p tcp -m tcp ! --tcp-flags SYN,RST,ACK SYN -m state --state NEW -j LOG --log-prefix "Nuova non syn:"
	$IPTABLES -A bad_tcp -p tcp -m tcp ! --tcp-flags SYN,RST,ACK SYN -m state --state NEW -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m state --state INVALID -j LOG --log-prefix "Invalida:"
	$IPTABLES -A bad_tcp -p tcp -m state --state INVALID -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,PSH,URG -m limit --limit 5/min -j LOG --log-prefix "ScanPort NMAP-XMAS:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,PSH,URG -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --tcp-flags SYN,RST SYN,RST -m limit --limit 5/min -j LOG --log-prefix "ScanPort SYN/RST:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --tcp-flags SYN,RST SYN,RST -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -m limit --limit 5/min -j LOG --log-prefix "ScanPort SYN/FIN:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --dport 137:139 -m limit --limit 5/min -j LOG --log-prefix "Tentativo SMB:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --sport 137:139 -m limit --limit 5/min -j LOG --log-prefix "Tentativo SMB:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --dport 137:139 -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --sport 137:139 -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --dport 2049 -m limit --limit 5/min -j LOG --log-prefix "Tentativo NFS:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --sport 2049 -m limit --limit 5/min -j LOG --log-prefix "Tentativo NFS:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --dport 2049 -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --sport 2049 -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --dport 6000:6063 -m limit --limit 5/min -j LOG --log-prefix "Tentativo X:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --sport 6000:6063 -m limit --limit 5/min -j LOG --log-prefix "Tentativo X:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --dport 6000:6063 -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --sport 6000:6063 -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --dport 20034 -m limit --limit 5/min -j LOG --log-prefix "Tentativo NetBus2:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --sport 20034 -m limit --limit 5/min -j LOG --log-prefix "Tentativo NetBus2:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --dport 20034 -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --sport 20034 -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --dport 12345:12346 -m limit --limit 5/min -j LOG --log-prefix "Tentativo NetBus:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --sport 12345:12346 -m limit --limit 5/min -j LOG --log-prefix "Tentativo NetBus:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --dport 12345:12346 -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --sport 12345:12346 -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --dport 27374 -m limit --limit 5/min -j LOG --log-prefix "Tentativo SubSeven:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --sport 27374 -m limit --limit 5/min -j LOG --log-prefix "Tentativo SubSeven:"
	$IPTABLES -A bad_tcp -p tcp -m tcp --dport 27374 -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m tcp --sport 27374 -j REJECT --reject-with icmp-net-unreachable

	########################################
	# Istruisco iptable a usare la catena  #
	# per il TCP maligno                   #
	########################################
	$IPTABLES -A INPUT -i $IFEXT -p tcp -j bad_tcp

	###########################
	# creo una catena per TCP #
	# pacchetti validi        #
	###########################
	$IPTABLES -N ok_tcp

	#############################################################################
	# Abilitazione traffico in entrata solo se relativo a pacchetti in risposta #
	#############################################################################
        $IPTABLES -A ok_tcp -p tcp -m multiport --dports 80,21,22,10000 -i $IFEXT -m state -s 10.1.1.0/24 --state NEW -j ACCEPT
	$IPTABLES -A ok_tcp -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j ACCEPT
	$IPTABLES -A ok_tcp -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
	$IPTABLES -A ok_tcp -i $IFEXT -p tcp -j LOG --log-prefix "ok_tcp drop:"
	$IPTABLES -A ok_tcp -p tcp -j REJECT --reject-with icmp-net-unreachable

	###########################
	# creo una catena per UDP #
	# pacchetti pericolosi    #
	###########################
	$IPTABLES -N bad_udp

	######################################
	# Regole di controllo PORTSCAN       #
	# sono commentate perchè non         #
	# ho il modulo psd disponibile. Se   #
	# lo avete potete abilitarle. Sono   #
	# regole aggiuntive per gli attacchi #
	# di tipo PORTSCAN                   #
	######################################
	#$IPTABLES -A bad_udp -p udp -m psd -j LOG --log-prefix "PORTSCAN UDP: "
	#$IPTABLES -A bad_udp -p udp -m psd -j REJECT --reject-with icmp-net-unreachable

	########################################
	# Istruisco iptable a usare la catena  #
	# per il UDP maligno                   #
	########################################
	$IPTABLES -A INPUT -i $IFEXT -p udp -j bad_udp

	###########################
	# creo una catena per UDP #
	# pacchetti validi        #
	###########################
	$IPTABLES -N ok_udp

	#############################################################################
	# Abilitazione traffico in entrata solo se relativo a pacchetti in risposta #
	#############################################################################
	$IPTABLES -A ok_udp -p udp -m state --state RELATED,ESTABLISHED -j ACCEPT
	$IPTABLES -A ok_udp -i $IFEXT -p udp -j LOG --log-prefix "ok_udp drop:"
	$IPTABLES -A ok_udp -p udp -j REJECT --reject-with icmp-net-unreachable


	#####################################
	# Aggiungo le catene personalizzate #
	#####################################
	$IPTABLES -A INPUT -i $IFEXT -p tcp -j ok_tcp
	$IPTABLES -A INPUT -i $IFEXT -p udp -j ok_udp

	################################
	# Regole finali di paranoia ;) #
	################################
	$IPTABLES -A INPUT -i $IFEXT -j LOG --log-prefix "Default drop:"
	$IPTABLES -A INPUT -i $IFEXT -j DROP

	########################
        # Apertura porte aMule #
        ########################
        $IPTABLES -A INPUT -p tcp -i $IFEXT --dport 4662 -j ACCEPT
        $IPTABLES -A INPUT -p udp -i $IFEXT --dport 4665 -j ACCEPT
        $IPTABLES -A INPUT -p udp -i $IFEXT --dport 4672 -j ACCEPT

        echo "ok"
	;;

  stop)
	###########################
        # Disattivazione Firewall #
	###########################
        echo -n "Disattivazione Firewall: "

        $IPTABLES -F
        $IPTABLES -F -t nat
        $IPTABLES -F -t mangle
        $IPTABLES -X
        $IPTABLES -X -t nat
        $IPTABLES -X -t mangle

        $IPTABLES -P INPUT   ACCEPT
        $IPTABLES -P FORWARD ACCEPT
        $IPTABLES -P OUTPUT  ACCEPT

        echo "ok"
	;;

  status)
	##############################
        # Display stato del Firewall #
	##############################
        echo -n "Regole attuali nel Firewall: "

        $IPTABLES -L
	;;

  restart|reload)
        $0 stop
        $0 start
	;;

  *)
	echo "Utilizzo: firewall {start|stop|restart|reload|status}" >&2
	exit 1
	;;

esac

exit 0
Ho aggiunto l'apertura delle porte di amule come nei primi script di Mizar.
La cosa incredibile è che tutto funziona al primo colpo! (good) (good)
Posta, web, amule con ID alto e Kad ok, tutto a posto. Avvio lo script con BUM all'avvio del pc.  Ho anche provato a bloccare degli IP in uscita e riesco a fare anche quello, tutto alla grande!
Prima di tutto quindi, un GRAZIE a voi tutti e in particolare agli autori dello script! :-*
Ma non capisco una cosa...
Per provare, ho commentato le righe relative ad amule, e rimane ID alto e kad ok...
Mi sono connesso con bittorrent e provato a scaricare l'immagine di ubuntu e va a manetta...
Ma è normale questo?
Non dovrei avere dei problemi se non apro le relative porte?
Per completezza allego il risultato di iptables -L con il firewall con le porte di amule commentate ed aggiungo che sono dietro ad un router correttamente configurato nelle rispettive aperture di porte varie:

Codice: Seleziona tutto

Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
icmp_in    icmp --  anywhere             anywhere            
bad_tcp    tcp  --  anywhere             anywhere            
bad_udp    udp  --  anywhere             anywhere            
ok_tcp     tcp  --  anywhere             anywhere            
ok_udp     udp  --  anywhere             anywhere            
LOG        all  --  anywhere             anywhere            LOG level warning prefix `Default drop:' 
DROP       all  --  anywhere             anywhere            

Chain FORWARD (policy DROP)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            

Chain bad_tcp (1 references)
target     prot opt source               destination         
REJECT     tcp  -- !rfc-1918/24          anywhere            multiport dports www,ftp,ssh,10000 state NEW reject-with icmp-net-unreachable 
REJECT     tcp  -- !rfc-1918/24          anywhere            multiport dports microsoft-ds,mysql state NEW reject-with icmp-net-unreachable 
LOG        tcp  --  anywhere             anywhere            tcp flags:!SYN,RST,ACK/SYN state NEW LOG level warning prefix `Nuova non syn:' 
REJECT     tcp  --  anywhere             anywhere            tcp flags:!SYN,RST,ACK/SYN state NEW reject-with icmp-net-unreachable 
LOG        tcp  --  anywhere             anywhere            state INVALID LOG level warning prefix `Invalida:' 
REJECT     tcp  --  anywhere             anywhere            state INVALID reject-with icmp-net-unreachable 
LOG        tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,PSH,URG limit: avg 5/min burst 5 LOG level warning prefix `ScanPort NMAP-XMAS:' 
REJECT     tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,PSH,URG reject-with icmp-net-unreachable 
LOG        tcp  --  anywhere             anywhere            tcp flags:SYN,RST/SYN,RST limit: avg 5/min burst 5 LOG level warning prefix `ScanPort SYN/RST:' 
REJECT     tcp  --  anywhere             anywhere            tcp flags:SYN,RST/SYN,RST reject-with icmp-net-unreachable 
LOG        tcp  --  anywhere             anywhere            tcp flags:FIN,SYN/FIN,SYN limit: avg 5/min burst 5 LOG level warning prefix `ScanPort SYN/FIN:' 
REJECT     tcp  --  anywhere             anywhere            tcp flags:FIN,SYN/FIN,SYN reject-with icmp-net-unreachable 
LOG        tcp  --  anywhere             anywhere            tcp dpts:netbios-ns:netbios-ssn limit: avg 5/min burst 5 LOG level warning prefix `Tentativo SMB:' 
LOG        tcp  --  anywhere             anywhere            tcp spts:netbios-ns:netbios-ssn limit: avg 5/min burst 5 LOG level warning prefix `Tentativo SMB:' 
REJECT     tcp  --  anywhere             anywhere            tcp dpts:netbios-ns:netbios-ssn reject-with icmp-net-unreachable 
REJECT     tcp  --  anywhere             anywhere            tcp spts:netbios-ns:netbios-ssn reject-with icmp-net-unreachable 
LOG        tcp  --  anywhere             anywhere            tcp dpt:nfs limit: avg 5/min burst 5 LOG level warning prefix `Tentativo NFS:' 
LOG        tcp  --  anywhere             anywhere            tcp spt:nfs limit: avg 5/min burst 5 LOG level warning prefix `Tentativo NFS:' 
REJECT     tcp  --  anywhere             anywhere            tcp dpt:nfs reject-with icmp-net-unreachable 
REJECT     tcp  --  anywhere             anywhere            tcp spt:nfs reject-with icmp-net-unreachable 
LOG        tcp  --  anywhere             anywhere            tcp dpts:x11:6063 limit: avg 5/min burst 5 LOG level warning prefix `Tentativo X:' 
LOG        tcp  --  anywhere             anywhere            tcp spts:x11:6063 limit: avg 5/min burst 5 LOG level warning prefix `Tentativo X:' 
REJECT     tcp  --  anywhere             anywhere            tcp dpts:x11:6063 reject-with icmp-net-unreachable 
REJECT     tcp  --  anywhere             anywhere            tcp spts:x11:6063 reject-with icmp-net-unreachable 
LOG        tcp  --  anywhere             anywhere            tcp dpt:20034 limit: avg 5/min burst 5 LOG level warning prefix `Tentativo NetBus2:' 
LOG        tcp  --  anywhere             anywhere            tcp spt:20034 limit: avg 5/min burst 5 LOG level warning prefix `Tentativo NetBus2:' 
REJECT     tcp  --  anywhere             anywhere            tcp dpt:20034 reject-with icmp-net-unreachable 
REJECT     tcp  --  anywhere             anywhere            tcp spt:20034 reject-with icmp-net-unreachable 
LOG        tcp  --  anywhere             anywhere            tcp dpts:12345:12346 limit: avg 5/min burst 5 LOG level warning prefix `Tentativo NetBus:' 
LOG        tcp  --  anywhere             anywhere            tcp spts:12345:12346 limit: avg 5/min burst 5 LOG level warning prefix `Tentativo NetBus:' 
REJECT     tcp  --  anywhere             anywhere            tcp dpts:12345:12346 reject-with icmp-net-unreachable 
REJECT     tcp  --  anywhere             anywhere            tcp spts:12345:12346 reject-with icmp-net-unreachable 
LOG        tcp  --  anywhere             anywhere            tcp dpt:asp limit: avg 5/min burst 5 LOG level warning prefix `Tentativo SubSeven:' 
LOG        tcp  --  anywhere             anywhere            tcp spt:asp limit: avg 5/min burst 5 LOG level warning prefix `Tentativo SubSeven:' 
REJECT     tcp  --  anywhere             anywhere            tcp dpt:asp reject-with icmp-net-unreachable 
REJECT     tcp  --  anywhere             anywhere            tcp spt:asp reject-with icmp-net-unreachable 

Chain bad_udp (1 references)
target     prot opt source               destination         

Chain icmp_in (1 references)
target     prot opt source               destination         
REJECT     icmp --  anywhere             anywhere            icmp echo-reply reject-with icmp-host-unreachable 
REJECT     icmp --  anywhere             anywhere            icmp echo-request reject-with icmp-host-unreachable 
REJECT     icmp --  anywhere             anywhere            icmp destination-unreachable reject-with icmp-host-unreachable 
REJECT     icmp --  anywhere             anywhere            icmp redirect reject-with icmp-host-unreachable 
REJECT     icmp --  anywhere             anywhere            icmp time-exceeded reject-with icmp-host-unreachable 
LOG        icmp --  anywhere             anywhere            LOG level warning prefix `ICMP drop:' 
DROP       icmp --  anywhere             anywhere            

Chain ok_tcp (1 references)
target     prot opt source               destination         
ACCEPT     tcp  --  rfc-1918/24          anywhere            multiport dports www,ftp,ssh,10000 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp flags:SYN,RST,ACK/SYN 
ACCEPT     tcp  --  anywhere             anywhere            state RELATED,ESTABLISHED 
LOG        tcp  --  anywhere             anywhere            LOG level warning prefix `ok_tcp drop:' 
REJECT     tcp  --  anywhere             anywhere            reject-with icmp-net-unreachable 

Chain ok_udp (1 references)
target     prot opt source               destination         
ACCEPT     udp  --  anywhere             anywhere            state RELATED,ESTABLISHED 
LOG        udp  --  anywhere             anywhere            LOG level warning prefix `ok_udp drop:' 
REJECT     udp  --  anywhere             anywhere            reject-with icmp-net-unreachable 
Non che mi lamenti che tutto funzioni bene, anzi! (rotfl)
Ma mi pareva di aver capito che senza aprire le porte e consentire il traffico, di default dovrebbe essere bloccato dal firewall...
O no? ::)
Chi mi dà una dritta a riguardo?
...fatti non foste a viver come bruti, ma per seguir virtute e canoscenza...
Avatar utente
BarryLyndon
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 384
Iscrizione: domenica 1 aprile 2007, 9:16

Re: settare firewall

Messaggio da BarryLyndon »

Nn riesco a capire perchè io stò cercando di compilare uno script seguendo un articolo di Linux&C e mi viene fuori questo:

Codice: Seleziona tutto

#!/bin/bash
IPTABLES='/sbin/iptables'

#Verifichiamo che esista l'eseguibile 'iptables'
if [ ! -f $IPTABLES ]; then 
	echo "Spiacente non riesco a trovare l'eseguibile 'iptables'"
	echo
	exit 0
fi

#Accertiamoci di eseguire lo script come 'root'
if [ $(id |awk -F'(' '{print $1}' |awk -F'=' '{print $2}') != 0 ]; then
	echo "Spiacente, questo script deve essere eseguito come root"
	echo
	exit 0
fi

#reset di tutte le catene/tabelle
for TABLE in filter nat mangle ; do
	$IPTABLES -t $TABLE -F
	$IPTALBES -t $TABLE -X
done

#impostazione della policy di default

$IPTABLES -t filter -P FORWARD DROP
$IPTABLES -t filter -P INPUT DROP
$IPTABLES -t filter -P OUTPUT DROP

#accettiamo tutte le connessioni da/verso localhost

$IPTABLES -t filter -A INPUT -s  127.0.0.1 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -d  127.0.0.1 -j ACCEPT

#ICMP (necessario pe ri pacchetti di controllo")
$IPTABLES -t filter -A INPUT -p icmp  --icmp-type 0 -j ACCEPT
$IPTABLES -t filter -A INPUT -p icmp  --icmp-type 3 -j ACCEPT
$IPTABLES -t filter -A INPUT -p icmp  --icmp-type 8 -j ACCEPT
$IPTABLES -t filter -A INPUT -p icmp  --icmp-type 11 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p icmp  --icmp-type 0 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p icmp  --icmp-type 3 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p icmp  --icmp-type 8 -j ACCEPT
$IPTABLES -t filter -A OUTPUT -p icmp  --icmp-type 11 -j ACCEPT

#Traffico in ingresso
$IPTABLES ...

Deve essere ancora finito però è differente da quello di Mizar e da altri che ho visto..perchè?
Linux user number 446022
Ubuntu User number is # 32680
Ptah
Entusiasta Emergente
Entusiasta Emergente
Messaggi: 1269
Iscrizione: mercoledì 13 dicembre 2006, 13:19
Contatti:

Re: settare firewall

Messaggio da Ptah »

@Fantasmino
A occhio e croce direi che funziona perchè la connessione parte inizlamente da te (connessione al server e alla rete Kad) e dato che nelle regole c'è scritto che abilita il traffico se relativo a connessioni già aperte allora passa tutto :)

Codice: Seleziona tutto

	$IPTABLES -A ok_tcp -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j ACCEPT
	$IPTABLES -A ok_tcp -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
Dovrebbe essere questo "l'inghippo" per così dire...infatti io sono nella tua stessa situazione (router con porte forwardate e porte mulo non standard, ma connessione ai server e alla rete Kad senza problemi)....per fare la prova (che sinceramente non mi va di fare personalmente dato che ora mi sto dedicando a Snort) ti basterebbe "limitare" le regole di accettazione se relative a traffico già stabilito ESCLUDENDO le porte del mulo...a quel punto non dovresti riuscire più a connetterti :)

Il tutto, come sempre, a meno di smentite da parte di più esperti  8)


@Berry:
E' differente perchè usa semplicemente un modo di impostare e manipolare le regole differente (intanto il ciclo FOR per "azzerare" le regole esistenti a ogni lancio) e poi perchè parrebbe che sia uno script creato per essere lanciato "on demand".
Attenzione che di default tu non fai entrare nè uscire nulla...quindi se vuoi navigare o fare altro (qualunque cosa) devi esplicitamente permetterlo!!! (vedi ad esempio le impostazioni per far uscire le richieste/risposte di ping)
(Ps. gli script non si compilano ;))
Non sono chi dico di essere ;) || Problema risolto?Metti [RISOLTO] nel titolo ;)
Script per Firewall Iptables
Guida Php ufficiale (in inglese)
Avatar utente
Fantasmino
Scoppiettante Seguace
Scoppiettante Seguace
Messaggi: 480
Iscrizione: giovedì 23 novembre 2006, 22:24

Re: settare firewall

Messaggio da Fantasmino »

@Ptah
Ciao e grazie della veloce risposta!
Cercherò di fare io le prove, ma ti chiederò una mano per interpretarle, come adesso, perché alcune cose non le capisco! :D
Ho provato a bloccare amule in tutti i modi, ma non ci riesco! È testardo come un ciuco e veloce come una ferrari! ;D
Dunque, ho inserito le righe 1, 2, 3 (i numeri sono solo qui nel quote):

Codice: Seleziona tutto

	#############################################################################
	# Abilitazione traffico in entrata solo se relativo a pacchetti in risposta #
	#############################################################################
	$IPTABLES -A ok_tcp -p tcp -m multiport --dports 80,21,22,10000 -i $IFEXT -m state -s 10.1.1.0/24 --state NEW -j ACCEPT
	$IPTABLES -A ok_tcp -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j ACCEPT
	$IPTABLES -A ok_tcp -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
	$IPTABLES -A ok_tcp -i $IFEXT -p tcp -j LOG --log-prefix "ok_tcp drop:"
	$IPTABLES -A ok_tcp -p tcp -j REJECT --reject-with icmp-net-unreachable
1	$IPTABLES -A ok_tcp -p tcp --dport 4662 -j REJECT --reject-with icmp-net-unreachable
2	$IPTABLES -A ok_tcp -p udp --dport 4665 -j REJECT --reject-with icmp-net-unreachable
3	$IPTABLES -A ok_tcp -p udp --dport 4672 -j REJECT --reject-with icmp-net-unreachable
e iptables -L mi restituisce:

Codice: Seleziona tutto

.......
Chain ok_tcp (1 references)
target     prot opt source               destination         
ACCEPT     tcp  --  rfc-1918/24          anywhere            multiport dports www,ftp,ssh,10000 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp flags:SYN,RST,ACK/SYN 
ACCEPT     tcp  --  anywhere             anywhere            state RELATED,ESTABLISHED 
LOG        tcp  --  anywhere             anywhere            LOG level warning prefix `ok_tcp drop:' 
REJECT     tcp  --  anywhere             anywhere            reject-with icmp-net-unreachable 
REJECT     tcp  --  anywhere             anywhere            tcp dpt:4662 reject-with icmp-net-unreachable 
REJECT     udp  --  anywhere             anywhere            udp dpt:4665 reject-with icmp-net-unreachable 
REJECT     udp  --  anywhere             anywhere            udp dpt:4672 reject-with icmp-net-unreachable 
ma il ciuco va sempre a manetta... ::)
Allora ho drasticamente aggiunto queste:

Codice: Seleziona tutto

	########################
	# Apertura porte aMule #
	########################
	$IPTABLES -A INPUT -p tcp -i $IFEXT --dport 4662 -j DROP
	$IPTABLES -A INPUT -p udp -i $IFEXT --dport 4665 -j DROP
	$IPTABLES -A INPUT -p udp -i $IFEXT --dport 4672 -j DROP
ed ora iptables mi restituisce:

Codice: Seleziona tutto

Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
icmp_in    icmp --  anywhere             anywhere            
bad_tcp    tcp  --  anywhere             anywhere            
bad_udp    udp  --  anywhere             anywhere            
ok_tcp     tcp  --  anywhere             anywhere            
ok_udp     udp  --  anywhere             anywhere            
LOG        all  --  anywhere             anywhere            LOG level warning prefix `Default drop:' 
DROP       all  --  anywhere             anywhere            
DROP       tcp  --  anywhere             anywhere            tcp dpt:4662 
DROP       udp  --  anywhere             anywhere            udp dpt:4665 
DROP       udp  --  anywhere             anywhere            udp dpt:4672 
ma il ciuco corre sempre come un matto, anzi, la connessione è immediata! ;D
Alla prima riga di quest'ultima stampata di terminale, però io leggo:

Codice: Seleziona tutto

ACCEPT     all  --  anywhere             anywhere  
Ma non è strano che ci sia un ACCEPT totale e dappertutto? Non è che questo scavalca le regole poi poste?

Avrei un altro chiarimento da chiedere, e si riferisce alle righe 124-125 e 180 dello script:

Codice: Seleziona tutto

###########################################
	# Regole di controllo su alcune porte TCP #
	# Servizi che voglio rendere disponibili  #
	# solo ai computer della rete interna     #
	###########################################
	$IPTABLES -A bad_tcp -p tcp -m multiport --dports 80,21,22,10000 -i $IFEXT -m state -s ! 10.1.1.0/24 --state NEW -j REJECT --reject-with icmp-net-unreachable
	$IPTABLES -A bad_tcp -p tcp -m multiport --dports 445,3306 -i $IFEXT -m state -s ! 10.1.1.0/24 --state NEW -j REJECT --reject-with icmp-net-unreachable
È corretto che io sostituisca 10.1.1.0/24 con il mio indirizzo di rete interna 10.0.0.1/24?
Se hai voglia di darci un'occhiata te ne sarei grato, mi basta qualche dritta poi ci lavoro io...
Grazie e buon lavoro su snort! :D
...fatti non foste a viver come bruti, ma per seguir virtute e canoscenza...
Scrivi risposta

Ritorna a “Sicurezza”

Chi c’è in linea

Visualizzano questa sezione: 0 utenti iscritti e 1 ospite