Line 1... |
Line 1... |
1 |
#!/bin/sh
|
1 |
#!/bin/sh
|
2 |
#
|
2 |
#
|
3 |
# $Id: alcasar-iptables-local.sh 2956 2021-05-24 19:57:17Z rexy $
|
3 |
# $Id: alcasar-iptables-local.sh 2986 2022-01-09 17:23:00Z rexy $
|
4 |
#
|
4 |
#
|
5 |
# Custom rules for ALCASAR firewall
|
5 |
# Custom rules for ALCASAR firewall
|
6 |
#
|
6 |
#
|
7 |
# Examples:
|
7 |
# Examples:
|
8 |
# - Local MAC addresses filtering (MAC are in '/usr/local/etc/alcasar-iptables-local-mac-filtered'. Format : aa:09:23:2f:4d:ee)
|
8 |
# - Local MAC addresses filtering (MAC are in '/usr/local/etc/alcasar-iptables-local-mac-filtered'. Format : aa:09:23:2f:4d:ee)
|
Line 34... |
Line 34... |
34 |
# On autorise le ping (echo & request) (ICMP N°0 & 8) en provenance d'Internet vers ALCASAR
|
34 |
# On autorise le ping (echo & request) (ICMP N°0 & 8) en provenance d'Internet vers ALCASAR
|
35 |
# Allow ping (echo & request) (ICMP N°0 & 8) from Internet
|
35 |
# Allow ping (echo & request) (ICMP N°0 & 8) from Internet
|
36 |
#$IPTABLES -A INPUT -i $EXTIF -p icmp --icmp-type 8 -j ACCEPT
|
36 |
#$IPTABLES -A INPUT -i $EXTIF -p icmp --icmp-type 8 -j ACCEPT
|
37 |
#$IPTABLES -A OUTPUT -o $EXTIF -p icmp --icmp-type 0 -j ACCEPT
|
37 |
#$IPTABLES -A OUTPUT -o $EXTIF -p icmp --icmp-type 0 -j ACCEPT
|
38 |
|
38 |
|
- |
|
39 |
# On interdit les utilisateurs d'accéder à des réseaux situés entre ALCASAR et le routeur d'accès à Internet
|
- |
|
40 |
# Deny access of users to networks connected between ALCASAR and Internet broadband router
|
- |
|
41 |
#protectedNetworks='10.0.0.0/8,172.16.0.0/12,192.168.0.0/16' # (RFC 1918)
|
- |
|
42 |
#[ -n "$TUNIF" ] && consultationIF=$TUNIF || consultationIF=$INTIF
|
- |
|
43 |
#$IPTABLES -A FORWARD -i $consultationIF -d $protectedNetworks -j DROP
|
- |
|
44 |
#$IPTABLES -A FORWARD -o $consultationIF -s $protectedNetworks -j DROP
|
- |
|
45 |
|
39 |
# On autorise ALCASAR a accéder à un serveur MAIL local (envoie de rapports, alertes, etc.)
|
46 |
# On autorise ALCASAR a accéder à un serveur MAIL local (envoie de rapports, alertes, etc.)
|
40 |
# Allow ALCASAR to conect to a local mail server (send reports, alerts, etc.)
|
47 |
# Allow ALCASAR to conect to a local mail server (send reports, alerts, etc.)
|
41 |
#SMTP_IP='192.168.111.5' # IP of mail server
|
48 |
#SMTP_IP='192.168.111.5' # IP of mail server
|
42 |
#SMTP_PORT=587 # port of mail server (25 for SMTP ; 587 for STARTTLS ; 465 for SMTPS)
|
49 |
#SMTP_PORT=587 # port of mail server (25 for SMTP ; 587 for STARTTLS ; 465 for SMTPS)
|
43 |
#$IPTABLES -A OUTPUT -p tcp -d $SMTP_IP --dport $SMTP_PORT -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
|
50 |
#$IPTABLES -A OUTPUT -p tcp -d $SMTP_IP --dport $SMTP_PORT -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
|
44 |
#$IPTABLES -A INPUT -p tcp -s $SMTP_IP --sport $SMTP_PORT -m conntrack --ctstate ESTABLISHED -j ACCEPT
|
51 |
#$IPTABLES -A INPUT -p tcp -s $SMTP_IP --sport $SMTP_PORT -m conntrack --ctstate ESTABLISHED -j ACCEPT
|
45 |
|
52 |
|
46 |
# On autorise l'accès SSH depuis Internet (port 11222) vers un equipement du LAN (port 22). On réalise donc un "PAT" (Port Adresse Translation)
|
53 |
# On autorise un admin à accéder à l'ACC depuis l'extérieur (Internet ou le LAN entre ALCASAR et la BOX)
|
47 |
# Allow PAT (Port Adresse Translation) from INTERNET (port 11222) in order to connect to a LAN equipment on port 22 (SSH)
|
54 |
# Allow managerIP to access ACC from the external network (Internet or LAN between ALCASAR and the broadband router)
|
- |
|
55 |
#managerIPs='192.168.0.10'
|
- |
|
56 |
#externalPort='34443'
|
- |
|
57 |
#$IPTABLES -t mangle -A PREROUTING -i $EXTIF -s $managerIPs -p tcp -d $PUBLIC_IP --dport $externalPort -j MARK --set-mark 100
|
- |
|
58 |
#$IPTABLES -t nat -A PREROUTING -i $EXTIF -s $managerIPs -p tcp -d $PUBLIC_IP --dport $externalPort -j DNAT --to $PRIVATE_IP:443
|
- |
|
59 |
#$IPTABLES -A INPUT -i $EXTIF -s $managerIPs -p tcp --dport 443 -m mark --mark 100 -j ACCEPT
|
- |
|
60 |
|
- |
|
61 |
# On autorise l'accès depuis Internet (port 11222) vers un equipement du LAN (port 22). L'équipement sur le LAN doit être en IP fixe
|
48 |
# example for the external UDP-TCP port 11222 which is redirected to the internal IP 192.168.182.10 on port 22
|
62 |
# Allow access from Internet (port 11222) to an LAN equipment (port 22). The equipment must be in static IP
|
49 |
#$IPTABLES -A PREROUTING -i $EXTIF -t nat -p tcp -d $PUBLIC_IP --dport 11222 -j DNAT --to 192.168.182.10:22
|
63 |
#$IPTABLES -A PREROUTING -i $EXTIF -t nat -p tcp -d $PUBLIC_IP --dport 11222 -j DNAT --to 192.168.182.10:22
|
50 |
#$IPTABLES -A PREROUTING -i $EXTIF -t nat -p udp -d $PUBLIC_IP --dport 11222 -j DNAT --to 192.168.182.10:22
|
64 |
#$IPTABLES -A PREROUTING -i $EXTIF -t nat -p udp -d $PUBLIC_IP --dport 11222 -j DNAT --to 192.168.182.10:22
|
51 |
#$IPTABLES -A FORWARD -p tcp -d 192.168.182.10 --dport 22 -j ACCEPT
|
65 |
#$IPTABLES -A FORWARD -p tcp -d 192.168.182.10 --dport 22 -j ACCEPT
|
52 |
#$IPTABLES -A FORWARD -p udp -d 192.168.182.10 --dport 22 -j ACCEPT
|
66 |
#$IPTABLES -A FORWARD -p udp -d 192.168.182.10 --dport 22 -j ACCEPT
|
53 |
|
67 |
|
54 |
# Deny access to protected networks from internal LAN
|
- |
|
55 |
#protectedNetworks='10.0.0.0/8,172.16.0.0/12,192.168.0.0/16' # (RFC 1918)
|
- |
|
56 |
#[ -n "$TUNIF" ] && consultationIF=$TUNIF || consultationIF=$INTIF
|
- |
|
57 |
#$IPTABLES -A FORWARD -i $consultationIF -d $protectedNetworks -j DROP
|
68 |
# On autorise l'accès depuis Internet (multiports) vers un équipement du LAN (par exemple pour un VPN). L'équipement doit être en IP fixe
|
58 |
#$IPTABLES -A FORWARD -o $consultationIF -s $protectedNetworks -j DROP
|
69 |
# Allow access from Internet (multiports) to an LAN equipment (VPN for example). The equipment must be in static IP
|
59 |
|
- |
|
60 |
# Allow managers to access ACC from the external network
|
70 |
#ext_ports=55022,31194; int_ports=44022,31194
|
61 |
#managerIPs='192.168.111.10'
|
71 |
#to_ip=192.168.182.7
|
62 |
#externalPort='34443'
|
- |
|
63 |
#$IPTABLES -t mangle -A PREROUTING -i $EXTIF -s $managerIPs -p tcp -d $PUBLIC_IP --dport $externalPort -j MARK --set-mark 100
|
72 |
#$IPTABLES -A PREROUTING -i $EXTIF -t nat -p tcp -d $PUBLIC_IP -m multiport --dports $ext_ports -j DNAT --to $to_ip
|
64 |
#$IPTABLES -t nat -A PREROUTING -i $EXTIF -s $managerIPs -p tcp -d $PUBLIC_IP --dport $externalPort -j DNAT --to $PRIVATE_IP:443
|
73 |
#$IPTABLES -A FORWARD -i $EXTIF -p tcp -d $to_ip -m multiport --dports $ext_ports -j ACCEPT
|
65 |
#$IPTABLES -A INPUT -i $EXTIF -s $managerIPs -p tcp --dport 443 -m mark --mark 100 -j ACCEPT
|
74 |
#$IPTABLES -A FORWARD -o $EXTIF -p tcp -s $to_ip -m multiport --sports $int_ports -j ACCEPT
|