Un Firewall, reperto storico del 2007…

iptables -F FORWARD
iptables -F INPUT
iptables -F OUTPUT
#
# passa tutto di default
iptables -P FORWARD DROP
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
#
################################
## NAT
################################
#
# source nat
iptables -t nat -A POSTROUTING -o eth0 -s 10.127.0.0/22 -d ! 10.127.0.0/22 -j SNAT –to-source 192.168.84.27
#
# destination nat
iptables -t nat -A PREROUTING -i eth0 -p tcp -d 192.168.84.27 –dport 8080 -j DNAT –to 10.127.3.1
iptables -t nat -A PREROUTING -i eth0 -p tcp -d 192.168.84.27 –dport 8007 -j DNAT –to 10.127.3.1
iptables -t nat -A PREROUTING -i eth0 -p tcp -d 192.168.84.27 –dport 8888 -j DNAT –to 10.127.2.1
iptables -t nat -A PREROUTING -i eth0 -p tcp -d 192.168.84.27 –dport 22 -j DNAT –to 10.127.2.1
#
################################
## DIVIETI
################################
#
# vietata la creazione di connessioni verso indirizzi proibiti
for indirizzo_proibito in `cat /export/alt/firewall/lista_indirizzi_proibiti`;
do iptables -A FORWARD -s 10.127.0.0/22 -d $indirizzo_proibito -j DROP;
done
#
# vietato l’uso della porta 22 agli hosts in punizione
for host_in_punizione in `cat /export/alt/firewall/lista_host_in_punizione`;
do iptables -A FORWARD -s $host_in_punizione -p tcp –dport 22 -j DROP;
done
#
# vietate le connessioni in entrata da ip sgraditi
for ospite_sgradito in `cat /export/alt/firewall/lista_ospiti_sgraditi`;
do iptables -A FORWARD -s $ospite_sgradito -p tcp -m state –state NEW -j DROP;
done
#
# vietato l’uso della porta 8080 agli hosts del gruppo 1
for host_del_gruppo_1 in `cat /export/alt/firewall/gruppo_1`;
do iptables -A FORWARD -s $host_del_gruppo_1 -p tcp –dport 8080 -j DROP;
done
#
################################
## PERMESSI
################################
#
# le risposte sono sempre accettate
iptables -A FORWARD -p tcp -m state –state ESTABLISHED -j ACCEPT
iptables -A FORWARD -p tcp -m state –state RELATED -j ACCEPT
#
# i servizi speciali interni permessi a tutti
iptables -A FORWARD -d 10.127.3.1 -p tcp –dport 8080 -j ACCEPT
iptables -A FORWARD -d 10.127.3.1 -p tcp –dport 8007 -j ACCEPT
iptables -A FORWARD -d 10.127.2.1 -p tcp –dport 8888 -j ACCEPT
iptables -A FORWARD -d 10.127.2.1 -p tcp –dport 22 -j ACCEPT
#
# i servizi esterni alla rete permessi agli host
iptables -A FORWARD -o eth0 -s 10.127.0.0/22 -p tcp –dport 80 -j ACCEPT
iptables -A FORWARD -o eth0 -s 10.127.0.0/22 -p tcp –dport 22 -j ACCEPT
iptables -A FORWARD -o eth0 -s 10.127.0.0/22 -p tcp –dport 110 -j ACCEPT
iptables -A FORWARD -o eth0 -s 10.127.0.0/22 -p tcp –dport 25 -j ACCEPT
iptables -A FORWARD -o eth0 -s 10.112.0.0/22 -p tcp –dport 80 -j ACCEPT
iptables -A FORWARD -o eth0 -s 10.112.0.0/22 -p tcp –dport 22 -j ACCEPT
iptables -A FORWARD -o eth0 -s 10.112.0.0/22 -p tcp –dport 110 -j ACCEPT
iptables -A FORWARD -o eth0 -s 10.112.0.0/22 -p tcp –dport 25 -j ACCEPT
#
# il servizio speciale permesso agli hosts del gruppo 2, ma solo tra loro
for host_del_gruppo_2 in `cat /export/alt/firewall/gruppo_2`;
do iptables -A FORWARD -s $host_del_gruppo_2 -d $host_del_gruppo_2 -p tcp –dport 8888 -j ACCEPT;
done
#
# i servizi permessi all’interno dalla rete (solo 22 e 8080)
iptables -A FORWARD -s 10.127.0.0/22 -d 10.127.0.0/22 -p tcp –dport 22 -j ACCEPT
iptables -A FORWARD -s 10.112.0.0/22 -d 10.112.0.0/22 -p tcp –dport 22 -j ACCEPT
iptables -A FORWARD -s 10.127.0.0/22 -d 10.112.0.0/22 -p tcp –dport 22 -j ACCEPT
iptables -A FORWARD -s 10.112.0.0/22 -d 10.127.0.0/22 -p tcp –dport 22 -j ACCEPT
#
iptables -A FORWARD -s 10.127.0.0/22 -d 10.127.0.0/22 -p tcp –dport 8080 -j ACCEPT
iptables -A FORWARD -s 10.112.0.0/22 -d 10.112.0.0/22 -p tcp –dport 8080 -j ACCEPT
iptables -A FORWARD -s 10.127.0.0/22 -d 10.112.0.0/22 -p tcp –dport 8080 -j ACCEPT
iptables -A FORWARD -s 10.112.0.0/22 -d 10.127.0.0/22 -p tcp –dport 8080 -j ACCEPT
#
iptables -A FORWARD -s 10.127.0.0/22 -d 10.127.0.0/22 -p tcp –dport 80 -j ACCEPT
iptables -A FORWARD -s 10.112.0.0/22 -d 10.112.0.0/22 -p tcp –dport 80 -j ACCEPT
iptables -A FORWARD -s 10.127.0.0/22 -d 10.112.0.0/22 -p tcp –dport 80 -j ACCEPT
iptables -A FORWARD -s 10.112.0.0/22 -d 10.127.0.0/22 -p tcp –dport 80 -j ACCEPT
#
################################
## OPEN VPN
################################
#
iptables -A FORWARD -d 192.168.84.27 -p udp –dport 1194 -j ACCEPT
#
#iptables -A FORWARD -j LOG –log-level 7 –log-prefix “Ruth’s firewall:

Read more from the Università category. If you would like to leave a comment, click here: Comment. or stay up to date with this post via RSS, or you can Trackback from your site.
Social Bookmark : Technorati, Digg, de.licio.us, Yahoo, Blinkbits, Blogmarks, Google, Magnolia.

Leave a Comment

Name (required)

Email (required)

Sito web

Commenti