Mon 1er script iptables

Mon 1er script iptables - Codes et scripts - Linux et OS Alternatifs

Marsh Posté le 12-01-2003 à 22:18:20    

Voila mon 1er script iptables , je voudrais votre avis :
 
[/cpp]  
 
#!/bin/sh
#
 
#Variables
LAN_FILTR=192.168.0.126/24;192.168.0.3/24
LAN_TRUST=192.168.0.2/24
 
#On flush tout
iptables -t filter -F
iptables -t filter -X
 
iptables -t nat -F
iptables -t nat -X
 
iptables -t mangle -F
iptables -t mangle -X
 
#Policy par default
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
 
#Localhost accepté
iptables -A INPUT -i 127.0.0.1 -j ACCEPT
iptables -A OUTPUT -o 127.0.0.1 -j ACCEPT
 
#Passerelle --> LAN autorisé
iptables -A OUTPUT -o eth0 -j ACCEPT
 
#LAN --> passerelle
 
     #serveur DNS
     iptables -A INPUT -i eth0 -s ! $LAN_TRUST --dport 53 -j ACCEPT
     iptables -A OUTPUT -o eth0 -s ! $LAN_TRUST --sport 53 -j ACCEPT
 
     #Seveur SAMBA
     iptables -A INPUT -i eth0 -s ! $LAN_TRUST -p tcp --dport 139 -j ACCEPT
     iptables -A OUTPUT -o eth0 -s ! $LAN_TRUST -p tcp --sport 139 -j ACCEPT
     iptables -A INPUT -i eth0 -s ! $LAN_TRUST -p udp --dport 137:138 -j ACCEPT
     iptables -A OUTPUT -o eth0 -s ! $LAN_TRUST -p udp --sport 137:138 -j ACCEPT
 
     #Serveur DHCP
     iptables -A INPUT -i eth0 -s ! $LAN_TRUST -p udp --dport 67 -j ACCEPT
     iptables -A OUTPUT -o eth0 -s ! $LAN_TRUST -p udp --sport 67 -j ACCEPT
 
 
     #Passerelle --> LAN de confiance (quoique ... )
     iptables -A INPUT -i eth0 -s $LAN_TRUST -j ACCEPT
 
#NAT --> ppp0
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o ppp0 -j MASQUERADE
 
#LAN --> NET
iptables -A FORWARD -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
 
#NET --> LAN
iptables -A FORWARD -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
 
#Requete du DNS --> DNS sur le NET
iptables -A OUTPUT -o ppp0 -p udp --sport 1024: --dport 53 -m state --state ! INVALID -j ACCEPT
iptables -A INPUT -i ppp0 -p udp --sport 53 --dport 1024: -m state --state RELATED,ESTABLISHED -j ACCEPT
 
#J'accepte les ICMP d'erreur
iptables -A INPUT -p icmp -m state --state RELATED -j ACCEPT
 
[/cpp]  
 
Ca m'a l'air assez bien . J'autorise le LAN a faire ce tout ce qu'ils veulent , mais personne ne peut etablire une nouvelle connection ( est-ce suffisant contre un trojan ou spyware ??? ) .
 
Quand je fait un # iptables -L , j'obtient ca :
 
target     prot opt source               destination          
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  -- !192.168.0.0/24       anywhere           tcp dpt:netbios-ssn  
ACCEPT     udp  -- !192.168.0.0/24       anywhere           udp dpts:netbios-ns:netbios-dgm  
ACCEPT     udp  -- !192.168.0.0/24       anywhere           udp dpt:bootps  
ACCEPT     all  --  192.168.0.0/24       anywhere            
ACCEPT     udp  --  anywhere             anywhere           udp spt:domain dpts:1024:65535 state RELATED,ESTABLISHED  
ACCEPT     icmp --  anywhere             anywhere           state RELATED  
 
Chain FORWARD (policy DROP)
target     prot opt source               destination          
ACCEPT     all  --  anywhere             anywhere           state NEW,RELATED,ESTABLISHED  
ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED  
 
Chain OUTPUT (policy DROP)
target     prot opt source               destination          
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  -- !192.168.0.0/24       anywhere           tcp spt:netbios-ssn  
ACCEPT     udp  -- !192.168.0.0/24       anywhere           udp spts:netbios-ns:netbios-dgm  
ACCEPT     udp  -- !192.168.0.0/24       anywhere           udp spt:bootps  
ACCEPT     udp  --  anywhere             anywhere           udp spts:1024:65535 dpt:domain state NEW,RELATED,ESTABLISHED  
 
 
La 1ere regle dans INPUT , n'est-elle pas dangeureuse ? (anywhere to anywhere alors que je demande -i lo , pareil dans OUTPUT d'ailleur )
 
Pareille dans les regles de FORWARD , j'ai anywhere to anywhere a chaque fois ...

Reply

Marsh Posté le 12-01-2003 à 22:18:20   

Reply

Marsh Posté le 12-01-2003 à 22:19:58    

au faite , comment faire pour mettre ce que l'on veut dans un cadre pour que se soit plus lisible ???

Reply

Marsh Posté le 12-01-2003 à 22:42:47    

tu le mets entre des balises fixed et /fixed


---------------
Celui qui pose une question est idiot 5 minutes. Celui qui n'en pose pas le reste toute sa vie. |  Membre du grand complot pharmaceutico-médico-scientifico-judéo-maçonnique.
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed