J’ai fais un petit script qui est sensé tester si le firewall sur ma machine est bien actif.
Etant donnée que “DROP” est dans mon script de firewall, j’ai fais ceci pour le tester.
[code]FIREWALL=“ON”
…
Test du service firewall
if [[ $FIREWALL = “ON” ]] ; then
FIREWALL=iptables -L | grep "DROP "
if [[ $FIREWALL = “” ]] ; then
FIREWALL='STOP’
DEFAUT="OUI"
else
FIREWALL='START’
fi
fi
echo $FIREWALL[/code]
Lorsque je le lance à la main, pas de problème, par contre des que le lance dans un crontab, la variable $FIREWALL est vide.
Merci à toi d’avoir pris la peine de donner la solution, même si tu l’as trouvée toi-même.
C’est, malheureusement, pas toujours ce que font certains membres, dommage !
[quote=“ricardo”]Merci à toi d’avoir pris la peine de donner la solution, même si tu l’as trouvée toi-même.
C’est, malheureusement, pas toujours ce que font certains membres, dommage ![/quote]
+1
[quote=“lol”][quote=“ricardo”]Merci à toi d’avoir pris la peine de donner la solution, même si tu l’as trouvée toi-même.
C’est, malheureusement, pas toujours ce que font certains membres, dommage ![/quote]
+1
Très pratique ce petit script ![/quote]
Oui, il m’intéresse aussi mais à modifier “à ma sauce”.
[code]lagache:/home/chris# iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all – anywhere anywhere
ACCEPT all – anywhere anywhere state RELATED,ESTABLISHED
ACCEPT all – anywhere anywhere state NEW
ACCEPT tcp – anywhere anywhere state NEW tcp dpt:58400
ACCEPT tcp – anywhere anywhere state NEW tcp dpt:58410
ACCEPT tcp – anywhere anywhere state NEW tcp dpt:www
ACCEPT tcp – anywhere anywhere state NEW tcp dpt:ftp
Chain FORWARD (policy DROP)
target prot opt source destination
REJECT all – 192.168.30.2 anywhere reject-with icmp-admin-prohibited
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 state RELATED,ESTABLISHED
ACCEPT all – anywhere anywhere
ACCEPT tcp – anywhere anywhere state NEW tcp dpt:5900
ACCEPT tcp – anywhere anywhere state NEW tcp dpt:ssh
ACCEPT tcp – anywhere anywhere state NEW tcp dpt:rsync[/code]
VAR=$(iptables -L | grep -q '^Chain [A-Z]* (policy DROP)$' | wc -l )
if [ $VAR -eq 3 ]; then
FIREWALL='START';
else
FIREWALL='STOP';
fi
Ça ça doit fonctionner.