Οι παρακάτω οδηγίες είναι για όσους θέλουν να έχουν firewall σε Debian/Ubuntu. Χρησιμοποιεί iptables.
Αυτές οι οδηγίες έχουν δοκιμαστεί σε Debian unstable & Ubuntu. Για όποιον δεν θέλει να γράφει όλα τα παρακάτω έχω φτιάξει ένα script που τα κάνει αυτόματα. Αφού το κατεβάσετε το τρέχετε με "source create-firewall.sh"
Το # είναι η γραμμή εντολών (για τον χρήστη root - για να γίνετε root γραψτε "sudo su -" στη γραμμή εντολών
# apt-get install iptables
Κατεβάστε το script που τα κάνει αυτόματα όλη τη διαδικασία και εκτελέστε το με "source create-firewall.sh"
ή
Προτιμώ να βάζω τα δικά μου scripts σε έναν κατάλογο (/etc/myscripts) για να είναι όλα μαζί. Πρώτα φτιάχνουμε τον κατάλογο και μετά δημιουργούμε το αρχείο με τους κανόνες.
# mkdir /etc/myscripts
# editor /etc/myscripts/firewall (μπορείτε αντί για την εντολή editor να βάλετε τον αγαπημένο σας editor nano, pico, vi ή ακόμα και kedit ή gedit σε περιβάλλον KDE ή Gnome)
Στο αρχείο βάζουμε τα παρακάτω:
#!/bin/sh
# firewall script created by jtsop
# easily manage your firewall configuration
# visit http://tsopokis.gr for more info
#--------------------------------------------------------------
# Clear iptables entries
#--------------------------------------------------------------
iptables -F
#--------------------------------------------------------------
# Revert to default chains
#--------------------------------------------------------------
iptables -X
#--------------------------------------------------------------
# Drop packets marked for forwarding
#--------------------------------------------------------------
iptables -P FORWARD DROP
#--------------------------------------------------------------
# Drop incoming packets - will create rules later
#--------------------------------------------------------------
iptables -P INPUT DROP
#--------------------------------------------------------------
# Allow outgoing traffic
#--------------------------------------------------------------
iptables -P OUTPUT ACCEPT
#--------------------------------------------------------------
# Allow incoming traffic from localhost
#--------------------------------------------------------------
iptables -A INPUT -i lo -j ACCEPT
#--------------------------------------------------------------
# Allow ICMP echo-replies (pings)
#--------------------------------------------------------------
iptables -A INPUT -i eth0 -p icmp -j ACCEPT
#---------------------------------------------------------------
# Allow outbound DNS queries from the FW and the replies too
#
# - Interface eth0 is the internet interface
#
# Zone transfers use TCP and not UDP. Most home networks
# / websites using a single DNS server won't require TCP statements
#
#---------------------------------------------------------------
iptables -A INPUT -p udp -i eth0 --sport 53 --dport 1024:65535 -j ACCEPT
#---------------------------------------------------------------
# Allow previously established connections
# - Interface eth0 is the internet interface
#---------------------------------------------------------------
iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED -i eth0 -p tcp
#---------------------------------------------------------------
# Allow port 80 (www) and 22 (SSH) connections to the firewall (uncomment them in order to work)
#---------------------------------------------------------------
#iptables -A INPUT -p tcp -i eth0 --dport 22 --sport 1024:65535 -m state --state NEW -j ACCEPT
#iptables -A INPUT -p tcp -i eth0 --dport 80 --sport 1024:65535 -m state --state NEW -j ACCEPT
#---------------------------------------------------------------
# Show iptables current config
#---------------------------------------------------------------
iptables -L
# chmod +x /etc/myscripts/firewall
# cd /etc/init.d/ && ln -s ../myscripts/firewall firewall
# cd /etc/rc2.d/ && ln -s ../init.d/firewall S57firewall
# cd /etc/rc3.d/ && ln -s ../init.d/firewall S57firewall
# cd /etc/rc4.d/ && ln -s ../init.d/firewall S57firewall
# cd /etc/rc5.d/ && ln -s ../init.d/firewall S57firewall
# /etc/init.d/firewall
Πλέον έχουμε το firewall σε λειτουργία!!
# editor /etc/init.d/firewall
Από tsopokis.gr