Subversion Repositories ALCASAR

Rev

Rev 848 | Rev 871 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log

Rev 848 Rev 859
1
#!/bin/sh
1
#!/bin/sh
2
# $Id: alcasar-iptables.sh 848 2012-04-03 17:43:10Z franck $
2
# $Id: alcasar-iptables.sh 859 2012-04-19 22:21:31Z 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 write the netfilter rules for ALCASAR
4
# This script write the netfilter rules for ALCASAR
5
# Rexy - 3abtux - CPN
5
# Rexy - 3abtux - CPN
6
#
6
#
7
# Reminders
7
# Reminders
8
# There are three channels for log :
8
# There are three channels for log :
9
#	1 (default) for tracability;
9
#	1 (default) for tracability;
10
#	2 for secure admin (ssh);
10
#	2 for secure admin (ssh);
11
#	3 for exterior access attempts.
11
#	3 for exterior access attempts.
12
# The French Security Agency (ANSSI) rules was applied by 'this script
12
# The French Security Agency (ANSSI) rules was applied by 'this script
13
# The bootps/dhcp (67) port is always open on tun0/eth1 by coova 
13
# The bootps/dhcp (67) port is always open on tun0/eth1 by coova 
14
conf_file="/usr/local/etc/alcasar.conf"
14
conf_file="/usr/local/etc/alcasar.conf"
15
private_ip_mask=`grep PRIVATE_IP= $conf_file|cut -d"=" -f2`
15
private_ip_mask=`grep PRIVATE_IP= $conf_file|cut -d"=" -f2`
16
private_ip_mask=${private_ip_mask:=192.168.182.1/24}
16
private_ip_mask=${private_ip_mask:=192.168.182.1/24}
17
PRIVATE_IP=`echo $private_ip_mask | cut -d"/" -f1`			# ALCASAR LAN IP address
17
PRIVATE_IP=`echo $private_ip_mask | cut -d"/" -f1`			# ALCASAR LAN IP address
18
private_network=`/bin/ipcalc -n $private_ip_mask|cut -d"=" -f2`		# LAN IP address (ie.: 192.168.182.0)
18
private_network=`/bin/ipcalc -n $private_ip_mask|cut -d"=" -f2`		# LAN IP address (ie.: 192.168.182.0)
19
private_prefix=`/bin/ipcalc -p $private_ip_mask|cut -d"=" -f2`		# LAN prefix (ie. 24)
19
private_prefix=`/bin/ipcalc -p $private_ip_mask|cut -d"=" -f2`		# LAN prefix (ie. 24)
20
PRIVATE_NETWORK_MASK=$private_network/$private_prefix			# Lan IP address + prefix (192.168.182.0/24)
20
PRIVATE_NETWORK_MASK=$private_network/$private_prefix			# Lan IP address + prefix (192.168.182.0/24)
21
public_ip_mask=`grep PUBLIC_IP= $conf_file|cut -d"=" -f2`		# ALCASAR WAN IP address
21
public_ip_mask=`grep PUBLIC_IP= $conf_file|cut -d"=" -f2`		# ALCASAR WAN IP address
22
PUBLIC_IP=`echo $public_ip_mask | cut -d"/" -f1`
22
PUBLIC_IP=`echo $public_ip_mask | cut -d"/" -f1`
23
dns1=`grep DNS1= $conf_file|cut -d"=" -f2`				# first public DNS server
23
dns1=`grep DNS1= $conf_file|cut -d"=" -f2`				# first public DNS server
24
dns1=${dns1:=208.67.220.220}
24
dns1=${dns1:=208.67.220.220}
25
dns2=`grep DNS2= $conf_file|cut -d"=" -f2`				# second public DNS server
25
dns2=`grep DNS2= $conf_file|cut -d"=" -f2`				# second public DNS server
26
dns2=${dns2:=208.67.222.222}
26
dns2=${dns2:=208.67.222.222}
27
DNSSERVERS="$dns1,$dns2"						# first and second DNS IP servers addresses
27
DNSSERVERS="$dns1,$dns2"						# first and second DNS IP servers addresses
28
PROTOCOLS_FILTERING=`grep PROTOCOLS_FILTERING= $conf_file|cut -d"=" -f2`	# Network protocols filter (on/off)
28
PROTOCOLS_FILTERING=`grep PROTOCOLS_FILTERING= $conf_file|cut -d"=" -f2`	# Network protocols filter (on/off)
29
PROTOCOLS_FILTERING=${PROTOCOLS_FILTERING:=off}
29
PROTOCOLS_FILTERING=${PROTOCOLS_FILTERING:=off}
30
EXT_LAN_FILTERING=`grep EXT_LAN_FILTERING= $conf_file|cut -d"=" -f2`	# filter acces to the lan on alcasar/eth0 (on/off)
-
 
31
EXT_LAN_FILTERING=${EXT_LAN_FILTERING:=off}
-
 
32
DNS_FILTERING=`grep DNS_FILTERING= $conf_file|cut -d"=" -f2`		# DNS and URLs filter (on/off)
30
DNS_FILTERING=`grep DNS_FILTERING= $conf_file|cut -d"=" -f2`		# DNS and URLs filter (on/off)
33
DNS_FILTERING=${DNS_FILTERING:=off}
31
DNS_FILTERING=${DNS_FILTERING:=off}
34
QOS=`grep QOS= $conf_file|cut -d"=" -f2`				# QOS (on/off)
32
QOS=`grep QOS= $conf_file|cut -d"=" -f2`				# QOS (on/off)
35
QOS=${QOS:=off}
33
QOS=${QOS:=off}
36
SSH=`grep SSH= $conf_file|cut -d"=" -f2`				# sshd active (on/off)
34
SSH=`grep SSH= $conf_file|cut -d"=" -f2`				# sshd active (on/off)
37
SSH=${SSH:=off}
35
SSH=${SSH:=off}
38
Admin_from_IP=${Admin_from_IP:="0.0.0.0/0.0.0.0"}			# WAN IP address to reduce ssh access (all ip allowed on LAN side)
36
Admin_from_IP=${Admin_from_IP:="0.0.0.0/0.0.0.0"}			# WAN IP address to reduce ssh access (all ip allowed on LAN side)
39
LDAP=`grep LDAP= $conf_file|cut -d"=" -f2`				# LDAP external server active (on/off)
37
LDAP=`grep LDAP= $conf_file|cut -d"=" -f2`				# LDAP external server active (on/off)
40
LDAP=${LDAP:=off}
38
LDAP=${LDAP:=off}
41
LDAP_IP=`grep LDAP_IP= $conf_file|cut -d"=" -f2`			# WAN IP address to reduce LDAP WAN access (all ip allowed on LAN side)
39
LDAP_IP=`grep LDAP_IP= $conf_file|cut -d"=" -f2`			# WAN IP address to reduce LDAP WAN access (all ip allowed on LAN side)
42
LDAP_IP=${LDAP_IP:="0.0.0.0/0.0.0.0"}
40
LDAP_IP=${LDAP_IP:="0.0.0.0/0.0.0.0"}
43
EXTIF="eth0"
41
EXTIF="eth0"
44
INTIF="eth1"
42
INTIF="eth1"
45
TUNIF="tun0"								# listen device for chilli daemon
43
TUNIF="tun0"								# listen device for chilli daemon
46
IPTABLES="/sbin/iptables"
44
IPTABLES="/sbin/iptables"
47
 
45
 
48
# Effacement des règles existantes
46
# Effacement des règles existantes
49
# Flush all existing rules
47
# Flush all existing rules
50
$IPTABLES -F
48
$IPTABLES -F
51
$IPTABLES -t nat -F
49
$IPTABLES -t nat -F
52
$IPTABLES -t mangle -F
50
$IPTABLES -t mangle -F
53
$IPTABLES -F INPUT
51
$IPTABLES -F INPUT
54
$IPTABLES -F FORWARD
52
$IPTABLES -F FORWARD
55
$IPTABLES -F OUTPUT
53
$IPTABLES -F OUTPUT
56
 
54
 
57
# Suppression des chaines utilisateurs sur les tables filter et nat
55
# Suppression des chaines utilisateurs sur les tables filter et nat
58
# Flush non default rules on filter and nat tables
56
# Flush non default rules on filter and nat tables
59
$IPTABLES -X
57
$IPTABLES -X
60
$IPTABLES -t nat -X
58
$IPTABLES -t nat -X
61
 
59
 
62
# Stratégies par défaut
60
# Stratégies par défaut
63
# Default policies
61
# Default policies
64
$IPTABLES -P INPUT DROP
62
$IPTABLES -P INPUT DROP
65
$IPTABLES -P FORWARD DROP
63
$IPTABLES -P FORWARD DROP
66
$IPTABLES -P OUTPUT DROP
64
$IPTABLES -P OUTPUT DROP
67
$IPTABLES -t nat -P PREROUTING ACCEPT
65
$IPTABLES -t nat -P PREROUTING ACCEPT
68
$IPTABLES -t nat -P POSTROUTING ACCEPT
66
$IPTABLES -t nat -P POSTROUTING ACCEPT
69
$IPTABLES -t nat -P OUTPUT ACCEPT
67
$IPTABLES -t nat -P OUTPUT ACCEPT
70
 
68
 
71
#############################
69
#############################
72
#       PREROUTING          #
70
#       PREROUTING          #
73
#############################
71
#############################
74
# Marquage (et journalisation) des paquets qui tentent d'accéder directement à DansGuardian pour pouvoir les rejeter en INPUT
72
# Marquage (et journalisation) des paquets qui tentent d'accéder directement à DansGuardian pour pouvoir les rejeter en INPUT
75
# mark (and log) the dansguardian bypass attempts in order to DROP them in INPUT rules
73
# mark (and log) the dansguardian bypass attempts in order to DROP them in INPUT rules
76
# $IPTABLES -A PREROUTING -t nat -i $TUNIF -p tcp -d $PRIVATE_IP -m tcp --dport 8080 -j ULOG --ulog-prefix "RULE direct-proxy -- DENY "
74
# $IPTABLES -A PREROUTING -t nat -i $TUNIF -p tcp -d $PRIVATE_IP -m tcp --dport 8080 -j ULOG --ulog-prefix "RULE direct-proxy -- DENY "
77
$IPTABLES -A PREROUTING -t mangle -i $TUNIF -d $PRIVATE_IP -p tcp -m tcp --dport 8080 -j MARK --set-mark 1
75
$IPTABLES -A PREROUTING -t mangle -i $TUNIF -d $PRIVATE_IP -p tcp -m tcp --dport 8080 -j MARK --set-mark 1
78
 
76
 
79
# Marquage (et journalisation) des paquets qui tentent d'accéder directement au port udp 54 pour pouvoir les rejeter en INPUT
77
# Marquage (et journalisation) des paquets qui tentent d'accéder directement au port udp 54 pour pouvoir les rejeter en INPUT
80
# Mark (and log) the udp 54 direct attempts to REJECT them in INPUT rules
78
# Mark (and log) the udp 54 direct attempts to REJECT them in INPUT rules
81
# Remarque : Ce port n'est ouvert que lorsque le filtrage est activé
79
# Remarque : Ce port n'est ouvert que lorsque le filtrage est activé
82
# Remark : this port is only open when filtering is on
80
# Remark : this port is only open when filtering is on
83
# $IPTABLES -A PREROUTING -t nat -i $TUNIF -p udp -d $PRIVATE_IP -m udp --dport 54 -j ULOG --ulog-prefix "RULE DNS-proxy -- DENY "
81
# $IPTABLES -A PREROUTING -t nat -i $TUNIF -p udp -d $PRIVATE_IP -m udp --dport 54 -j ULOG --ulog-prefix "RULE DNS-proxy -- DENY "
84
$IPTABLES -A PREROUTING -t mangle -i $TUNIF -d $PRIVATE_IP -p tcp --dport 54 -j MARK --set-mark 2
82
$IPTABLES -A PREROUTING -t mangle -i $TUNIF -d $PRIVATE_IP -p tcp --dport 54 -j MARK --set-mark 2
85
 
83
 
86
# Si le filtrage est activé, redirection des flux DNS vers le port 54 (dns+blackhole) sauf pour les IP en exceptions 
84
# Si le filtrage est activé, redirection des flux DNS vers le port 54 (dns+blackhole) sauf pour les IP en exceptions 
87
# If DNS filter is on, redirect DNS request to udp 54 (dns+blackhole) except for exception IP addresses
85
# If DNS filter is on, redirect DNS request to udp 54 (dns+blackhole) except for exception IP addresses
88
if [ $DNS_FILTERING = on ]; then
86
if [ $DNS_FILTERING = on ]; then
89
	# Compute exception IP
87
	# Compute exception IP
90
	nb_exceptions=`wc -l /usr/local/etc/alcasar-filter-exceptions | cut -d" " -f1`
88
	nb_exceptions=`wc -l /usr/local/etc/alcasar-filter-exceptions | cut -d" " -f1`
91
	if [ $nb_exceptions != "0" ]
89
	if [ $nb_exceptions != "0" ]
92
	then
90
	then
93
		while read ip_exception 
91
		while read ip_exception 
94
		do
92
		do
95
			$IPTABLES -A PREROUTING -t nat -i $TUNIF -p udp -s $ip_exception -d $PRIVATE_IP --dport domain -j ACCEPT
93
			$IPTABLES -A PREROUTING -t nat -i $TUNIF -p udp -s $ip_exception -d $PRIVATE_IP --dport domain -j ACCEPT
96
		done < /usr/local/etc/alcasar-filter-exceptions
94
		done < /usr/local/etc/alcasar-filter-exceptions
97
	fi
95
	fi
98
		$IPTABLES -A PREROUTING -t nat -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p udp --dport domain -j REDIRECT --to-port 54
96
		$IPTABLES -A PREROUTING -t nat -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p udp --dport domain -j REDIRECT --to-port 54
99
fi
97
fi
100
 
98
 
101
# Journalisation des requètes HTTP vers Internet (seulement les paquets SYN) - Les autres protocoles sont journalisés en FORWARD
99
# Journalisation des requètes HTTP vers Internet (seulement les paquets SYN) - Les autres protocoles sont journalisés en FORWARD
102
# Log HTTP requests to Internet (only syn packets) - Other protocols are log in FORWARD
100
# Log HTTP requests to Internet (only syn packets) - Other protocols are log in FORWARD
103
$IPTABLES -A PREROUTING -t nat -i $TUNIF -s $PRIVATE_NETWORK_MASK ! -d $PRIVATE_IP -p tcp --dport http -m state --state NEW -j ULOG --ulog-prefix "RULE F_http -- ACCEPT "
101
$IPTABLES -A PREROUTING -t nat -i $TUNIF -s $PRIVATE_NETWORK_MASK ! -d $PRIVATE_IP -p tcp --dport http -m state --state NEW -j ULOG --ulog-prefix "RULE F_http -- ACCEPT "
104
# Redirection des requêtes HTTP vers DansGuardian (proxy transparent)
102
# Redirection des requêtes HTTP vers DansGuardian (proxy transparent)
105
# Redirect HTTP requests in DansGuardian (transparent proxy)
103
# Redirect HTTP requests in DansGuardian (transparent proxy)
106
$IPTABLES -A PREROUTING -t nat -i $TUNIF -s $PRIVATE_NETWORK_MASK ! -d $PRIVATE_IP -p tcp --dport http -j REDIRECT --to-port 8080
104
$IPTABLES -A PREROUTING -t nat -i $TUNIF -s $PRIVATE_NETWORK_MASK ! -d $PRIVATE_IP -p tcp --dport http -j REDIRECT --to-port 8080
107
 
105
 
108
# Redirection des requêtes NTP vers le serveur NTP local
106
# Redirection des requêtes NTP vers le serveur NTP local
109
# Redirect NTP request in local NTP server
107
# Redirect NTP request in local NTP server
110
$IPTABLES -A PREROUTING -t nat -i $TUNIF -s $PRIVATE_NETWORK_MASK ! -d $PRIVATE_IP -p udp --dport ntp -j REDIRECT --to-port 123
108
$IPTABLES -A PREROUTING -t nat -i $TUNIF -s $PRIVATE_NETWORK_MASK ! -d $PRIVATE_IP -p udp --dport ntp -j REDIRECT --to-port 123
111
 
109
 
112
#############################
110
#############################
113
#         INPUT             #
111
#         INPUT             #
114
#############################
112
#############################
115
# Tout passe sur loopback
113
# Tout passe sur loopback
116
# accept all on loopback
114
# accept all on loopback
117
$IPTABLES -A INPUT -i lo -j ACCEPT
115
$IPTABLES -A INPUT -i lo -j ACCEPT
118
 
116
 
119
# Insertion de règles de blocage (Devel)
-
 
120
# Here, we add block rules (Devel)
-
 
121
if [ -s /usr/local/etc/alcasar-iptables-block ]; then 
-
 
122
    while read ip_blocked
-
 
123
    do
-
 
124
      echo "Network Address blocked : $ip_blocked"
-
 
125
      $IPTABLES -A FORWARD -d $ip_blocked -j ULOG --ulog-prefix "RULE IP-blocked -- REJECT "
-
 
126
      $IPTABLES -A FORWARD -d $ip_blocked -j REJECT
-
 
127
      $IPTABLES -A FORWARD -s $ip_blocked -j ULOG --ulog-prefix "RULE IP-blocked -- REJECT "
-
 
128
      $IPTABLES -A FORWARD -s $ip_blocked -j REJECT
-
 
129
    done < /usr/local/etc/alcasar-iptables-block
-
 
130
fi
-
 
131
 
117
 
132
# Rejet des demandes de connexions non conformes (FIN-URG-PUSH, XMAS, NullScan, SYN-RST et NEW not SYN)
118
# Rejet des demandes de connexions non conformes (FIN-URG-PUSH, XMAS, NullScan, SYN-RST et NEW not SYN)
133
# Drop non standard connexions (FIN-URG-PUSH, XMAS, NullScan, SYN-RST et NEW not SYN)
119
# Drop non standard connexions (FIN-URG-PUSH, XMAS, NullScan, SYN-RST et NEW not SYN)
134
$IPTABLES -A INPUT -p tcp --tcp-flags FIN,URG,PSH FIN,URG,PSH -j DROP
120
$IPTABLES -A INPUT -p tcp --tcp-flags FIN,URG,PSH FIN,URG,PSH -j DROP
135
$IPTABLES -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
121
$IPTABLES -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
136
$IPTABLES -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
122
$IPTABLES -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
137
$IPTABLES -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
123
$IPTABLES -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
138
$IPTABLES -A INPUT -p tcp -m tcp ! --syn -m state --state NEW -j DROP
124
$IPTABLES -A INPUT -p tcp -m tcp ! --syn -m state --state NEW -j DROP
139
 
125
 
140
# On rejette les trame en broadcast et en multicast sur EXTIF (pour ne pas les journaliser)
126
# On rejette les trame en broadcast et en multicast sur EXTIF (pour ne pas les journaliser)
141
# Drop broadcast & multicast on EXTIF to not be logged 
127
# Drop broadcast & multicast on EXTIF to not be logged 
142
$IPTABLES -A INPUT -i $EXTIF -m addrtype --dst-type BROADCAST,MULTICAST -j DROP
128
$IPTABLES -A INPUT -i $EXTIF -m addrtype --dst-type BROADCAST,MULTICAST -j DROP
143
 
129
 
144
# On autorise les retours de connexions légitimes par INPUT
130
# On autorise les retours de connexions légitimes par INPUT
145
# Conntrack on INPUT
131
# Conntrack on INPUT
146
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
132
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
147
 
133
 
148
# On interdit les connexions directes au port utilisé par DansGuardian (8080). Les packets concernés ont été marqués dans la table mangle (PREROUTING)
134
# On interdit les connexions directes au port utilisé par DansGuardian (8080). Les packets concernés ont été marqués dans la table mangle (PREROUTING)
149
# Deny direct connections on DansGuardian port (8080). The concerned paquets are marked in mangle table (PREROUTING)
135
# Deny direct connections on DansGuardian port (8080). The concerned paquets are marked in mangle table (PREROUTING)
150
$IPTABLES -A INPUT -i $TUNIF -p tcp --dport 8080 -m mark --mark 1 -j REJECT --reject-with tcp-reset
136
$IPTABLES -A INPUT -i $TUNIF -p tcp --dport 8080 -m mark --mark 1 -j REJECT --reject-with tcp-reset
151
 
137
 
152
# Filtrage de l'accès au LAN connecté sur EXTIF (eth0)
138
# Insertion des règles de blocage IP
153
# EXTIF (eth0) connected LAN filtering
139
# Here, we add IP block rules 
154
if [ $EXT_LAN_FILTERING = on ]; then
140
if [ -s /usr/local/etc/alcasar-ip-blocked ]; then 
-
 
141
	while read ip_line
-
 
142
	do
-
 
143
		ip_on=`echo $ip_line|cut -b1`
-
 
144
		if [ $ip_on != "#" ]
-
 
145
		then	
-
 
146
			ip_blocked=`echo $ip_line|cut -d" " -f1`
-
 
147
			$IPTABLES -A INPUT -i $TUNIF -d $ip_blocked -p tcp --dport 8080 -m state --state NEW --syn -j ULOG --ulog-prefix "RULE IP-blocked -- REJECT "
155
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK ! -d $public_ip_mask -p tcp --dport 8080 -m state --state NEW --syn -j ACCEPT
148
			$IPTABLES -A INPUT -i $TUNIF -d $ip_blocked -p tcp --dport 8080 -m state --state NEW --syn -j REJECT 
156
else
149
		fi
-
 
150
	done < /usr/local/etc/alcasar-ip-blocked
-
 
151
fi
157
# Autorisation des connexions légitimes à DansGuardian 
152
# Autorisation des connexions légitimes à DansGuardian 
158
# Allow connections for DansGuardian
153
# Allow connections for DansGuardian
159
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -p tcp --dport 8080 -m state --state NEW --syn -j ACCEPT
154
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -p tcp --dport 8080 -m state --state NEW --syn -j ACCEPT
160
fi
-
 
161
 
155
 
162
# On interdit les connexions directes au port UDP 54. Les packets concernés ont été marqués dans la table mangle (PREROUTING)
156
# On interdit les connexions directes au port UDP 54. Les packets concernés ont été marqués dans la table mangle (PREROUTING)
163
# Deny direct connections on UDP 54. The concerned paquets are marked in mangle table (PREROUTING)
157
# Deny direct connections on UDP 54. The concerned paquets are marked in mangle table (PREROUTING)
164
$IPTABLES -A INPUT -i $TUNIF -p udp --dport 54 -m mark --mark 2 -j REJECT --reject-with icmp-port-unreachable
158
$IPTABLES -A INPUT -i $TUNIF -p udp --dport 54 -m mark --mark 2 -j REJECT --reject-with icmp-port-unreachable
165
 
159
 
166
# autorisation des connexion légitime à DNSMASQ (avec blackhole)
160
# autorisation des connexion légitime à DNSMASQ (avec blackhole)
167
# Allow connections for DNSMASQ (with blackhole)
161
# Allow connections for DNSMASQ (with blackhole)
168
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p udp --dport 54 -j ACCEPT
162
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p udp --dport 54 -j ACCEPT
169
 
163
 
170
# Accès direct aux services internes
164
# Accès direct aux services internes
171
# Internal services access
165
# Internal services access
172
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p udp --dport domain -j ACCEPT	# DNS non filtré # DNS without blackhole
166
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p udp --dport domain -j ACCEPT	# DNS non filtré # DNS without blackhole
173
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p icmp --icmp-type 8 -j ACCEPT	# Réponse ping # ping responce
167
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p icmp --icmp-type 8 -j ACCEPT	# Réponse ping # ping responce
174
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p icmp --icmp-type 0 -j ACCEPT	# Requête  ping # ping request
168
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p icmp --icmp-type 0 -j ACCEPT	# Requête  ping # ping request
175
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport https -j ACCEPT	# Pages d'authentification et MCC # authentication pages and MCC
169
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport https -j ACCEPT	# Pages d'authentification et MCC # authentication pages and MCC
176
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport http -j ACCEPT	# Page d'avertissement filtrage # Filtering warning pages
170
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport http -j ACCEPT	# Page d'avertissement filtrage # Filtering warning pages
177
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport 3990 -j ACCEPT	# Requêtes de deconnexion usagers # Users logout requests
171
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport 3990 -j ACCEPT	# Requêtes de deconnexion usagers # Users logout requests
178
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p udp --dport ntp -j ACCEPT	# Serveur local de temps # local time server
172
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p udp --dport ntp -j ACCEPT	# Serveur local de temps # local time server
179
 
173
 
180
# SSHD rules if activate 
174
# SSHD rules if activate 
181
if [ $SSH = on ]
175
if [ $SSH = on ]
182
	then
176
	then
183
	$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport ssh -m state --state NEW -j ULOG --ulog-nlgroup 2 --ulog-prefix "RULE ssh-from-LAN -- ACCEPT"
177
	$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport ssh -m state --state NEW -j ULOG --ulog-nlgroup 2 --ulog-prefix "RULE ssh-from-LAN -- ACCEPT"
184
	$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport ssh -j ACCEPT
178
	$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport ssh -j ACCEPT
185
	$IPTABLES -A INPUT -i $EXTIF -s $Admin_from_IP -d $PUBLIC_IP -p tcp --dport ssh -m state --state NEW --syn -j ULOG --ulog-nlgroup 2 --ulog-prefix "RULE ssh-from-WAN -- ACCEPT"
179
	$IPTABLES -A INPUT -i $EXTIF -s $Admin_from_IP -d $PUBLIC_IP -p tcp --dport ssh -m state --state NEW --syn -j ULOG --ulog-nlgroup 2 --ulog-prefix "RULE ssh-from-WAN -- ACCEPT"
186
	$IPTABLES -A INPUT -i $EXTIF -s $Admin_from_IP -d $PUBLIC_IP -p tcp --dport ssh -m state --state NEW,ESTABLISHED -j ACCEPT
180
	$IPTABLES -A INPUT -i $EXTIF -s $Admin_from_IP -d $PUBLIC_IP -p tcp --dport ssh -m state --state NEW,ESTABLISHED -j ACCEPT
187
fi
181
fi
188
 
182
 
189
# Insertion de règles locales
183
# Insertion de règles locales
190
# Here, we add local rules (i.e. VPN from Internet)
184
# Here, we add local rules (i.e. VPN from Internet)
191
if [ -f /usr/local/etc/alcasar-iptables-local.sh ]; then
185
if [ -f /usr/local/etc/alcasar-iptables-local.sh ]; then
192
        . /usr/local/etc/alcasar-iptables-local.sh
186
        . /usr/local/etc/alcasar-iptables-local.sh
193
fi
187
fi
194
 
188
 
195
# Journalisation et rejet des connexions (autres que celles autorisées) effectuées depuis le LAN
189
# Journalisation et rejet des connexions (autres que celles autorisées) effectuées depuis le LAN
196
# Deny and log on INPUT from the LAN
190
# Deny and log on INPUT from the LAN
197
$IPTABLES -A INPUT -i $TUNIF -m state --state NEW -j ULOG --ulog-prefix "RULE rej-int -- REJECT "
191
$IPTABLES -A INPUT -i $TUNIF -m state --state NEW -j ULOG --ulog-prefix "RULE rej-int -- REJECT "
198
$IPTABLES -A INPUT -i $TUNIF -p tcp -j REJECT --reject-with tcp-reset
192
$IPTABLES -A INPUT -i $TUNIF -p tcp -j REJECT --reject-with tcp-reset
199
$IPTABLES -A INPUT -i $TUNIF -p udp -j REJECT --reject-with icmp-port-unreachable
193
$IPTABLES -A INPUT -i $TUNIF -p udp -j REJECT --reject-with icmp-port-unreachable
200
 
194
 
201
# interdiction d'accès à INTIF (n'est utile que lorsque chilli est arrêté).
195
# interdiction d'accès à INTIF (n'est utile que lorsque chilli est arrêté).
202
# Reject INTIF access (only when chilli is down)
196
# Reject INTIF access (only when chilli is down)
203
$IPTABLES -A INPUT -i $INTIF -j ULOG --ulog-prefix "RULE Protect1 -- REJECT "
197
$IPTABLES -A INPUT -i $INTIF -j ULOG --ulog-prefix "RULE Protect1 -- REJECT "
204
$IPTABLES -A INPUT -i $INTIF -j REJECT
198
$IPTABLES -A INPUT -i $INTIF -j REJECT
205
 
199
 
206
# Journalisation et rejet des connexions initiées depuis le réseau extérieur (test des effets du paramètre --limit en cours)
200
# Journalisation et rejet des connexions initiées depuis le réseau extérieur (test des effets du paramètre --limit en cours)
207
# On EXTIF, the access attempts are log in channel 2 (we should test --limit option to avoid deny of service)
201
# On EXTIF, the access attempts are log in channel 2 (we should test --limit option to avoid deny of service)
208
$IPTABLES -A INPUT -i $EXTIF -m state --state NEW -j ULOG --ulog-nlgroup 3 --ulog-qthreshold 10 --ulog-prefix "RULE rej-ext -- DROP"
202
$IPTABLES -A INPUT -i $EXTIF -m state --state NEW -j ULOG --ulog-nlgroup 3 --ulog-qthreshold 10 --ulog-prefix "RULE rej-ext -- DROP"
209
 
203
 
210
#############################
204
#############################
211
#        FORWARD            #
205
#        FORWARD            #
212
#############################
206
#############################
213
 
207
 
214
# Rejet des requêtes DNS vers Internet
208
# Rejet des requêtes DNS vers Internet
215
# Deny forward DNS
209
# Deny forward DNS
216
$IPTABLES -A FORWARD -i $TUNIF -p udp --dport domain -j REJECT --reject-with icmp-port-unreachable
210
$IPTABLES -A FORWARD -i $TUNIF -p udp --dport domain -j REJECT --reject-with icmp-port-unreachable
217
$IPTABLES -A FORWARD -i $TUNIF -p tcp --dport domain -j REJECT --reject-with tcp-reset
211
$IPTABLES -A FORWARD -i $TUNIF -p tcp --dport domain -j REJECT --reject-with tcp-reset
218
 
212
 
219
# Filtrage de l'accès au LAN connecté sur EXTIF (eth0)
213
# Insertion des règles de blocage IP
220
# EXTIF (eth0) connected LAN filtering
214
# Here, we add IP block rules 
221
if [ $EXT_LAN_FILTERING = on ]; then
215
if [ -s /usr/local/etc/alcasar-ip-blocked ]; then 
-
 
216
	while read ip_line
-
 
217
	do
-
 
218
		ip_on=`echo $ip_line|cut -b1`
-
 
219
		if [ $ip_on != "#" ]
-
 
220
		then	
-
 
221
			ip_blocked=`echo $ip_line|cut -d" " -f1`
-
 
222
			$IPTABLES -A FORWARD -i $TUNIF -d $ip_blocked -j ULOG --ulog-prefix "RULE IP-blocked -- REJECT "
222
$IPTABLES -A FORWARD -i $TUNIF -p udp -d $public_ip_mask -j REJECT --reject-with icmp-port-unreachable
223
			$IPTABLES -A FORWARD -i $TUNIF -d $ip_blocked -p udp -j REJECT --reject-with icmp-port-unreachable
223
$IPTABLES -A FORWARD -i $TUNIF -p icmp -d $public_ip_mask -j REJECT --reject-with icmp-port-unreachable
224
			$IPTABLES -A FORWARD -i $TUNIF -d $ip_blocked -p icmp -j REJECT --reject-with icmp-port-unreachable
224
$IPTABLES -A FORWARD -i $TUNIF -p tcp -d $public_ip_mask -j REJECT --reject-with tcp-reset
225
			$IPTABLES -A FORWARD -i $TUNIF -d $ip_blocked -p tcp -j REJECT --reject-with tcp-reset
-
 
226
		fi
-
 
227
	done < /usr/local/etc/alcasar-ip-blocked
225
fi
228
fi
-
 
229
 
226
# Autorisation des retours de connexions légitimes
230
# Autorisation des retours de connexions légitimes
227
# Allow conntrack
231
# Allow conntrack
228
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
232
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
229
 
233
 
230
#  If protocols filter is activate 
234
#  If protocols filter is activate 
231
if [ $PROTOCOLS_FILTERING = on ]; then
235
if [ $PROTOCOLS_FILTERING = on ]; then
232
	# Compute exception IP (IP addresses that shouldn't be filtered)
236
	# Compute exception IP (IP addresses that shouldn't be filtered)
233
	nb_exceptions=`wc -l /usr/local/etc/alcasar-filter-exceptions | cut -d" " -f1`
237
	nb_exceptions=`wc -l /usr/local/etc/alcasar-filter-exceptions | cut -d" " -f1`
234
	if [ $nb_exceptions != "0" ]
238
	if [ $nb_exceptions != "0" ]
235
	then
239
	then
236
		while read ip_exception 
240
		while read ip_exception 
237
		do
241
		do
238
			$IPTABLES -A FORWARD -i $TUNIF -s $ip_exception -m state --state NEW -j ULOG --ulog-prefix "RULE IP-exception -- ACCEPT "
242
			$IPTABLES -A FORWARD -i $TUNIF -s $ip_exception -m state --state NEW -j ULOG --ulog-prefix "RULE IP-exception -- ACCEPT "
239
			$IPTABLES -A FORWARD -i $TUNIF -s $ip_exception -m state --state NEW -j ACCEPT
243
			$IPTABLES -A FORWARD -i $TUNIF -s $ip_exception -m state --state NEW -j ACCEPT
240
		done < /usr/local/etc/alcasar-filter-exceptions
244
		done < /usr/local/etc/alcasar-filter-exceptions
241
	fi
245
	fi
242
	# Compute uamallowed IP (IP address of equipments connect between ALCASAR and Internet (DMZ, own servers, ...) 
246
	# Compute uamallowed IP (IP address of equipments connect between ALCASAR and Internet (DMZ, own servers, ...) 
243
	nb_exceptions=`wc -l /usr/local/etc/alcasar-uamallowed | cut -d" "  -f1`
247
	nb_exceptions=`wc -l /usr/local/etc/alcasar-uamallowed | cut -d" "  -f1`
244
	if [ $nb_exceptions != "0" ]
248
	if [ $nb_exceptions != "0" ]
245
	then
249
	then
246
		while read ip_allowed_line 
250
		while read ip_allowed_line 
247
		do
251
		do
248
			ip_allowed=`echo $ip_allowed_line|cut -d"\"" -f2`
252
			ip_allowed=`echo $ip_allowed_line|cut -d"\"" -f2`
249
			$IPTABLES -A FORWARD -i $TUNIF -d $ip_allowed -m state --state NEW -j ULOG --ulog-prefix "RULE IP-allowed -- ACCEPT "
253
			$IPTABLES -A FORWARD -i $TUNIF -d $ip_allowed -m state --state NEW -j ULOG --ulog-prefix "RULE IP-allowed -- ACCEPT "
250
			$IPTABLES -A FORWARD -i $TUNIF -d $ip_allowed -m state --state NEW -j ACCEPT
254
			$IPTABLES -A FORWARD -i $TUNIF -d $ip_allowed -m state --state NEW -j ACCEPT
251
		done < /usr/local/etc/alcasar-uamallowed
255
		done < /usr/local/etc/alcasar-uamallowed
252
	fi
256
	fi
253
	# Autorisation des protocoles non commentés
257
	# Autorisation des protocoles non commentés
254
	# Allow non comment protocols
258
	# Allow non comment protocols
255
	while read svc_line
259
	while read svc_line
256
	do
260
	do
257
		svc_on=`echo $svc_line|cut -b1`
261
		svc_on=`echo $svc_line|cut -b1`
258
		if [ $svc_on != "#" ]
262
		if [ $svc_on != "#" ]
259
		then	
263
		then	
260
			svc_name=`echo $svc_line|cut -d" " -f1`
264
			svc_name=`echo $svc_line|cut -d" " -f1`
261
			svc_port=`echo $svc_line|cut -d" " -f2`
265
			svc_port=`echo $svc_line|cut -d" " -f2`
262
			if [ $svc_name = "icmp" ]
266
			if [ $svc_name = "icmp" ]
263
			then
267
			then
264
				$IPTABLES -A FORWARD -i $TUNIF -p icmp -j ACCEPT 
268
				$IPTABLES -A FORWARD -i $TUNIF -s $PRIVATE_NETWORK_MASK -p icmp -j ACCEPT 
265
			else
269
			else
266
				$IPTABLES -A FORWARD -i $TUNIF -p tcp --dport $svc_port -m state --state NEW -j ULOG --ulog-prefix "RULE F_TCP-$svc_name -- ACCEPT "
270
				$IPTABLES -A FORWARD -i $TUNIF -s $PRIVATE_NETWORK_MASK -p tcp --dport $svc_port -m state --state NEW -j ULOG --ulog-prefix "RULE F_TCP-$svc_name -- ACCEPT "
267
				$IPTABLES -A FORWARD -i $TUNIF -p tcp --dport $svc_port -m state --state NEW -j ACCEPT
271
				$IPTABLES -A FORWARD -i $TUNIF -s $PRIVATE_NETWORK_MASK -p tcp --dport $svc_port -m state --state NEW -j ACCEPT
268
				$IPTABLES -A FORWARD -i $TUNIF -p udp --dport $svc_port -m state --state NEW -j ULOG --ulog-prefix "RULE F_UDP-$svc_name -- ACCEPT "
272
				$IPTABLES -A FORWARD -i $TUNIF -s $PRIVATE_NETWORK_MASK -p udp --dport $svc_port -m state --state NEW -j ULOG --ulog-prefix "RULE F_UDP-$svc_name -- ACCEPT "
269
				$IPTABLES -A FORWARD -i $TUNIF -p udp --dport $svc_port -m state --state NEW -j ACCEPT
273
				$IPTABLES -A FORWARD -i $TUNIF -s $PRIVATE_NETWORK_MASK -p udp --dport $svc_port -m state --state NEW -j ACCEPT
270
			fi
274
			fi
271
		fi
275
		fi
272
	done < /usr/local/etc/alcasar-services
276
	done < /usr/local/etc/alcasar-services
273
	# Rejet explicite des autres protocoles
277
	# Rejet explicite des autres protocoles
274
	# reject the others protocols
278
	# reject the others protocols
275
	$IPTABLES -A FORWARD -i $TUNIF -j ULOG --ulog-prefix "RULE F_filter -- REJECT "
279
	$IPTABLES -A FORWARD -i $TUNIF -j ULOG --ulog-prefix "RULE F_filter -- REJECT "
276
	$IPTABLES -A FORWARD -i $TUNIF -p tcp -j REJECT --reject-with tcp-reset
280
	$IPTABLES -A FORWARD -i $TUNIF -p tcp -j REJECT --reject-with tcp-reset
277
	$IPTABLES -A FORWARD -i $TUNIF -p udp -j REJECT --reject-with icmp-port-unreachable
281
	$IPTABLES -A FORWARD -i $TUNIF -p udp -j REJECT --reject-with icmp-port-unreachable
278
	$IPTABLES -A FORWARD -i $TUNIF -p icmp -j REJECT 
282
	$IPTABLES -A FORWARD -i $TUNIF -p icmp -j REJECT 
279
fi
283
fi
280
 
284
 
281
#  If QOS is activate  #
285
#  If QOS is activate  #
282
if [ $QOS = on ] && [ -e /usr/local/etc/alcasar-iptables-qos.sh ]; then
286
if [ $QOS = on ] && [ -e /usr/local/etc/alcasar-iptables-qos.sh ]; then
283
	. /usr/local/etc/alcasar-iptables-qos.sh 	
287
	. /usr/local/etc/alcasar-iptables-qos.sh 	
284
fi
288
fi
285
 
289
 
286
# Autorisation des connections sortant du LAN  
290
# Autorisation des connections sortant du LAN  
287
# Allow forward connections with log
291
# Allow forward connections with log
288
$IPTABLES -A FORWARD -i $TUNIF -m state --state NEW -j ULOG --ulog-prefix "RULE F_all -- ACCEPT "
292
$IPTABLES -A FORWARD -i $TUNIF -s $PRIVATE_NETWORK_MASK -m state --state NEW -j ULOG --ulog-prefix "RULE F_all -- ACCEPT "
289
$IPTABLES -A FORWARD -i $TUNIF -m state --state NEW -j ACCEPT
293
$IPTABLES -A FORWARD -i $TUNIF -s $PRIVATE_NETWORK_MASK -m state --state NEW -j ACCEPT
290
 
294
 
291
#############################
295
#############################
292
#         OUTPUT            #
296
#         OUTPUT            #
293
#############################
297
#############################
294
# SSHD rules if activate 
298
# SSHD rules if activate 
295
if [ $SSH = on ]
299
if [ $SSH = on ]
296
	then
300
	then
297
	$IPTABLES -A OUTPUT -o $EXTIF -p tcp --sport ssh -m state --state ESTABLISHED -j ACCEPT
301
	$IPTABLES -A OUTPUT -o $EXTIF -p tcp --sport ssh -m state --state ESTABLISHED -j ACCEPT
298
fi
302
fi
299
# On laisse tout sortir sur toutes les cartes sauf celle qui est connectée sur l'extérieur
303
# On laisse tout sortir sur toutes les cartes sauf celle qui est connectée sur l'extérieur
300
# Everything is allowed but traffic through outside network interface
304
# Everything is allowed but traffic through outside network interface
301
$IPTABLES -A OUTPUT ! -o $EXTIF -j ACCEPT
305
$IPTABLES -A OUTPUT ! -o $EXTIF -j ACCEPT
302
 
306
 
303
# On autorise les requêtes DNS vers les serveurs DNS identifiés 
307
# On autorise les requêtes DNS vers les serveurs DNS identifiés 
304
# Allow DNS requests to identified DNS servers
308
# Allow DNS requests to identified DNS servers
305
$IPTABLES -A OUTPUT -o $EXTIF -d $DNSSERVERS -p udp --dport domain -m state --state NEW -j ACCEPT
309
$IPTABLES -A OUTPUT -o $EXTIF -d $DNSSERVERS -p udp --dport domain -m state --state NEW -j ACCEPT
306
 
310
 
307
# On autorise les requêtes HTTP sortantes
311
# On autorise les requêtes HTTP sortantes
308
# HTTP requests are allowed
312
# HTTP requests are allowed
309
$IPTABLES -A OUTPUT -o $EXTIF -p tcp --dport http -j ACCEPT
313
$IPTABLES -A OUTPUT -o $EXTIF -p tcp --dport http -j ACCEPT
310
 
314
 
311
# On autorise les requêtes FTP 
315
# On autorise les requêtes FTP 
312
# FTP requests are allowed
316
# FTP requests are allowed
313
modprobe ip_conntrack_ftp
317
modprobe ip_conntrack_ftp
314
$IPTABLES -A OUTPUT -o $EXTIF -p tcp --dport ftp -j ACCEPT
318
$IPTABLES -A OUTPUT -o $EXTIF -p tcp --dport ftp -j ACCEPT
315
$IPTABLES -A OUTPUT -o $EXTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
319
$IPTABLES -A OUTPUT -o $EXTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
316
 
320
 
317
# On autorise les requêtes NTP 
321
# On autorise les requêtes NTP 
318
# NTP requests are allowed
322
# NTP requests are allowed
319
$IPTABLES -A OUTPUT -o $EXTIF -p udp --dport ntp -j ACCEPT
323
$IPTABLES -A OUTPUT -o $EXTIF -p udp --dport ntp -j ACCEPT
320
 
324
 
321
# On autorise les requêtes ICMP (ping) 
325
# On autorise les requêtes ICMP (ping) 
322
# ICMP (ping) requests are allowed
326
# ICMP (ping) requests are allowed
323
$IPTABLES -A OUTPUT -o $EXTIF -p icmp --icmp-type 8 -j ACCEPT
327
$IPTABLES -A OUTPUT -o $EXTIF -p icmp --icmp-type 8 -j ACCEPT
324
 
328
 
325
# On autorise les requêtes LDAP si un serveur externe est configué
329
# On autorise les requêtes LDAP si un serveur externe est configué
326
# LDAP requests are allowed if an external server is declared
330
# LDAP requests are allowed if an external server is declared
327
if [ $LDAP = on ]
331
if [ $LDAP = on ]
328
	then
332
	then
329
	$IPTABLES -A OUTPUT -p tcp -d $LDAP_IP -m multiport --dports ldap,ldaps -m state --state NEW,ESTABLISHED -j ACCEPT
333
	$IPTABLES -A OUTPUT -p tcp -d $LDAP_IP -m multiport --dports ldap,ldaps -m state --state NEW,ESTABLISHED -j ACCEPT
330
	$IPTABLES -A OUTPUT -p udp -d $LDAP_IP -m multiport --dports ldap,ldaps -m state --state NEW,ESTABLISHED -j ACCEPT
334
	$IPTABLES -A OUTPUT -p udp -d $LDAP_IP -m multiport --dports ldap,ldaps -m state --state NEW,ESTABLISHED -j ACCEPT
331
#	$IPTABLES -A INPUT  -p tcp -s $LDAP_IP -m multiports --sports ldap,ldaps -m state --state ESTABLISHED -j ACCEPT
335
#	$IPTABLES -A INPUT  -p tcp -s $LDAP_IP -m multiports --sports ldap,ldaps -m state --state ESTABLISHED -j ACCEPT
332
#	$IPTABLES -A INPUT  -p udp -s $LDAP_IP -m multiports --sports ldap,ldaps -m state --state ESTABLISHED -j ACCEPT
336
#	$IPTABLES -A INPUT  -p udp -s $LDAP_IP -m multiports --sports ldap,ldaps -m state --state ESTABLISHED -j ACCEPT
333
fi
337
fi
334
 
338
 
335
 
339
 
336
#############################
340
#############################
337
#       POSTROUTING         #
341
#       POSTROUTING         #
338
#############################
342
#############################
339
# Traduction dynamique d'adresse en sortie
343
# Traduction dynamique d'adresse en sortie
340
# Dynamic NAT on EXTIF
344
# Dynamic NAT on EXTIF
341
$IPTABLES -A POSTROUTING -t nat -o $EXTIF -j MASQUERADE
345
$IPTABLES -A POSTROUTING -t nat -o $EXTIF -j MASQUERADE
342
 
346
 
343
# Save all rules
347
# Save all rules
344
/etc/init.d/iptables save
348
/etc/init.d/iptables save
345
 
349
 
346
# End of script
350
# End of script
347
 
351
 
348
 
352