1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#!/bin/bash
. /etc/init.d/functions
. /etc/sysconfig/network
if [ ${NETWORKING} = "no" ]
then
exit 0
fi
if [ ! -x /sbin/iptables ] ; then
exit 0
fi
case "$1" in
start)
echo -n "iptables demarre : "
#regle d'initiation--------------------------
iptables -F
iptables -X
#parametre par default-----------------------
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
# --- --- RULES
# --- LO
iptables -A OUTPUT -o lo -s 127.0.0.0/8 -d 127.0.0.0/8 -j ACCEPT
iptables -A INPUT -i lo -s 127.0.0.0/8 -d 127.0.0.0/8 -j ACCEPT
# --- WIRELESS
iptables -A OUTPUT -o wlan0 -p tcp -m multiport --dport 80,443 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -o wlan0 -p udp --dport 53 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# --- ALL WIRELESS (for Transmission)
#iptables -A OUTPUT -o wlan0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
#iptables -A INPUT -i wlan0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# --- INERNET
iptables -A OUTPUT -p tcp -s 192.168.0.102 -m multiport --dport 80,443 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p udp -s 192.168.0.102 --dport 53 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# --- MSN
iptables -A OUTPUT -p tcp --dport 1863 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# --- SSH + VNC WAN
#iptables -A INPUT -p tcp --dport 22 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --dport 22 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
#iptables -A INPUT -p tcp --dport 5900 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# --- LAN
iptables -A OUTPUT -s 192.168.0.102 -d 192.168.0.200 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -s 192.168.0.200 -d 192.168.0.102 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# --- RETOUR
iptables -A INPUT -d 192.168.0.102 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -s 192.168.0.102 -m state --state ESTABLISHED,RELATED -j ACCEPT
# --- RETOUR WIRELESS
iptables -A INPUT -i wlan0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -o wlan0 -m state --state ESTABLISHED,RELATED -j ACCEPT
# --- --- RULES END
;;
stop)
echo -n "iptables ferme : "
iptables -F
iptables -X
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -F
iptables -t nat -X;;
statut)
statut iptables;;
restart)
$0 stop
$0 start;;
*)
echo "usage : iptables {start|stop|status|restart}"
exit 1
esac
echo "OK"
exit 0 |
Partager