Line 1... |
Line 1... |
1 |
#!/bin/sh
|
1 |
#!/bin/sh
|
2 |
# $Id: alcasar-iptables.sh 790 2012-01-12 23:23:59Z richard $
|
2 |
# $Id: alcasar-iptables.sh 791 2012-01-13 21:31:36Z 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
|
Line 133... |
Line 133... |
133 |
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
|
133 |
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
|
134 |
|
134 |
|
135 |
# On interdit les connexions directes au port utilisé par DansGuardian (8080). Les packets concernés ont été marqués dans la table mangle (PREROUTING)
|
135 |
# On interdit les connexions directes au port utilisé par DansGuardian (8080). Les packets concernés ont été marqués dans la table mangle (PREROUTING)
|
136 |
# Deny direct connections on DansGuardian port (8080). The concerned paquets are marked in mangle table (PREROUTING)
|
136 |
# Deny direct connections on DansGuardian port (8080). The concerned paquets are marked in mangle table (PREROUTING)
|
137 |
$IPTABLES -A INPUT -i $TUNIF -p tcp --dport 8080 -m mark --mark 1 -j REJECT --reject-with tcp-reset
|
137 |
$IPTABLES -A INPUT -i $TUNIF -p tcp --dport 8080 -m mark --mark 1 -j REJECT --reject-with tcp-reset
|
- |
|
138 |
|
- |
|
139 |
# Filtrage de l'accès au LAN connecté sur EXTIF (eth0)
|
- |
|
140 |
# EXTIF (eth0) connected LAN filtering
|
- |
|
141 |
if [ $EXT_LAN_FILTERING = on ]; then
|
- |
|
142 |
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK ! -d $public_ip_mask -p tcp --dport 8080 -m state --state NEW --syn -j ACCEPT
|
- |
|
143 |
else
|
138 |
# Autorisation des connexions légitimes à DansGuardian
|
144 |
# Autorisation des connexions légitimes à DansGuardian
|
139 |
# Allow connections for DansGuardian
|
145 |
# Allow connections for DansGuardian
|
140 |
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -p tcp --dport 8080 -m state --state NEW --syn -j ACCEPT
|
146 |
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -p tcp --dport 8080 -m state --state NEW --syn -j ACCEPT
|
- |
|
147 |
fi
|
141 |
|
148 |
|
142 |
# On interdit les connexions directes au port UDP 54. Les packets concernés ont été marqués dans la table mangle (PREROUTING)
|
149 |
# On interdit les connexions directes au port UDP 54. Les packets concernés ont été marqués dans la table mangle (PREROUTING)
|
143 |
# Deny direct connections on UDP 54. The concerned paquets are marked in mangle table (PREROUTING)
|
150 |
# Deny direct connections on UDP 54. The concerned paquets are marked in mangle table (PREROUTING)
|
144 |
$IPTABLES -A INPUT -i $TUNIF -p udp --dport 54 -m mark --mark 2 -j REJECT --reject-with icmp-port-unreachable
|
151 |
$IPTABLES -A INPUT -i $TUNIF -p udp --dport 54 -m mark --mark 2 -j REJECT --reject-with icmp-port-unreachable
|
- |
|
152 |
|
145 |
# autorisation des connexion légitime à DNSMASQ (avec blackhole)
|
153 |
# autorisation des connexion légitime à DNSMASQ (avec blackhole)
|
146 |
# Allow connections for DNSMASQ (with blackhole)
|
154 |
# Allow connections for DNSMASQ (with blackhole)
|
147 |
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p udp --dport 54 -j ACCEPT
|
155 |
$IPTABLES -A INPUT -i $TUNIF -s $PRIVATE_NETWORK_MASK -d $PRIVATE_IP -p udp --dport 54 -j ACCEPT
|
148 |
|
156 |
|
149 |
# Accès direct aux services internes
|
157 |
# Accès direct aux services internes
|
Line 187... |
Line 195... |
187 |
$IPTABLES -A INPUT -i $EXTIF -m state --state NEW -j ULOG --ulog-nlgroup 3 --ulog-qthreshold 10 --ulog-prefix "RULE rej-ext -- DROP"
|
195 |
$IPTABLES -A INPUT -i $EXTIF -m state --state NEW -j ULOG --ulog-nlgroup 3 --ulog-qthreshold 10 --ulog-prefix "RULE rej-ext -- DROP"
|
188 |
|
196 |
|
189 |
#############################
|
197 |
#############################
|
190 |
# FORWARD #
|
198 |
# FORWARD #
|
191 |
#############################
|
199 |
#############################
|
192 |
# Autorisation des retours de connexions légitimes
|
- |
|
193 |
# Allow conntrack
|
- |
|
194 |
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
|
- |
|
195 |
|
200 |
|
196 |
# Rejet des requêtes DNS vers Internet
|
201 |
# Rejet des requêtes DNS vers Internet
|
197 |
# Deny forward DNS
|
202 |
# Deny forward DNS
|
198 |
$IPTABLES -A FORWARD -i $TUNIF -p udp --dport domain -j REJECT --reject-with icmp-port-unreachable
|
203 |
$IPTABLES -A FORWARD -i $TUNIF -p udp --dport domain -j REJECT --reject-with icmp-port-unreachable
|
199 |
$IPTABLES -A FORWARD -i $TUNIF -p tcp --dport domain -j REJECT --reject-with tcp-reset
|
204 |
$IPTABLES -A FORWARD -i $TUNIF -p tcp --dport domain -j REJECT --reject-with tcp-reset
|
Line 254... |
Line 259... |
254 |
$IPTABLES -A FORWARD -i $TUNIF -j ULOG --ulog-prefix "RULE F_filter -- REJECT "
|
259 |
$IPTABLES -A FORWARD -i $TUNIF -j ULOG --ulog-prefix "RULE F_filter -- REJECT "
|
255 |
$IPTABLES -A FORWARD -i $TUNIF -p tcp -j REJECT --reject-with tcp-reset
|
260 |
$IPTABLES -A FORWARD -i $TUNIF -p tcp -j REJECT --reject-with tcp-reset
|
256 |
$IPTABLES -A FORWARD -i $TUNIF -p udp -j REJECT --reject-with icmp-port-unreachable
|
261 |
$IPTABLES -A FORWARD -i $TUNIF -p udp -j REJECT --reject-with icmp-port-unreachable
|
257 |
$IPTABLES -A FORWARD -i $TUNIF -p icmp -j REJECT
|
262 |
$IPTABLES -A FORWARD -i $TUNIF -p icmp -j REJECT
|
258 |
fi
|
263 |
fi
|
- |
|
264 |
# Autorisation des retours de connexions légitimes
|
- |
|
265 |
# Allow conntrack
|
- |
|
266 |
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
|
259 |
|
267 |
|
260 |
########################
|
- |
|
261 |
# If QOS is activate #
|
268 |
# If QOS is activate #
|
262 |
########################
|
- |
|
263 |
if [ $QOS = on ] && [ -e /usr/local/etc/alcasar-iptables-qos.sh ]; then
|
269 |
if [ $QOS = on ] && [ -e /usr/local/etc/alcasar-iptables-qos.sh ]; then
|
264 |
. /usr/local/etc/alcasar-iptables-qos.sh
|
270 |
. /usr/local/etc/alcasar-iptables-qos.sh
|
265 |
fi
|
271 |
fi
|
266 |
|
272 |
|
267 |
# Autorisation des connections sortant du LAN
|
273 |
# Autorisation des connections sortant du LAN
|