652 |
richard |
1 |
#!/bin/sh
|
826 |
franck |
2 |
# $Id: alcasar-iptables-local.sh 1829 2016-04-19 22:14:42Z richard $
|
652 |
richard |
3 |
# script de mise en place des regles personnalisées du parefeu d'Alcasar
|
|
|
4 |
# Rexy - 3abtux - CPN
|
1829 |
richard |
5 |
# version 2.2 (04/2016)
|
652 |
richard |
6 |
# changelog :
|
1829 |
richard |
7 |
# + example to allow ICMP from an Internet IP address (Admin_from) to EXTIF
|
|
|
8 |
# + exemple to allow SMTP from aLCASAR to an Internet server (SMTP_IP)
|
|
|
9 |
# + exemple of PAT rules from Internet
|
|
|
10 |
# + List of local MAC addresses filtered (MAC are in '/usr/local/etc/alcasar-iptables-local-mac-filtered'. Format : aa:09:23:2f:4d:ee)
|
|
|
11 |
# this script inherit of alcasar-iptables.sh variables : $INTIF, $EXTIF, $IPTABLES, etc
|
|
|
12 |
# Local MAC addresses filtering
|
|
|
13 |
if [ -s /usr/local/etc/alcasar-iptables-local-mac-filtered ]; then
|
1579 |
richard |
14 |
while read mac_line
|
|
|
15 |
do
|
|
|
16 |
ip_on=`echo $mac_line|cut -b1`
|
|
|
17 |
if [ $ip_on != "#" ]
|
|
|
18 |
then
|
|
|
19 |
mac_filtered=`echo $mac_line|cut -d" " -f1`
|
|
|
20 |
echo "MAC filtered = $mac_filtered"
|
|
|
21 |
$IPTABLES -A FORWARD -i $INTIF -m mac --mac-source $mac_filtered -j ULOG --ulog-prefix "$mac_filtered -- Filt_DROP"
|
|
|
22 |
$IPTABLES -A FORWARD -i $INTIF -p tcp -m mac --mac-source $mac_filtered -j DROP
|
|
|
23 |
$IPTABLES -A FORWARD -i $INTIF -p udp -m mac --mac-source $mac_filtered -j DROP
|
|
|
24 |
$IPTABLES -A FORWARD -i $INTIF -m mac --mac-source $mac_filtered -j DROP
|
|
|
25 |
fi
|
1829 |
richard |
26 |
done < /usr/local/etc/alcasar-iptables-local-mac-filtered
|
1522 |
franck |
27 |
fi
|
652 |
richard |
28 |
|
|
|
29 |
# On autorise le ping (echo & request) (icmp N°0 & 8) en provenance de l'extérieur vers ALCASAR
|
870 |
richard |
30 |
# ping (echo & request) (icmp N°0 & 8) is allowed on EXTIF
|
652 |
richard |
31 |
#$IPTABLES -A INPUT -i $EXTIF -s $Admin_from_IP -p icmp --icmp-type 8 -j ACCEPT
|
|
|
32 |
#$IPTABLES -A OUTPUT -o $EXTIF -d $Admin_from_IP -p icmp --icmp-type 0 -j ACCEPT
|
|
|
33 |
|
|
|
34 |
# On autorise l'accès à un serveur MAIL (SMTP) pour l'envoie de rapports, alertes (logwatch, etc.)
|
759 |
franck |
35 |
#SMTP_IP=0.0.0.0 # renseigner l'@IP du serveur SMTP
|
652 |
richard |
36 |
#$IPTABLES -A OUTPUT -p tcp -d $SMTP_IP --dport smtp -m state --state NEW,ESTABLISHED -j ACCEPT
|
|
|
37 |
#$IPTABLES -A INPUT -p tcp -s $SMTP_IP --sport smtp -m state --state ESTABLISHED -j ACCEPT
|
|
|
38 |
|
1522 |
franck |
39 |
# On autorise du PAT (Port Adresse Translation) afin de pouvoir joindre des équipements du LAN depuis Internet
|
|
|
40 |
#m_ports=5000,5001
|
|
|
41 |
#to_ip=192.168.182.3
|
1618 |
franck |
42 |
#$IPTABLES -A PREROUTING -i $EXTIF -t nat -p tcp -d $PUBLIC_IP -m multiport --dports $m_ports -j DNAT --to $to_ip
|
|
|
43 |
#$IPTABLES -A FORWARD -i $EXTIF -p tcp -d $to_ip -m multiport --dports $m_ports -j ACCEPT
|
1627 |
franck |
44 |
#$IPTABLES -A FORWARD -o $EXTIF -p tcp -s $to_ip -m multiport --sports $m_ports -j ACCEPT
|
652 |
richard |
45 |
|
|
|
46 |
# Fin du script des règles du parefeu
|
|
|
47 |
|