Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
# $Id: alcasar-iptables.sh 2495 2018-02-26 01:41:09Z tom.houdayer $
|
2 |
# $Id: alcasar-iptables.sh 2496 2018-02-26 01:47:02Z tom.houdayer $
|
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 192... |
Line 192... |
192 |
# redirect DNS of 'havp_wl' users to port 55
|
192 |
# redirect DNS of 'havp_wl' users to port 55
|
193 |
$IPTABLES -A PREROUTING -t nat -i $TUNIF -m set --match-set havp_wl src -d $PRIVATE_IP -p udp --dport domain -j REDIRECT --to-port 55
|
193 |
$IPTABLES -A PREROUTING -t nat -i $TUNIF -m set --match-set havp_wl src -d $PRIVATE_IP -p udp --dport domain -j REDIRECT --to-port 55
|
194 |
|
194 |
|
195 |
# Journalisation HTTP_Internet des usagers 'havp_bl' (paquets SYN uniquement). Les autres protocoles sont journalisés en FORWARD par netflow.
|
195 |
# Journalisation HTTP_Internet des usagers 'havp_bl' (paquets SYN uniquement). Les autres protocoles sont journalisés en FORWARD par netflow.
|
196 |
# Log Internet HTTP of 'havp_bl' users" (only syn packets). Other protocols are logged in FORWARD by netflow
|
196 |
# Log Internet HTTP of 'havp_bl' users" (only syn packets). Other protocols are logged in FORWARD by netflow
|
197 |
$IPTABLES -A PREROUTING -t nat -i $TUNIF -m set --match-set havp_bl src ! -d $PRIVATE_IP -p tcp --dport http -m state --state NEW -j NFLOG --nflog-group 1 --nflog-prefix "RULE F_http -- ACCEPT "
|
197 |
$IPTABLES -A PREROUTING -t nat -i $TUNIF -m set --match-set havp_bl src ! -d $PRIVATE_IP -p tcp --dport http -m conntrack --ctstate NEW -j NFLOG --nflog-group 1 --nflog-prefix "RULE F_http -- ACCEPT "
|
198 |
|
198 |
|
199 |
# Redirection HTTP des usagers 'havp_bl' cherchant à joindre les IP de la blacklist vers ALCASAR (page 'accès interdit')
|
199 |
# Redirection HTTP des usagers 'havp_bl' cherchant à joindre les IP de la blacklist vers ALCASAR (page 'accès interdit')
|
200 |
# Redirect HTTP of 'havp_bl' users who want blacklist IP to ALCASAR ('access denied' page)
|
200 |
# Redirect HTTP of 'havp_bl' users who want blacklist IP to ALCASAR ('access denied' page)
|
201 |
$IPTABLES -A PREROUTING -t nat -i $TUNIF -m set --match-set havp_bl src -m set --match-set bl_ip_blocked dst -p tcp --dport http -j REDIRECT --to-port 80
|
201 |
$IPTABLES -A PREROUTING -t nat -i $TUNIF -m set --match-set havp_bl src -m set --match-set bl_ip_blocked dst -p tcp --dport http -j REDIRECT --to-port 80
|
202 |
|
202 |
|
Line 230... |
Line 230... |
230 |
# Drop non standard connexions (FIN-URG-PUSH, XMAS, NullScan, SYN-RST et NEW not SYN)
|
230 |
# Drop non standard connexions (FIN-URG-PUSH, XMAS, NullScan, SYN-RST et NEW not SYN)
|
231 |
$IPTABLES -A INPUT -p tcp --tcp-flags FIN,URG,PSH FIN,URG,PSH -j DROP
|
231 |
$IPTABLES -A INPUT -p tcp --tcp-flags FIN,URG,PSH FIN,URG,PSH -j DROP
|
232 |
$IPTABLES -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
|
232 |
$IPTABLES -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
|
233 |
$IPTABLES -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
|
233 |
$IPTABLES -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
|
234 |
$IPTABLES -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
|
234 |
$IPTABLES -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
|
235 |
$IPTABLES -A INPUT -p tcp -m tcp ! --syn -m state --state NEW -j DROP
|
235 |
$IPTABLES -A INPUT -p tcp -m tcp ! --syn -m conntrack --ctstate NEW -j DROP
|
236 |
|
236 |
|
237 |
# Si configéré, on autorise les réponses DHCP
|
237 |
# Si configéré, on autorise les réponses DHCP
|
238 |
# Allow DHCP answers if configured
|
238 |
# Allow DHCP answers if configured
|
239 |
public_ip_mask=`grep ^PUBLIC_IP= $CONF_FILE|cut -d"=" -f2` # ALCASAR WAN IP address
|
239 |
public_ip_mask=`grep ^PUBLIC_IP= $CONF_FILE|cut -d"=" -f2` # ALCASAR WAN IP address
|
240 |
if [[ "$public_ip_mask" == "dhcp" ]]
|
240 |
if [[ "$public_ip_mask" == "dhcp" ]]
|
Line 246... |
Line 246... |
246 |
# Drop broadcast & multicast on EXTIF to avoid log
|
246 |
# Drop broadcast & multicast on EXTIF to avoid log
|
247 |
$IPTABLES -A INPUT -m addrtype --dst-type BROADCAST,MULTICAST -j DROP
|
247 |
$IPTABLES -A INPUT -m addrtype --dst-type BROADCAST,MULTICAST -j DROP
|
248 |
|
248 |
|
249 |
# On autorise les retours de connexions légitimes par INPUT
|
249 |
# On autorise les retours de connexions légitimes par INPUT
|
250 |
# Conntrack on INPUT
|
250 |
# Conntrack on INPUT
|
251 |
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
|
251 |
$IPTABLES -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
|
252 |
|
252 |
|
253 |
# On interdit les connexions directes au port utilisé par DansGuardian (8080). Les packets concernés ont été marqués et loggués dans la table mangle (PREROUTING)
|
253 |
# On interdit les connexions directes au port utilisé par DansGuardian (8080). Les packets concernés ont été marqués et loggués dans la table mangle (PREROUTING)
|
254 |
# Deny direct connections on DansGuardian port (8080). The concerned paquets have been marked and logged in mangle table (PREROUTING)
|
254 |
# Deny direct connections on DansGuardian port (8080). The concerned paquets have been marked and logged in mangle table (PREROUTING)
|
255 |
$IPTABLES -A INPUT -i $TUNIF -p tcp --dport 8080 -m mark --mark 1 -j REJECT --reject-with tcp-reset
|
255 |
$IPTABLES -A INPUT -i $TUNIF -p tcp --dport 8080 -m mark --mark 1 -j REJECT --reject-with tcp-reset
|
256 |
|
256 |
|
257 |
# Autorisation des connexions légitimes à DansGuardian
|
257 |
# Autorisation des connexions légitimes à DansGuardian
|
258 |
# Allow connections for DansGuardian
|
258 |
# Allow connections for DansGuardian
|
259 |
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -p tcp --dport 8080 -m state --state NEW --syn -j ACCEPT
|
259 |
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -p tcp --dport 8080 -m conntrack --ctstate NEW --syn -j ACCEPT
|
260 |
|
260 |
|
261 |
# On interdit les connexions directes au port utilisé par tinyproxy (8090). Les packets concernés ont été marqués et loggués dans la table mangle (PREROUTING)
|
261 |
# On interdit les connexions directes au port utilisé par tinyproxy (8090). Les packets concernés ont été marqués et loggués dans la table mangle (PREROUTING)
|
262 |
# Deny direct connections on tinyproxy port (8090). The concerned paquets have been marked in mangle table (PREROUTING)
|
262 |
# Deny direct connections on tinyproxy port (8090). The concerned paquets have been marked in mangle table (PREROUTING)
|
263 |
$IPTABLES -A INPUT -i $TUNIF -p tcp --dport 8090 -m mark --mark 2 -j REJECT --reject-with tcp-reset
|
263 |
$IPTABLES -A INPUT -i $TUNIF -p tcp --dport 8090 -m mark --mark 2 -j REJECT --reject-with tcp-reset
|
264 |
|
264 |
|
265 |
# Autorisation des connexions légitimes vers tinyproxy
|
265 |
# Autorisation des connexions légitimes vers tinyproxy
|
266 |
# Allow connections to tinyproxy
|
266 |
# Allow connections to tinyproxy
|
267 |
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -p tcp --dport 8090 -m state --state NEW --syn -j ACCEPT
|
267 |
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -p tcp --dport 8090 -m conntrack --ctstate NEW --syn -j ACCEPT
|
268 |
|
268 |
|
269 |
# On interdit les connexions directes au port 54 (DNS-blacklist). Les packets concernés ont été marqués dans la table mangle (PREROUTING)
|
269 |
# On interdit les connexions directes au port 54 (DNS-blacklist). Les packets concernés ont été marqués dans la table mangle (PREROUTING)
|
270 |
# Deny direct connections on port 54 (DNS-blacklist). The concerned paquets are marked in mangle table (PREROUTING)
|
270 |
# Deny direct connections on port 54 (DNS-blacklist). The concerned paquets are marked in mangle table (PREROUTING)
|
271 |
$IPTABLES -A INPUT -i $TUNIF -p udp --dport 54 -m mark --mark 3 -j REJECT --reject-with icmp-port-unreachable
|
271 |
$IPTABLES -A INPUT -i $TUNIF -p udp --dport 54 -m mark --mark 3 -j REJECT --reject-with icmp-port-unreachable
|
272 |
$IPTABLES -A INPUT -i $TUNIF -p tcp --dport 54 -m mark --mark 3 -j REJECT --reject-with tcp-reset
|
272 |
$IPTABLES -A INPUT -i $TUNIF -p tcp --dport 54 -m mark --mark 3 -j REJECT --reject-with tcp-reset
|
Line 308... |
Line 308... |
308 |
$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
|
308 |
$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
|
309 |
|
309 |
|
310 |
# SSHD rules if activate
|
310 |
# SSHD rules if activate
|
311 |
if [ $SSH = on ]
|
311 |
if [ $SSH = on ]
|
312 |
then
|
312 |
then
|
313 |
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport ssh -m state --state NEW -j NFLOG --nflog-group 2 --nflog-prefix "RULE ssh-from-LAN -- ACCEPT"
|
313 |
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport ssh -m conntrack --ctstate NEW -j NFLOG --nflog-group 2 --nflog-prefix "RULE ssh-from-LAN -- ACCEPT"
|
314 |
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport ssh -j ACCEPT
|
314 |
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p tcp --dport ssh -j ACCEPT
|
315 |
$IPTABLES -A INPUT -i $EXTIF -s $SSH_ADMIN_FROM -d $PUBLIC_IP -p tcp --dport ssh -m state --state NEW --syn -j NFLOG --nflog-group 2 --nflog-prefix "RULE ssh-from-WAN -- ACCEPT"
|
315 |
$IPTABLES -A INPUT -i $EXTIF -s $SSH_ADMIN_FROM -d $PUBLIC_IP -p tcp --dport ssh -m conntrack --ctstate NEW --syn -j NFLOG --nflog-group 2 --nflog-prefix "RULE ssh-from-WAN -- ACCEPT"
|
316 |
$IPTABLES -A INPUT -i $EXTIF -s $SSH_ADMIN_FROM -d $PUBLIC_IP -p tcp --dport ssh -m state --state NEW -j ACCEPT
|
316 |
$IPTABLES -A INPUT -i $EXTIF -s $SSH_ADMIN_FROM -d $PUBLIC_IP -p tcp --dport ssh -m conntrack --ctstate NEW -j ACCEPT
|
317 |
fi
|
317 |
fi
|
318 |
|
318 |
|
319 |
# Insertion de règles locales
|
319 |
# Insertion de règles locales
|
320 |
# Here, we add local rules (i.e. VPN from Internet)
|
320 |
# Here, we add local rules (i.e. VPN from Internet)
|
321 |
if [ -f /usr/local/etc/alcasar-iptables-local.sh ]; then
|
321 |
if [ -f /usr/local/etc/alcasar-iptables-local.sh ]; then
|
322 |
. /usr/local/etc/alcasar-iptables-local.sh
|
322 |
. /usr/local/etc/alcasar-iptables-local.sh
|
323 |
fi
|
323 |
fi
|
324 |
|
324 |
|
325 |
# Journalisation et rejet des connexions (autres que celles autorisées) effectuées depuis le LAN
|
325 |
# Journalisation et rejet des connexions (autres que celles autorisées) effectuées depuis le LAN
|
326 |
# Deny and log on INPUT from the LAN
|
326 |
# Deny and log on INPUT from the LAN
|
327 |
$IPTABLES -A INPUT -i $TUNIF -m state --state NEW -j NFLOG --nflog-group 1 --nflog-prefix "RULE rej-int -- REJECT "
|
327 |
$IPTABLES -A INPUT -i $TUNIF -m conntrack --ctstate NEW -j NFLOG --nflog-group 1 --nflog-prefix "RULE rej-int -- REJECT "
|
328 |
$IPTABLES -A INPUT -i $TUNIF -p tcp -j REJECT --reject-with tcp-reset
|
328 |
$IPTABLES -A INPUT -i $TUNIF -p tcp -j REJECT --reject-with tcp-reset
|
329 |
$IPTABLES -A INPUT -i $TUNIF -p udp -j REJECT --reject-with icmp-port-unreachable
|
329 |
$IPTABLES -A INPUT -i $TUNIF -p udp -j REJECT --reject-with icmp-port-unreachable
|
330 |
|
330 |
|
331 |
# Interdiction d'accès à INTIF (n'est utile que lorsque chilli est arrêté).
|
331 |
# Interdiction d'accès à INTIF (n'est utile que lorsque chilli est arrêté).
|
332 |
# Reject INTIF access (only when chilli is down)
|
332 |
# Reject INTIF access (only when chilli is down)
|
333 |
$IPTABLES -A INPUT -i $INTIF -j NFLOG --nflog-group 1 --nflog-prefix "RULE Protect1 -- REJECT "
|
333 |
$IPTABLES -A INPUT -i $INTIF -j NFLOG --nflog-group 1 --nflog-prefix "RULE Protect1 -- REJECT "
|
334 |
$IPTABLES -A INPUT -i $INTIF -j REJECT
|
334 |
$IPTABLES -A INPUT -i $INTIF -j REJECT
|
335 |
|
335 |
|
336 |
# Journalisation et rejet des connexions initiées depuis le réseau extérieur (test des effets du paramètre --limit en cours)
|
336 |
# Journalisation et rejet des connexions initiées depuis le réseau extérieur (test des effets du paramètre --limit en cours)
|
337 |
# On EXTIF, the access attempts are log in channel 2 (we should test --limit option to avoid deny of service)
|
337 |
# On EXTIF, the access attempts are log in channel 2 (we should test --limit option to avoid deny of service)
|
338 |
$IPTABLES -A INPUT -i $EXTIF -m state --state NEW -j NFLOG --nflog-group 3 --nflog-threshold 10 --nflog-prefix "RULE rej-ext -- DROP"
|
338 |
$IPTABLES -A INPUT -i $EXTIF -m conntrack --ctstate NEW -j NFLOG --nflog-group 3 --nflog-threshold 10 --nflog-prefix "RULE rej-ext -- DROP"
|
339 |
|
339 |
|
340 |
#############################
|
340 |
#############################
|
341 |
# FORWARD #
|
341 |
# FORWARD #
|
342 |
#############################
|
342 |
#############################
|
343 |
|
343 |
|
Line 352... |
Line 352... |
352 |
$IPTABLES -A FORWARD -i $TUNIF -p udp --dport domain -j REJECT --reject-with icmp-port-unreachable
|
352 |
$IPTABLES -A FORWARD -i $TUNIF -p udp --dport domain -j REJECT --reject-with icmp-port-unreachable
|
353 |
$IPTABLES -A FORWARD -i $TUNIF -p tcp --dport domain -j REJECT --reject-with tcp-reset
|
353 |
$IPTABLES -A FORWARD -i $TUNIF -p tcp --dport domain -j REJECT --reject-with tcp-reset
|
354 |
|
354 |
|
355 |
# Active le suivi de session
|
355 |
# Active le suivi de session
|
356 |
# Allow Conntrack
|
356 |
# Allow Conntrack
|
357 |
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
|
357 |
$IPTABLES -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
|
358 |
|
358 |
|
359 |
# Compute uamallowed IP (IP address of equipments connected between ALCASAR and Internet (DMZ, own servers, ...)
|
359 |
# Compute uamallowed IP (IP address of equipments connected between ALCASAR and Internet (DMZ, own servers, ...)
|
360 |
nb_uamallowed=`wc -l /usr/local/etc/alcasar-uamallowed | cut -d" " -f1`
|
360 |
nb_uamallowed=`wc -l /usr/local/etc/alcasar-uamallowed | cut -d" " -f1`
|
361 |
if [ $nb_uamallowed != "0" ]
|
361 |
if [ $nb_uamallowed != "0" ]
|
362 |
then
|
362 |
then
|
363 |
while read ip_allowed_line
|
363 |
while read ip_allowed_line
|
364 |
do
|
364 |
do
|
365 |
ip_allowed=`echo $ip_allowed_line|cut -d"\"" -f2`
|
365 |
ip_allowed=`echo $ip_allowed_line|cut -d"\"" -f2`
|
366 |
$IPTABLES -A FORWARD -i $TUNIF -d $ip_allowed -m state --state NEW -j NETFLOW
|
366 |
$IPTABLES -A FORWARD -i $TUNIF -d $ip_allowed -m conntrack --ctstate NEW -j NETFLOW
|
367 |
$IPTABLES -A FORWARD -i $TUNIF -d $ip_allowed -m state --state NEW -j ACCEPT
|
367 |
$IPTABLES -A FORWARD -i $TUNIF -d $ip_allowed -m conntrack --ctstate NEW -j ACCEPT
|
368 |
done < /usr/local/etc/alcasar-uamallowed
|
368 |
done < /usr/local/etc/alcasar-uamallowed
|
369 |
fi
|
369 |
fi
|
370 |
|
370 |
|
371 |
# filtrage protocole par utilisateur (profile 1 : http, https)
|
371 |
# filtrage protocole par utilisateur (profile 1 : http, https)
|
372 |
# protocols filtering for users (profil 1 : http, https)
|
372 |
# protocols filtering for users (profil 1 : http, https)
|
373 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_1 src -s $PRIVATE_NETWORK_MASK -p tcp -m multiport ! --dports http,https -m state --state NEW -j REJECT --reject-with tcp-reset
|
373 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_1 src -s $PRIVATE_NETWORK_MASK -p tcp -m multiport ! --dports http,https -m conntrack --ctstate NEW -j REJECT --reject-with tcp-reset
|
374 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_1 src -s $PRIVATE_NETWORK_MASK -p udp -m multiport ! --dports http,https -m state --state NEW -j REJECT --reject-with icmp-port-unreachable
|
374 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_1 src -s $PRIVATE_NETWORK_MASK -p udp -m multiport ! --dports http,https -m conntrack --ctstate NEW -j REJECT --reject-with icmp-port-unreachable
|
375 |
|
375 |
|
376 |
# filtrage protocole par utilisateur (profile 2 : http https pop3 pop3s imap imaps ftp sftp ssh)
|
376 |
# filtrage protocole par utilisateur (profile 2 : http https pop3 pop3s imap imaps ftp sftp ssh)
|
377 |
# protocols filtering for users (profil 2 : http https pop3 pop3s imap imaps ftp sftp ssh)
|
377 |
# protocols filtering for users (profil 2 : http https pop3 pop3s imap imaps ftp sftp ssh)
|
378 |
|
378 |
|
379 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_2 src -s $PRIVATE_NETWORK_MASK -p tcp -m multiport ! --dports http,https,pop3,pop3s,imap,imaps,ftp,ftp-data,sftp,ssh -m state --state NEW -j REJECT --reject-with tcp-reset
|
379 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_2 src -s $PRIVATE_NETWORK_MASK -p tcp -m multiport ! --dports http,https,pop3,pop3s,imap,imaps,ftp,ftp-data,sftp,ssh -m conntrack --ctstate NEW -j REJECT --reject-with tcp-reset
|
380 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_2 src -s $PRIVATE_NETWORK_MASK -p udp -m multiport ! --dports http,https,pop3,pop3s,imap,imaps,ssh -m state --state NEW -j REJECT --reject-with icmp-port-unreachable
|
380 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_2 src -s $PRIVATE_NETWORK_MASK -p udp -m multiport ! --dports http,https,pop3,pop3s,imap,imaps,ssh -m conntrack --ctstate NEW -j REJECT --reject-with icmp-port-unreachable
|
381 |
|
381 |
|
382 |
# filtrage protocole par utilisateur (profile 3 : personnalisable via l'ACC)
|
382 |
# filtrage protocole par utilisateur (profile 3 : personnalisable via l'ACC)
|
383 |
# protocols filtering for users (profil 3 : customized with ACC)
|
383 |
# protocols filtering for users (profil 3 : customized with ACC)
|
384 |
#profile 3 personalisables via l'ACC
|
384 |
#profile 3 personalisables via l'ACC
|
385 |
custom_tcp_protocols_list='';custom_udp_protocols_list=''
|
385 |
custom_tcp_protocols_list='';custom_udp_protocols_list=''
|
Line 419... |
Line 419... |
419 |
else
|
419 |
else
|
420 |
if [ "$svc_icmp" != "on" ]
|
420 |
if [ "$svc_icmp" != "on" ]
|
421 |
then
|
421 |
then
|
422 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_3 src -s $PRIVATE_NETWORK_MASK -p icmp -j REJECT --reject-with icmp-proto-unreachable
|
422 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_3 src -s $PRIVATE_NETWORK_MASK -p icmp -j REJECT --reject-with icmp-proto-unreachable
|
423 |
fi
|
423 |
fi
|
424 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_3 src -s $PRIVATE_NETWORK_MASK -p tcp -m multiport ! --dports $custom_tcp_protocols_list -m state --state NEW -j REJECT --reject-with tcp-reset
|
424 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_3 src -s $PRIVATE_NETWORK_MASK -p tcp -m multiport ! --dports $custom_tcp_protocols_list -m conntrack --ctstate NEW -j REJECT --reject-with tcp-reset
|
425 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_3 src -s $PRIVATE_NETWORK_MASK -p udp -m multiport ! --dports $custom_udp_protocols_list -m state --state NEW -j REJECT --reject-with icmp-port-unreachable
|
425 |
$IPTABLES -A FORWARD -i $TUNIF -m set --match-set proto_3 src -s $PRIVATE_NETWORK_MASK -p udp -m multiport ! --dports $custom_udp_protocols_list -m conntrack --ctstate NEW -j REJECT --reject-with icmp-port-unreachable
|
426 |
fi
|
426 |
fi
|
427 |
|
427 |
|
428 |
# journalisation et autorisation des connections sortant du LAN
|
428 |
# journalisation et autorisation des connections sortant du LAN
|
429 |
# Allow forward connections with log
|
429 |
# Allow forward connections with log
|
430 |
$IPTABLES -A FORWARD -i $TUNIF -s $PRIVATE_NETWORK_MASK -m state --state NEW -j NETFLOW
|
430 |
$IPTABLES -A FORWARD -i $TUNIF -s $PRIVATE_NETWORK_MASK -m conntrack --ctstate NEW -j NETFLOW
|
431 |
$IPTABLES -A FORWARD -i $TUNIF -s $PRIVATE_NETWORK_MASK -m state --state NEW -j ACCEPT
|
431 |
$IPTABLES -A FORWARD -i $TUNIF -s $PRIVATE_NETWORK_MASK -m conntrack --ctstate NEW -j ACCEPT
|
432 |
|
432 |
|
433 |
#############################
|
433 |
#############################
|
434 |
# OUTPUT #
|
434 |
# OUTPUT #
|
435 |
#############################
|
435 |
#############################
|
436 |
# On laisse tout sortir à l'exception de la carte externe (cf ci-dessous)
|
436 |
# On laisse tout sortir à l'exception de la carte externe (cf ci-dessous)
|
Line 446... |
Line 446... |
446 |
$IPTABLES -A OUTPUT -o $EXTIF -p udp --dport 67 -j ACCEPT
|
446 |
$IPTABLES -A OUTPUT -o $EXTIF -p udp --dport 67 -j ACCEPT
|
447 |
fi
|
447 |
fi
|
448 |
|
448 |
|
449 |
# On autorise les requêtes DNS vers les serveurs DNS identifiés
|
449 |
# On autorise les requêtes DNS vers les serveurs DNS identifiés
|
450 |
# Allow DNS requests to identified DNS servers
|
450 |
# Allow DNS requests to identified DNS servers
|
451 |
$IPTABLES -A OUTPUT -o $EXTIF -d $DNSSERVERS -p udp --dport domain -m state --state NEW -j ACCEPT
|
451 |
$IPTABLES -A OUTPUT -o $EXTIF -d $DNSSERVERS -p udp --dport domain -m conntrack --ctstate NEW -j ACCEPT
|
452 |
|
452 |
|
453 |
# On autorise les requêtes HTTP avec log Netflow (en provenance de Dansguardian)
|
453 |
# On autorise les requêtes HTTP avec log Netflow (en provenance de Dansguardian)
|
454 |
# HTTPS requests are allowed with netflow log (from Dansguardian)
|
454 |
# HTTPS requests are allowed with netflow log (from Dansguardian)
|
455 |
$IPTABLES -A OUTPUT -o $EXTIF -p tcp --dport http -j NETFLOW
|
455 |
$IPTABLES -A OUTPUT -o $EXTIF -p tcp --dport http -j NETFLOW
|
456 |
$IPTABLES -A OUTPUT -o $EXTIF -p tcp --dport http -j ACCEPT
|
456 |
$IPTABLES -A OUTPUT -o $EXTIF -p tcp --dport http -j ACCEPT
|
Line 465... |
Line 465... |
465 |
|
465 |
|
466 |
# On autorise les requêtes FTP
|
466 |
# On autorise les requêtes FTP
|
467 |
# FTP requests are allowed
|
467 |
# FTP requests are allowed
|
468 |
modprobe nf_conntrack_ftp
|
468 |
modprobe nf_conntrack_ftp
|
469 |
$IPTABLES -A OUTPUT -o $EXTIF -p tcp --dport ftp -j ACCEPT
|
469 |
$IPTABLES -A OUTPUT -o $EXTIF -p tcp --dport ftp -j ACCEPT
|
470 |
$IPTABLES -A OUTPUT -o $EXTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
|
470 |
$IPTABLES -A OUTPUT -o $EXTIF -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
|
471 |
|
471 |
|
472 |
# On autorise les requêtes NTP
|
472 |
# On autorise les requêtes NTP
|
473 |
# NTP requests are allowed
|
473 |
# NTP requests are allowed
|
474 |
$IPTABLES -A OUTPUT -o $EXTIF -p udp --dport ntp -j ACCEPT
|
474 |
$IPTABLES -A OUTPUT -o $EXTIF -p udp --dport ntp -j ACCEPT
|
475 |
|
475 |
|
Line 477... |
Line 477... |
477 |
# ICMP (ping) requests are allowed
|
477 |
# ICMP (ping) requests are allowed
|
478 |
$IPTABLES -A OUTPUT -o $EXTIF -p icmp --icmp-type 8 -j ACCEPT
|
478 |
$IPTABLES -A OUTPUT -o $EXTIF -p icmp --icmp-type 8 -j ACCEPT
|
479 |
|
479 |
|
480 |
# On autorise les requêtes LDAP
|
480 |
# On autorise les requêtes LDAP
|
481 |
# LDAP requests are allowed
|
481 |
# LDAP requests are allowed
|
482 |
$IPTABLES -A OUTPUT -o $EXTIF -p tcp -m multiport --dports ldap,ldaps -m state --state NEW,ESTABLISHED -j ACCEPT
|
482 |
$IPTABLES -A OUTPUT -o $EXTIF -p tcp -m multiport --dports ldap,ldaps -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
|
483 |
$IPTABLES -A OUTPUT -o $EXTIF -p udp -m multiport --dports ldap,ldaps -m state --state NEW,ESTABLISHED -j ACCEPT
|
483 |
$IPTABLES -A OUTPUT -o $EXTIF -p udp -m multiport --dports ldap,ldaps -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
|
484 |
|
484 |
|
485 |
#############################
|
485 |
#############################
|
486 |
# POSTROUTING #
|
486 |
# POSTROUTING #
|
487 |
#############################
|
487 |
#############################
|
488 |
# Traduction dynamique d'adresse en sortie
|
488 |
# Traduction dynamique d'adresse en sortie
|