Bonjour,
Sur mon poste perso (petit serveur de fichiers basique), j’utilisais GUFW pour configurer le pare-feu.
GUFW me faisant des segmentation fault à tout-va, je me suis décidé à utiliser iptables directement.
En partant de ça : https://wiki.debian.org/iptables, j’ai fait ça :
[code]*filter
Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn’t use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Allows all outbound traffic
You could modify this to only allow certain traffic
-A OUTPUT -j ACCEPT
Allows HTTP and HTTPS connections from anywhere (the normal ports for websites)
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT
SSH connections
-A INPUT -p tcp -m state --state NEW --dport 45689 -j ACCEPT
Transmission
-A INPUT -p tcp --dport 58974 -j ACCEPT
-A INPUT -p udp --dport 58974 -j ACCEPT
Samba
-A INPUT -p tcp -m multiport --dports 135,139,445 -j ACCEPT
-A INPUT -p tcp -m multiport --sports 135,139,445 -j ACCEPT
-A INPUT -p udp -m multiport --dports 137,138 -j ACCEPT
-A INPUT -p udp -m multiport --sports 137,138 -j ACCEPT
Cups
-A INPUT -p tcp --dport 631 -j ACCEPT
-A INPUT -p udp --dport 631 -j ACCEPT
Rygel
-A INPUT -p udp --dport 1900 -j ACCEPT
-A INPUT -p tcp --dport 26541 -j ACCEPT
-A INPUT -p udp --dport 26541 -j ACCEPT
VNC
-A INPUT -p tcp --dport 33569 -j ACCEPT
Allow ping
note that blocking other types of icmp packets is considered a bad idea by some
remove -m icmp --icmp-type 8 from this line to allow all kinds of icmp:
https://security.stackexchange.com/questions/22711
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
log iptables denied calls (access via ‘dmesg’ command)
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
Reject all other inbound - default deny unless explicitly allowed policy:
-A INPUT -j REJECT
-A FORWARD -j REJECT
COMMIT[/code]
Première question, je voudrais savoir si c’est à peu près cohérent ?
Ce que j’ai compris ici : tout le traffic entant est bloqué sauf ce que j’accepte explicitement (HTTP & HTTPS, SSH, Transmission, samba, cups, rygel, vnc). En revanche, tout le traffic sortant est autorisé sans aucun filtre (on verra par la suite).
Ce que je n’ai pas compris ici (tout le reste en fait ) :
# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
# Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
[code]# Allow ping
note that blocking other types of icmp packets is considered a bad idea by some
remove -m icmp --icmp-type 8 from this line to allow all kinds of icmp:
https://security.stackexchange.com/questions/22711
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT[/code]
# Reject all other inbound - default deny unless explicitly allowed policy:
-A INPUT -j REJECT
-A FORWARD -j REJECT
Et il ya cette option state que je ne saisis pas :
-m state --state ESTABLISHED,RELATED
-m state --state NEW
Bon, soyez indulgents, j’en suis au début de mes investigations… Si certains d’entre vous pouvaient prendre quelques instants pour vulgariser un peu ?
Merci