1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#!/bin/sh
# Vider les tables actuelles
iptables -t filter -F
# Vider les règles personnelles
iptables -t filter -X
# ---
# Interdire toute connexion entrante et sortante
iptables -t filter -P INPUT DROP
iptables -t filter -P FORWARD DROP
iptables -t filter -P OUTPUT DROP
# Ne pas casser les connexions etablies
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
# Autoriser loopback
iptables -t filter -A INPUT -i lo -j ACCEPT
iptables -t filter -A OUTPUT -o lo -j ACCEPT
# ICMP (Ping)
iptables -t filter -A INPUT -p icmp -j ACCEPT
iptables -t filter -A OUTPUT -p icmp -j ACCEPT
# ---
# SSH In
iptables -t filter -A INPUT -p tcp --dport 22 -j ACCEPT
# SSH Out
iptables -t filter -A OUTPUT -p tcp --dport 22 -j ACCEPT
# DNS In/Out
iptables -t filter -A OUTPUT -p tcp --dport 53 -j ACCEPT
iptables -t filter -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -t filter -A INPUT -p udp --dport 53 -j ACCEPT
# Permet de contacter la machine sous « son nom d'hote ».local
iptables -t filter -A INPUT -p udp -d 224.0.0.251 --dport mdns -j ACCEPT
# Streaming Logiciel In/Out
iptables -t filter -A OUTPUT -p tcp --dport 554 -j ACCEPT
iptables -t filter -A OUTPUT -p udp --dport 554 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 554 -j ACCEPT
iptables -t filter -A INPUT -p udp --dport 554 -j ACCEPT
# Connexion Internet
iptables -A INPUT -i breth0 --protocol tcp --source-port 80 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o breth0 --protocol tcp --destination-port 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i breth0 --protocol tcp --destination-port 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -o breth0 --protocol tcp --source-port 80 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Gigatribe
iptables -t filter -A OUTPUT -p tcp --dport 6666 -j ACCEPT
iptables -t filter -A OUTPUT -p udp --dport 6666 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 6666 -j ACCEPT
iptables -t filter -A INPUT -p udp --dport 6666 -j ACCEPT
# Bureau a distance
iptables -t filter -A OUTPUT -p tcp --dport 9999 -j ACCEPT
iptables -t filter -A OUTPUT -p udp --dport 9999 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 9999 -j ACCEPT
iptables -t filter -A INPUT -p udp --dport 9999 -j ACCEPT
# Samba
iptables -A INPUT -p udp --dport 137 -j ACCEPT
iptables -A INPUT -p udp --dport 138 -j ACCEPT
iptables -A INPUT -p tcp --dport 139 -j ACCEPT
# La regle par defaut pour la chaine INPUT devient REJECT (contrairement
# a DROP qui ignore les paquets, avec REJECT, l expediteur est averti du refus).
# On note les paquets qui vont etre jetes.
iptables -t filter -A INPUT -j LOG --log-prefix "paquet IPv4 inattendu "
iptables -t filter -A INPUT -j REJECT |
Partager