Bonjour à vous,
Je me suis un peu pris la tête sur les iptables, je crois avoir compris l’essentiel… j’ai donc fait un script que j’ai mis dans mon /etc/init.d/monIptable.
Le voici :
[code]#!/bin/bash
#Script parefeu iptables.
#Interdiction des connexions entrantes et sortantes(toutes)
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
#Log de ce que l’on jette
iptables -N LOG_DROP
iptables -A LOG_DROP -j LOG --log-prefix '[IPTABLES DROP] : ’
iptables -A LOG_DROP -j DROP
iptables -A FORWARD -j LOG_DROP
iptables -A INPUT -j LOG_DROP
iptables -A OUTPUT -j LOG_DROP
#vidage règles existantes
iptables -F
iptables -t nat -F
iptables -X
iptables -t nat -X
#Accept les connexions déjà établies
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#LOG de ce que l’on accept
iptables -N LOG_ACCEPT
iptables -A LOG_ACCEPT -j LOG --log-prefix '[IPTABLES ACCEPT] : ’
iptables -A LOG_ACCEPT -j ACCEPT
iptables -A FORWARD -j LOG_ACCEPT
iptables -A INPUT -j LOG_ACCEPT
iptables -A OUTPUT -j LOG_ACCEPT
#Accepter ce qui se passe sur le réseau local (lo et lan)
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -s 192.168.0.0/24 -j ACCEPT
27,1 Haut
[/code]
Lorsque je vérifie si tout est pris en compte :
[code]sudo iptables -L
[sudo] password for toto:
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all – anywhere anywhere state RELATED,ESTABLISHED
LOG_ACCEPT all – anywhere anywhere
ACCEPT all – anywhere anywhere
ACCEPT all – 192.168.0.0/24 anywhere
ACCEPT icmp – anywhere anywhere
ACCEPT udp – anywhere anywhere udp spt:domain
ACCEPT tcp – anywhere anywhere tcp spt:domain
ACCEPT tcp – anywhere anywhere tcp dpt:http
ACCEPT tcp – anywhere anywhere tcp dpt:63598
ACCEPT tcp – anywhere anywhere tcp dpt:urd
ACCEPT tcp – anywhere anywhere tcp dpt:imaps
ACCEPT tcp – anywhere anywhere tcp dpt:ftp-data
ACCEPT tcp – anywhere anywhere tcp dpt:ftp
Chain FORWARD (policy DROP)
target prot opt source destination
LOG_ACCEPT all – anywhere anywhere
ACCEPT all – 192.168.0.0/24 anywhere
Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT all – anywhere anywhere state RELATED,ESTABLISHED
LOG_ACCEPT all – anywhere anywhere
ACCEPT all – anywhere anywhere
ACCEPT all – anywhere 192.168.0.0/24
ACCEPT udp – anywhere anywhere udp dpt:domain
ACCEPT tcp – anywhere anywhere tcp dpt:domain
ACCEPT tcp – anywhere anywhere tcp dpt:http
ACCEPT tcp – anywhere anywhere tcp dpt:63598
ACCEPT tcp – anywhere anywhere tcp dpt:urd
ACCEPT tcp – anywhere anywhere tcp dpt:imaps
ACCEPT tcp – anywhere anywhere tcp dpt:ftp-data
ACCEPT tcp – anywhere anywhere tcp dpt:ftp
ACCEPT udp – anywhere ns0.fdn.fr
ACCEPT tcp – anywhere ns0.fdn.org
Chain LOG_ACCEPT (3 references)
target prot opt source destination
LOG all – anywhere anywhere LOG level warning prefix "[IPTABLES ACCEPT] : "
ACCEPT all – anywhere anywhere [/code]
J’ai pourtant un doute…
LOG_ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
J’ai l’impression que cette ligne autorise tout le trafic, je me trompe ?
Merci à vous !





