J'aurai voulu savoir ce que vous pensez de mon firewall J'ai comme config réseau :
1 serveur sous linux relié en réseau avec 2 ordis sous windows
alors le voici
- Code: Tout sélectionner
#!/bin/sh
################
####By Matchek####
###############
set_vars() {
IPTABLES=/sbin/iptables
CLIENT_IP=192.168.0.3
CLIENT_IP2=192.168.0.4
INET_IP=xxx.xxx.xxx.xxx
ADSL=ppp0
LAN=eth0
IPAdmin=192.168.0.3
# Les Couleurs.
GRIS=$'\e[30;01m'
ROUGE=$'\e[31;01m'
VERT=$'\e[32;01m'
JAUNE=$'\e[33;01m'
BLEU=$'\e[34;01m'
ROSE=$'\e[35;01m'
BLEUCIEL=$'\e[36;01m'
BLANC=$'\e[37;01m'
DEFAULT=$'\e[0m'
# Set le nombre ce colones du stty
getcols() {
echo "$2"
}
COLS="`stty size 2> /dev/null`"
COLS="`getcols ${COLS}`"
COLS=$((${COLS} - 7))
# Les Variables divers
VER=V1.000
ERROR=1
}
MSGTITRE() {
# Message de Titre.
echo " ${GRIS}${*}"
return 0
}
MSGTETE() {
# Message de tete.
echo -e " ${BLEU}*${DEFAULT} ${*}..."
return 0
}
MSGFIN() {
# Message de fin.
local retval=
if [ "$#" -eq 0 ] || ([ -n "$1" ] && [ "$1" -eq 0 ])
then
echo -e "${ENDCOL} ${BLEU}[ ${VERT}ok${BLEU} ]${DEFAULT}"
else
retval="$1"
if [ "$#" -ge 2 ]
then
shift
echo -e " ${ROUGE}*${DEFAULT} ${*}"
fi
echo -e "${ENDCOL} ${BLEU}[ ${ROUGE}!!${BLEU} ]${DEFAULT}"
echo
return ${retval}
fi
return 0
}
MSGDEBUT() {
# Message du Debut.
echo " ${BLEU} ${*} ${VERT} $VER ${DEFAULT}"
return 0
}
INIT_IPTABLES () {
MSGTITRE "Initialisation de iptables."
# Activation de la passerelle
MSGTETE "Activation du FORWARDING"
echo 1 > /proc/sys/net/ipv4/ip_forward
MSGFIN
# On charge les modules
MSGTETE "Chargement du module ip_tables"
modprobe ip_tables
MSGFIN
MSGTETE "Chargement du module ip_nat_ftp"
modprobe ip_nat_ftp
MSGFIN
MSGTETE "Chargement du module ip_nat_irc"
modprobe ip_nat_irc
MSGFIN
MSGTETE "Chargement du module iptable_filter"
modprobe iptable_filter
MSGFIN
MSGTETE "Chargement du module iptable_mangle"
modprobe iptable_mangle
MSGFIN
MSGTETE "Chargement du module iptable_nat"
modprobe iptable_nat
MSGFIN
MSGTETE "Chargement du module ip_conntrack_ftp"
modprobe ip_conntrack_ftp
MSGFIN
MSGTETE "Chargement du module ip_conntrack_irc"
modprobe ip_conntrack_irc
MSGFIN
MSGTETE "Chargement du module ip_conntrack"
modprobe ip_conntrack
MSGFIN
# Les regles par default
MSGTETE "Nettoyage des anciennes regles"
$IPTABLES -F
$IPTABLES -X
$IPTABLES -t nat -F
$IPTABLES -t nat -X
$IPTABLES -t mangle -F
$IPTABLES -t mangle -X
MSGFIN
}
INIT_PROTECT () {
MSGTITRE "Protection contre les attaques"
MSGTETE "Anti-spooofing"
if [ -e /proc/sys/net/ipv4/conf/all/rp_filter ]
then
for filtre in /proc/sys/net/ipv4/conf/*/rp_filter
do
echo 1 > $filtre
done
fi
MSGFIN
MSGTETE "Ignore l'echo en ICMP"
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
MSGFIN
MSGTETE "Ignore messages d'erreur ICMP"
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
MSGFIN
MSGTETE "Protection contre l'acceptation des messages ICMP rediriges"
for filtre in /proc/sys/net/ipv4/conf/*/accept_redirects
do
echo 0 > filtre
done
for filtre in /proc/sys/net/ipv4/conf/*/send_redirects
do
echo 0 > filtre
done
for filtre in /proc/sys/net/ipv4/conf/*/accept_source_route
do
echo 0 > $filtre
done
MSGFIN
MSGTETE "Protection contre le syn-flood"
$IPTABLES -A FORWARD -p TCP --syn -m limit --limit 1/s -j ACCEPT
MSGFIN
MSGTETE "Protection contre le test de port furtif"
$IPTABLES -A FORWARD -p TCP --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
MSGFIN
MSGTETE "Protection contre le ping de la mort"
$IPTABLES -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
MSGFIN
MSGTETE "Loger les paquets spoofes et rediriges"
for f in /proc/sys/net/ipv4/conf/*/log_martians
do
echo 1 > $filtre
done
MSGFIN
MSGTETE "Pas de ICMP"
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
MSGFIN
MSGTETE "Pas de IGMP ni PIM"
# Ignorer le protocole IGMP
$IPTABLES -A INPUT -p igmp -j DROP
# Ignorer le protocole PIM
$IPTABLES -A INPUT -p pim -j DROP
MSGFIN
MSGTETE "Anti-syncookies"
if [ -e /proc/sys/net/ipv4/tcp_syncookies ]
then
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
fi
MSGFIN
MSGTETE "Anti-attaques DoS"
if [ -e /proc/sys/net/ipv4/tcp_fin_timeout ] &&
[ -e /proc/sys/net/ipv4/tcp_windows_scaling ] &&
[ -e /proc/sys/net/ipv4/tcp_timestamps ] &&
[ -e /proc/sys/net/ipv4/tcp_sack ] &&
[ -e /proc/sys/net/ipv4/tcp_max_syn_backlog ]
then
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
echo 0 > /proc/sys/net/ipv4/tcp_windows_scaling
echo 0 > /proc/sys/net/ipv4/tcp_timestamps
echo 0 > /proc/sys/net/ipv4/tcp_sack
echo 1024 > /proc/sys/net/ipv4/tcp_max_syn_backlog
fi
MSGFIN
}
INIT_FIREWALL () {
MSGTITRE "Initialisation du Firewall."
# On log tout
MSGTETE "Log les paquets drope ou accepte"
$IPTABLES -N LOG_DROP
$IPTABLES -A LOG_DROP -j LOG --log-prefix '[IPTABLES DROP] : '
$IPTABLES -A LOG_DROP -j DROP
$IPTABLES -N LOG_ACCEPT
$IPTABLES -A LOG_ACCEPT -j LOG --log-prefix '[IPTABLES ACCEPT] : '
$IPTABLES -A LOG_ACCEPT -j ACCEPT
MSGFIN
# On bloque tout
MSGTETE "La politique par defaut REFUSER TOUT"
$IPTABLES -P INPUT DROP
$IPTABLES -P FORWARD DROP
$IPTABLES -P OUTPUT DROP
MSGFIN
# Reseau local et localhost
MSGTETE "Tout accepter en local"
$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A OUTPUT -o lo -j ACCEPT
MSGFIN
# Les interdictions
MSGTETE "Interdictions"
$IPTABLES -A INPUT -p tcp --dport 21 -i $ADSL -j DROP
$IPTABLES -A INPUT -p tcp --dport 22 -i $ADSL -j DROP
$IPTABLES -A INPUT -p tcp --dport 23 -i $ADSL -j DROP
$IPTABLES -A INPUT -p tcp --dport 25 -i $ADSL -j DROP
$IPTABLES -A INPUT -p tcp --dport 110 -i $ADSL -j DROP
$IPTABLES -A INPUT -p tcp --dport 111 -i $ADSL -j DROP
$IPTABLES -A INPUT -p udp --dport 111 -i $ADSL -j DROP
$IPTABLES -A INPUT -p tcp --dport 135:139 -i $ADSL -j DROP
$IPTABLES -A INPUT -p udp --dport 135:139 -i $ADSL -j DROP
$IPTABLES -A INPUT -p tcp --dport 143 -i $ADSL -j DROP
$IPTABLES -A INPUT -p tcp --dport 445 -i $ADSL -j DROP
$IPTABLES -A INPUT -p udp --dport 445 -i $ADSL -j DROP
$IPTABLES -A INPUT -p tcp --dport 515 -i $ADSL -j DROP
$IPTABLES -A INPUT -p tcp --dport 6000:6009 -i $ADSL -j DROP
# IP interdites
$IPTABLES -A INPUT -i $ADSL -p ALL -j DROP -s 10.0.0.255
$IPTABLES -A INPUT -i $ADSL -p ALL -j DROP -d 10.0.0.255
$IPTABLES -A OUTPUT -o $ADSL -p ALL -j DROP -s 10.0.0.255
$IPTABLES -A OUTPUT -o $ADSL -p ALL -j DROP -d 10.0.0.255
$IPTABLES -A INPUT -i $ADSL -p ALL -j DROP -s 0.0.0.0
$IPTABLES -A INPUT -i $ADSL -p ALL -j DROP -d 0.0.0.0
$IPTABLES -A OUTPUT -o $ADSL -p ALL -j DROP -s 0.0.0.0
$IPTABLES -A OUTPUT -o $ADSL -p ALL -j DROP -d 0.0.0.0
$IPTABLES -A INPUT -i $ADSL -p ALL -j DROP -s 255.255.255.255
$IPTABLES -A INPUT -i $ADSL -p ALL -j DROP -d 255.255.255.255
$IPTABLES -A OUTPUT -o $ADSL -p ALL -j DROP -s 255.255.255.255
$IPTABLES -A OUTPUT -o $ADSL -p ALL -j DROP -d 255.255.255.255
# Antispoofing
$IPTABLES -t nat -I PREROUTING -i $ADSL -s 127.0.0.0/8 -j DROP
$IPTABLES -t nat -I PREROUTING -i $ADSL -s 10.0.0.0/8 -j DROP
$IPTABLES -t nat -I PREROUTING -i $ADSL -s 169.254.0.0/16 -j DROP
$IPTABLES -t nat -I PREROUTING -i $ADSL -s 172.16.0.0/12 -j DROP
$IPTABLES -t nat -I PREROUTING -i $ADSL -s 192.168.2.0/24 -j DROP
$IPTABLES -t nat -I PREROUTING -i $ADSL -s 192.168.0.0/24 -j DROP
$IPTABLES -t nat -I PREROUTING -i $ADSL -s 192.168.0.0/16 -j DROP
$IPTABLES -t nat -I PREROUTING -i $ADSL -s 224.0.0.1/4 -j DROP
$IPTABLES -t nat -I PREROUTING -i $ADSL -s 240.0.0.0/4 -j DROP
$IPTABLES -A INPUT -i $ADSL -s 127.0.0.0/8 -j DROP
$IPTABLES -A INPUT -i $ADSL -s 10.0.0.0/8 -j DROP
$IPTABLES -A INPUT -i $ADSL -s 169.254.0.0/16 -j DROP
$IPTABLES -A INPUT -i $ADSL -s 172.16.0.0/12 -j DROP
$IPTABLES -A INPUT -i $ADSL -s 192.0.2.0/24 -j DROP
$IPTABLES -A INPUT -i $ADSL -s 192.168.0.0/24 -j DROP
$IPTABLES -A INPUT -i $ADSL -s 192.168.0.0/16 -j DROP
$IPTABLES -A INPUT -i $ADSL -s 224.0.0.1/4 -j DROP
$IPTABLES -A INPUT -i $ADSL -s 240.0.0.0/4 -j DROP
MSGFIN
}
INIT_OUTADSL () {
MSGTITRE "FIREWALL -> INTERNET."
# Acces web
MSGTETE "Pour le HTTP"
$IPTABLES -A OUTPUT -o $ADSL -m state --state NEW,ESTABLISHED -p tcp --dport 80 -j ACCEPT
$IPTABLES -A INPUT -i $ADSL -m state --state ESTABLISHED -p tcp --sport 80 -j ACCEPT
MSGFIN
# Acces https
MSGTETE "Pour le https"
$IPTABLES -A OUTPUT -o $ADSL -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A INPUT -i $ADSL -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT
MSGFIN
# Acces domain
MSGTETE "Pour le DNS"
$IPTABLES -A OUTPUT -o $ADSL -m state --state NEW,ESTABLISHED -p udp --dport 53 -j ACCEPT
$IPTABLES -A INPUT -i $ADSL -m state --state ESTABLISHED -p udp --sport 53 -j ACCEPT
MSGFIN
# Acces ftp
MSGTETE "Pour le ftp"
$IPTABLES -A OUTPUT -o $ADSL -p tcp --dport 21 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A INPUT -i $ADSL -p tcp --sport 21 -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A OUTPUT -o $ADSL -p tcp --dport 20 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A INPUT -i $ADSL -p tcp --sport 20 -m state --state ESTABLISHED,RELATED -j ACCEPT
MSGFIN
}
INIT_FORWARD () {
MSGTITRE "LAN -> INTERNET."
# Ports emule
MSGTETE "Pour emule"
#$IPTABLES -A FORWARD -p tcp --dport 4682 -i $ADSL -j ACCEPT
#$IPTABLES -t nat -A PREROUTING -i $ADSL -d $INET_IP -p tcp --dport 4682 -j DNAT --to-destination $CLIENT_IP:4682
MSGFIN
MSGTETE "Pour le DNS"
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p udp --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p udp --sport 53 -m state --state ESTABLISHED -j ACCEPT
MSGFIN
MSGTETE "Pour SMTP"
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p tcp --sport 25 -m state --state ESTABLISHED -j ACCEPT
MSGFIN
MSGTETE "Pour POP"
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p tcp --dport 110 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p tcp --sport 110 -m state --state ESTABLISHED -j ACCEPT
MSGFIN
MSGTETE "Pour le https"
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT
MSGFIN
MSGTETE "Pour le ftp"
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p tcp --dport 21 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p tcp --sport 21 -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p tcp --dport 20 -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p tcp --sport 20 -m state --state ESTABLISHED,RELATED -j ACCEPT
MSGFIN
MSGTETE "Pour msn"
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p tcp --dport 1863 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p tcp --sport 1863 -m state --state ESTABLISHED -j ACCEPT
MSGFIN
MSGTETE "Pour mIRC"
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p tcp --dport 6667:6669 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p tcp --sport 6667:6669 -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p tcp --sport 1024:65535 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p tcp --sport 1024:65535 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
MSGFIN
MSGTETE "Pour skype"
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p udp --sport 3426 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p udp --dport 3426 -m state --state ESTABLISHED -j ACCEPT
MSGFIN
MSGTETE "Pour cs"
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p tcp --dport 27030:27039 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p udp --dport 27015:27030 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p tcp --sport 27030:27039 -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p udp --sport 27015:27030 -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p udp --dport 27000:27015 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p udp --sport 27000:27015 -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p udp --dport 1200 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p udp --sport 1200 -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p udp --sport 1096 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p udp --dport 1096 -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p udp --sport 27243:27244 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p tcp --dport 27243 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p udp --dport 27244 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p udp --dport 27244 -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p udp --sport 1560:1563 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p udp --dport 1560:1563 -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A FORWARD -i $LAN -o $ADSL -p icmp -s 192.168.0.3 -j ACCEPT
$IPTABLES -A FORWARD -i $ADSL -o $LAN -p icmp -d 192.168.0.3 -j ACCEPT
MSGFIN
}
INIT_INLAN () {
MSGTITRE "LAN -> FIREWALL."
# Redirection proxy
MSGTETE "Pour Squid"
$IPTABLES -A INPUT -i $LAN -p tcp --dport 8080 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A OUTPUT -o $LAN -p tcp --sport 8080 -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -t nat -A PREROUTING -i $LAN -p tcp --dport 80 -j REDIRECT --to-port 8080
MSGFIN
MSGTETE "Pour le ssh"
$IPTABLES -A INPUT -i $LAN -p tcp --source $IPAdmin --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A OUTPUT -o $LAN -p tcp --destination $IPAdmin --sport 22 -m state --state ESTABLISHED -j ACCEPT
MSGFIN
MSGTETE "Pour samba"
$IPTABLES -A INPUT -i $LAN -p tcp --source $IPAdmin --dport 445 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A OUTPUT -o $LAN -p tcp --destination $IPAdmin --sport 445 -m state --state ESTABLISHED -j ACCEPT
$IPTABLES -A INPUT -i $LAN -p tcp --source $IPAdmin --dport 135:139 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A OUTPUT -o $LAN -p tcp --destination $IPAdmin --sport 135:139 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A INPUT -i $LAN -p udp --source $IPAdmin --dport 135:139 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A OUTPUT -o $LAN -p udp --destination $IPAdmin --sport 135:139 -m state --state NEW,ESTABLISHED -j ACCEPT
MSGFIN
MSGTETE "Pour vnc"
$IPTABLES -A INPUT -i $LAN -p tcp --source $IPAdmin --dport 5901 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A OUTPUT -o $LAN -p tcp --destination $IPAdmin --sport 5901 -m state --state ESTABLISHED -j ACCEPT
MSGFIN
MSGTETE "Pour le Webmin"
$IPTABLES -A INPUT -i $LAN -p tcp --source $IPAdmin --dport 10000 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPTABLES -A OUTPUT -o $LAN -p tcp --destination $IPAdmin --sport 10000 -m state --state ESTABLISHED -j ACCEPT
MSGFIN
}
INIT_MASK () {
MSGTITRE "Masquerade & LOG des paquets."
# Le masquerade
MSGTETE "Masquerade des adressse du LAN"
$IPTABLES -t nat -A POSTROUTING -s 192.168.0.0/24 -o $ADSL -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -s 192.168.0.0/255.255.255.0 -o $ADSL -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -s 192.168.0.0/255.255.255.255 -o $ADSL -j MASQUERADE
$IPTABLES -t nat -A POSTROUTING -o $ADSL -j MASQUERADE
MSGFIN
MSGTETE "Log des paquet DROP"
$IPTABLES -A FORWARD -j LOG_DROP
$IPTABLES -A INPUT -j LOG_DROP
$IPTABLES -A OUTPUT -j LOG_DROP
$IPTABLES -P INPUT DROP
$IPTABLES -P FORWARD DROP
$IPTABLES -P OUTPUT DROP
MSGFIN
}
INIT_FLUSH () {
MSGTITRE "Vider les regles iptables."
MSGTETE "La police par defaut ACCEPT"
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT
MSGFIN
# Les tables NAT et MANGLE
MSGTETE "Polices par defaut pour la table NAT"
$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT
$IPTABLES -t nat -P OUTPUT ACCEPT
$IPTABLES -t mangle -P PREROUTING ACCEPT
$IPTABLES -t mangle -P INPUT ACCEPT
$IPTABLES -t mangle -P OUTPUT ACCEPT
$IPTABLES -t mangle -P FORWARD ACCEPT
$IPTABLES -t mangle -P POSTROUTING ACCEPT
MSGFIN
MSGTETE "On vide toutes les regles existantes"
$IPTABLES -F
$IPTABLES -t nat -F
$IPTABLES -t mangle -F
MSGFIN
MSGTETE "Efface les chaines qui ne sont pas par defaut dans la table filter et nat"
$IPTABLES -X
$IPTABLES -t nat -X
$IPTABLES -t mangle -X
MSGFIN
}
start() {
set_vars
MSGDEBUT "Lancement du firewall en mode START"
INIT_IPTABLES
INIT_PROTECT
INIT_FIREWALL
INIT_OUTADSL
INIT_FORWARD
INIT_INLAN
INIT_MASK
}
stop() {
set_vars
MSGDEBUT "Lancement du firewall en mode STOP"
INIT_FLUSH
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
iptables -L
iptables -t nat -L
iptables -t mangle -L
RETVAL=?
;;
*)
set_vars
echo "${BLEU}Usage: ${ROUGE}firewall ${VERT} {start|stop|restart|status} ${DEFAULT}"
RETVAL=1
esac
exit