Line 1... |
Line 1... |
1 |
#!/bin/sh
|
1 |
#!/bin/sh
|
2 |
# $Id: alcasar-iptables-local.sh 1627 2015-05-13 20:10:14Z franck $
|
2 |
# $Id: alcasar-iptables-local.sh 1829 2016-04-19 22:14:42Z richard $
|
3 |
# script de mise en place des regles personnalisées du parefeu d'Alcasar
|
3 |
# script de mise en place des regles personnalisées du parefeu d'Alcasar
|
4 |
# Rexy - 3abtux - CPN
|
4 |
# Rexy - 3abtux - CPN
|
5 |
# version 2.1 (12/2014)
|
5 |
# version 2.2 (04/2016)
|
6 |
# changelog :
|
6 |
# changelog :
|
7 |
# + autorisation de l'ICMP vers EXTIF
|
7 |
# + example to allow ICMP from an Internet IP address (Admin_from) to EXTIF
|
8 |
# + autorisation SMTP vers serveur extérieur (SMTP_IP)
|
8 |
# + exemple to allow SMTP from aLCASAR to an Internet server (SMTP_IP)
|
9 |
# + autorisation PAT depuis l'extérieur
|
9 |
# + exemple of PAT rules from Internet
|
10 |
# List of MAC filtered in /usr/local/etc/alcasar-iptables-local-filtered ; format : aa:09:23:2f:4d:ee
|
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 |
|
- |
|
12 |
CONF_FILE="/usr/local/etc/alcasar.conf"
|
- |
|
13 |
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2` # EXTernal InterFace
|
- |
|
14 |
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
|
11 |
# this script inherit of alcasar-iptables.sh variables : $INTIF, $EXTIF, $IPTABLES, etc
|
15 |
|
- |
|
16 |
# filtrage particulier ciblés
|
12 |
# Local MAC addresses filtering
|
17 |
if [ -s /usr/local/etc/alcasar-iptables-local-filtered ]; then
|
13 |
if [ -s /usr/local/etc/alcasar-iptables-local-mac-filtered ]; then
|
18 |
while read mac_line
|
14 |
while read mac_line
|
19 |
do
|
15 |
do
|
20 |
ip_on=`echo $mac_line|cut -b1`
|
16 |
ip_on=`echo $mac_line|cut -b1`
|
21 |
if [ $ip_on != "#" ]
|
17 |
if [ $ip_on != "#" ]
|
22 |
then
|
18 |
then
|
Line 25... |
Line 21... |
25 |
$IPTABLES -A FORWARD -i $INTIF -m mac --mac-source $mac_filtered -j ULOG --ulog-prefix "$mac_filtered -- Filt_DROP"
|
21 |
$IPTABLES -A FORWARD -i $INTIF -m mac --mac-source $mac_filtered -j ULOG --ulog-prefix "$mac_filtered -- Filt_DROP"
|
26 |
$IPTABLES -A FORWARD -i $INTIF -p tcp -m mac --mac-source $mac_filtered -j DROP
|
22 |
$IPTABLES -A FORWARD -i $INTIF -p tcp -m mac --mac-source $mac_filtered -j DROP
|
27 |
$IPTABLES -A FORWARD -i $INTIF -p udp -m mac --mac-source $mac_filtered -j DROP
|
23 |
$IPTABLES -A FORWARD -i $INTIF -p udp -m mac --mac-source $mac_filtered -j DROP
|
28 |
$IPTABLES -A FORWARD -i $INTIF -m mac --mac-source $mac_filtered -j DROP
|
24 |
$IPTABLES -A FORWARD -i $INTIF -m mac --mac-source $mac_filtered -j DROP
|
29 |
fi
|
25 |
fi
|
30 |
done < /usr/local/etc/alcasar-iptables-local-filtered
|
26 |
done < /usr/local/etc/alcasar-iptables-local-mac-filtered
|
31 |
fi
|
27 |
fi
|
32 |
|
28 |
|
33 |
# On autorise le ping (echo & request) (icmp N°0 & 8) en provenance de l'extérieur vers ALCASAR
|
29 |
# On autorise le ping (echo & request) (icmp N°0 & 8) en provenance de l'extérieur vers ALCASAR
|
34 |
# ping (echo & request) (icmp N°0 & 8) is allowed on EXTIF
|
30 |
# ping (echo & request) (icmp N°0 & 8) is allowed on EXTIF
|
35 |
#$IPTABLES -A INPUT -i $EXTIF -s $Admin_from_IP -p icmp --icmp-type 8 -j ACCEPT
|
31 |
#$IPTABLES -A INPUT -i $EXTIF -s $Admin_from_IP -p icmp --icmp-type 8 -j ACCEPT
|