Bonjour,
voilà je suis un petit nouveau, je me suis configurer un serveur sous débian squeeze,
j’ai réussi à configurer pas mal de chose comme sécuriser apache2, ssl, …
tout fonctionne bien sans règle de filtrage iptable…
J’ai parcouru pas mal de tuto’s et lorsque j’applique mes règles de filtrage presque tout fonctionne sauf :
- Accès au partage de fichiers Samba client Win7
- Accès au serveur ftp par internet (il me demande le log et mot de pass, puis me met qu’il ne peut accéder à la page)
si j’enlève mes règles de filtrage tout refonctionne…
mon script iptable est le suivant :
[b]#!/bin/sh
IPTABLES="iptables"
IF_NET=“eth0”
Initialisation
modes pour le ftp[/b]
modprobe ip_nat_ftp
modprobe ip_conntrack_ftp
Vider les tables actuelles
iptables -t filter -F
Vider les regles 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 2215 -j ACCEPT
SSH Out
iptables -t filter -A OUTPUT -p tcp --dport 2215 -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
NTP Out
iptables -t filter -A OUTPUT -p udp --dport 123 -j ACCEPT
HTTP + HTTPS Out
iptables -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 10000 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 11000 -j ACCEPT
HTTP + HTTPS In
iptables -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 8443 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 10000 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 11000 -j ACCEPT
FTP Out
iptables -t filter -A OUTPUT -p tcp --dport 20:21 -j ACCEPT
FTP In
modprobe ip_conntrack_ftp # ligne facultative avec les serveurs OVH
iptables -t filter -A INPUT -p tcp --dport 20:21 -j ACCEPT
iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Mail SMTP:25
iptables -t filter -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 25 -j ACCEPT
EPMAP => definit toutes les RPC !
iptables -A INPUT -m state --state NEW -p TCP --dport 135 -j ACCEPT
iptables -A INPUT -m state --state NEW -p UDP --dport 135 -j ACCEPT
NetBios-NS
iptables -A INPUT -m state --state NEW -p TCP --dport 137 -j ACCEPT
iptables -A INPUT -m state --state NEW -p UDP --dport 137 -j ACCEPT
NetBios-DGM => exploration du reseau (base sur SMB browser service)
iptables -A INPUT -m state --state NEW -p UDP --dport 138 -j ACCEPT
NetBios-SSN => partage fichiers, imprimantes par Microsoft
iptables -A INPUT -m state --state NEW -p TCP --dport 139 -j ACCEPT
La commande iptables -L -v :
Chain INPUT (policy DROP 317 packets, 42332 bytes)
pkts bytes target prot opt in out source destination
0 0 fail2ban-ssh tcp – any any anywhere anywhere multiport dports ssh
847 69636 fail2ban-apache-overflows tcp – any any anywhere anywhere multiport dports www,https
847 69636 fail2ban-apache tcp – any any anywhere anywhere multiport dports www,https
50 2266 fail2ban-vsftpd tcp – any any anywhere anywhere multiport dports ftp,ftp-data,ftps,ftps-data
15255 1865K ACCEPT all – any any anywhere anywhere state RELATED,ESTABLISHED
285 25950 ACCEPT all – lo any anywhere anywhere
0 0 ACCEPT icmp – any any anywhere anywhere
1 52 ACCEPT tcp – any any anywhere anywhere tcp dpt:2215
0 0 ACCEPT tcp – any any anywhere anywhere tcp dpt:domain
0 0 ACCEPT udp – any any anywhere anywhere udp dpt:domain
1 52 ACCEPT tcp – any any anywhere anywhere tcp dpt:www
1 52 ACCEPT tcp – any any anywhere anywhere tcp dpt:https
0 0 ACCEPT tcp – any any anywhere anywhere tcp dpt:8443
1 52 ACCEPT tcp – any any anywhere anywhere tcp dpt:webmin
0 0 ACCEPT tcp – any any anywhere anywhere tcp dpt:11000
11 488 ACCEPT tcp – any any anywhere anywhere tcp dpts:ftp-data:ftp
0 0 ACCEPT all – any any anywhere anywhere state RELATED,ESTABLISHED
0 0 ACCEPT tcp – any any anywhere anywhere tcp dpt:smtp
0 0 ACCEPT tcp – any any anywhere anywhere state NEW tcp dpt:loc-srv
0 0 ACCEPT udp – any any anywhere anywhere state NEW udp dpt:loc-srv
0 0 ACCEPT tcp – any any anywhere anywhere state NEW tcp dpt:netbios-ns
157 12822 ACCEPT udp – any any anywhere anywhere state NEW udp dpt:netbios-ns
44 9835 ACCEPT udp – any any anywhere anywhere state NEW udp dpt:netbios-dgm
0 0 ACCEPT tcp – any any anywhere anywhere state NEW tcp dpt:netbios-ssn
0 0 ACCEPT tcp – any any anywhere anywhere state NEW tcp dpt:microsoft-ds
0 0 ACCEPT udp – any any anywhere anywhere state NEW udp dpt:microsoft-ds
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy DROP 60 packets, 7200 bytes)
pkts bytes target prot opt in out source destination
14622 1897K ACCEPT all – any any anywhere anywhere state RELATED,ESTABLISHED
285 25950 ACCEPT all – any lo anywhere anywhere
0 0 ACCEPT icmp – any any anywhere anywhere
0 0 ACCEPT tcp – any any anywhere anywhere tcp dpt:2215
2 120 ACCEPT tcp – any any anywhere anywhere tcp dpt:domain
435 26145 ACCEPT udp – any any anywhere anywhere udp dpt:domain
15 1140 ACCEPT udp – any any anywhere anywhere udp dpt:ntp
64 3840 ACCEPT tcp – any any anywhere anywhere tcp dpt:www
0 0 ACCEPT tcp – any any anywhere anywhere tcp dpt:https
0 0 ACCEPT tcp – any any anywhere anywhere tcp dpt:webmin
0 0 ACCEPT tcp – any any anywhere anywhere tcp dpt:11000
0 0 ACCEPT tcp – any any anywhere anywhere tcp dpts:ftp-data:ftp
0 0 ACCEPT tcp – any any anywhere anywhere tcp dpt:smtp
Chain fail2ban-apache (1 references)
pkts bytes target prot opt in out source destination
847 69636 RETURN all – any any anywhere anywhere
Chain fail2ban-apache-noscript (0 references)
pkts bytes target prot opt in out source destination
0 0 RETURN all – any any anywhere anywhere
Chain fail2ban-apache-overflows (1 references)
pkts bytes target prot opt in out source destination
847 69636 RETURN all – any any anywhere anywhere
Chain fail2ban-ssh (1 references)
pkts bytes target prot opt in out source destination
0 0 RETURN all – any any anywhere anywhere
Chain fail2ban-vsftpd (1 references)
pkts bytes target prot opt in out source destination
50 2266 RETURN all – any any anywhere anywhere
Si quelqu’un à une petite idée elle est la bienvenue…
Merci