| Line 1... |
Line 1... |
| 1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
| 2 |
# $Id: alcasar-iptables.sh 1587 2015-03-08 22:34:21Z richard $
|
2 |
# $Id: alcasar-iptables.sh 1588 2015-03-08 23:00:08Z richard $
|
| 3 |
# Script de mise en place des regles du parefeu d'Alcasar (mode normal)
|
3 |
# Script de mise en place des regles du parefeu d'Alcasar (mode normal)
|
| 4 |
# This script writes the netfilter rules for ALCASAR
|
4 |
# This script writes the netfilter rules for ALCASAR
|
| 5 |
# Rexy - 3abtux - CPN
|
5 |
# Rexy - 3abtux - CPN
|
| 6 |
#
|
6 |
#
|
| 7 |
# Reminders
|
7 |
# Reminders
|
| Line 24... |
Line 24... |
| 24 |
public_ip_mask=`grep ^PUBLIC_IP= $CONF_FILE|cut -d"=" -f2` # ALCASAR WAN IP address
|
24 |
public_ip_mask=`grep ^PUBLIC_IP= $CONF_FILE|cut -d"=" -f2` # ALCASAR WAN IP address
|
| 25 |
if [[ "$public_ip_mask" == "dhcp" ]]
|
25 |
if [[ "$public_ip_mask" == "dhcp" ]]
|
| 26 |
then
|
26 |
then
|
| 27 |
PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/([012]?[0-9]|3[0-2])\b"
|
27 |
PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/([012]?[0-9]|3[0-2])\b"
|
| 28 |
public_ip_mask=`ip addr show $EXTIF | egrep -o $PTN`
|
28 |
public_ip_mask=`ip addr show $EXTIF | egrep -o $PTN`
|
| 29 |
dns1=`grep ^nameserver /etc/resolv.conf|cut -d" " -f2|head -n 1`
|
- |
|
| 30 |
nb_dns=`grep ^nameserver /etc/resolv.conf|wc -l`
|
- |
|
| 31 |
if [ $nb_dns == 2 ]
|
- |
|
| 32 |
then
|
- |
|
| 33 |
dns2=`grep ^nameserver /etc/resolv.conf|cut -d" " -f2|tail -n 1`
|
- |
|
| 34 |
fi
|
- |
|
| 35 |
else
|
- |
|
| 36 |
dns1=`grep ^DNS1= $CONF_FILE|cut -d"=" -f2`
|
- |
|
| 37 |
dns2=`grep ^DNS2= $CONF_FILE|cut -d"=" -f2`
|
- |
|
| 38 |
fi
|
29 |
fi
|
| 39 |
PUBLIC_IP=`echo $public_ip_mask | cut -d"/" -f1`
|
30 |
PUBLIC_IP=`echo $public_ip_mask | cut -d"/" -f1`
|
| - |
|
31 |
dns1=`grep ^DNS1= $CONF_FILE|cut -d"=" -f2`
|
| - |
|
32 |
dns2=`grep ^DNS2= $CONF_FILE|cut -d"=" -f2`
|
| 40 |
dns1=${dns1:=208.67.220.220}
|
33 |
dns1=${dns1:=208.67.220.220}
|
| 41 |
dns2=${dns2:=208.67.222.222}
|
34 |
dns2=${dns2:=208.67.222.222}
|
| 42 |
DNSSERVERS="$dns1,$dns2" # first and second public DNS servers
|
35 |
DNSSERVERS="$dns1,$dns2" # first and second public DNS servers
|
| 43 |
PROTOCOLS_FILTERING=`grep ^PROTOCOLS_FILTERING= $CONF_FILE|cut -d"=" -f2` # Network protocols filter (on/off)
|
36 |
PROTOCOLS_FILTERING=`grep ^PROTOCOLS_FILTERING= $CONF_FILE|cut -d"=" -f2` # Network protocols filter (on/off)
|
| 44 |
PROTOCOLS_FILTERING=${PROTOCOLS_FILTERING:=off}
|
37 |
PROTOCOLS_FILTERING=${PROTOCOLS_FILTERING:=off}
|