1 | #
|
---|
2 | # Wirless Leiden PF firewall configuration for Proxy Setup. This firewall has 5
|
---|
3 | # main features:
|
---|
4 | #
|
---|
5 | # 1) It supports outgoing NAT to specified ports. The so called iLeiden setup.
|
---|
6 | # 2) It supports incoming NAT from the private MGMT network, for maintenance use.
|
---|
7 | # 3) It protects the private MGMT network from WL requests to it's own services.
|
---|
8 | # 4) It portects the $ext_if by only allowing an subset of services.
|
---|
9 | # 5) The Wireless Leiden facing interfaces are not firewalled.
|
---|
10 | # 6) WL Captive Portal Support for interfaces who needs it.
|
---|
11 | # 7) Optional: Exposure of WL services to the outside
|
---|
12 | # 8) Overrides default route for local orginating traffic to specific ports, needed for
|
---|
13 | # for normal proxy setup, which should NOT follow the iLeiden default route.
|
---|
14 | # 9) Protect the Wireless Network from junk traffic.
|
---|
15 | wl_net="172.16.0.0/12"
|
---|
16 | allow_ext_tcp="{ssh, domain}"
|
---|
17 | allow_ext_udp="{domain, snmp}"
|
---|
18 | private="{ 10.0.0.0/8, 172.16.0.0/12 192.168.0.0/16 }"
|
---|
19 |
|
---|
20 |
|
---|
21 | # Default configuration for ALIX2 with vr0 as external interface and wlan0 as
|
---|
22 | # the public accesspoint in iLeiden setup.
|
---|
23 | ext_if="vr0"
|
---|
24 | ext_if_net="vr0:network"
|
---|
25 | ext_if_default_route="192.168.42.1"
|
---|
26 | captive_portal_interfaces="wlan0"
|
---|
27 | publicnat="http,https"
|
---|
28 | masterip="127.0.0.1"
|
---|
29 | # For an traditional proxy setup set, uncomment:
|
---|
30 | #publicnat=0
|
---|
31 |
|
---|
32 | # Always be nice, and return the fact we are blocking the packets
|
---|
33 | set block-policy return
|
---|
34 |
|
---|
35 | # Table used to authorized hosts (6)
|
---|
36 | table <wlportal> persist counters
|
---|
37 |
|
---|
38 | # NAT MGMT to Wireless Leiden (2)
|
---|
39 | nat on ! $ext_if from $ext_if_net to $wl_net -> $masterip
|
---|
40 |
|
---|
41 | # Do NOT allow NAT to the Private Network (3)
|
---|
42 | no nat from $wl_net to $private
|
---|
43 |
|
---|
44 | # Nat the internet for iLeiden functionality (1)
|
---|
45 | nat on $ext_if inet proto tcp from $wl_net to any port { 80,443 } -> ($ext_if)
|
---|
46 |
|
---|
47 | # Nat to the internet for packets which are orginating from itself for proxy functionality (8)
|
---|
48 | nat on !$ext_if inet proto tcp from $wl_net to any port { 80,443 } -> ($ext_if)
|
---|
49 |
|
---|
50 |
|
---|
51 | # Redirection needs source natting and allow rules (see below) (7)
|
---|
52 | rdr on $ext_if inet proto tcp from any to $ext_if port 8081 -> 172.16.4.46 port 80
|
---|
53 |
|
---|
54 | # Redirect user to captive portal they have not clicked OK yet (6)
|
---|
55 | no rdr on { $captive_portal_interfaces } proto tcp from <wlportal> to !$wl_net port 80
|
---|
56 | rdr on { $captive_portal_interfaces } proto tcp from $wl_net to !$wl_net port 80 -> 172.31.255.1 port 8081
|
---|
57 |
|
---|
58 | # Localhost is considered safe (5)
|
---|
59 | pass quick on lo0 all
|
---|
60 |
|
---|
61 | # By default all interfaces are open (5)
|
---|
62 | pass all
|
---|
63 |
|
---|
64 | # This quirck is needed to override the routing table default route (8)
|
---|
65 | pass out on !$ext_if route-to ($ext_if $ext_if_default_route) proto tcp from any to !$wl_net port {22, 80, 443} user != unknown keep state
|
---|
66 | pass out on !$ext_if route-to ($ext_if $ext_if_default_route) proto udp from any to !$wl_net port {53} user != unknown keep state
|
---|
67 |
|
---|
68 | # By default deny all outgoing traffic to avoid systems spamming the network (9)
|
---|
69 | block out on { $captive_portal_interfaces } from any to !$wl_net
|
---|
70 |
|
---|
71 | # Note: not even HTTPS traffic allowed for those who has not clicked OK yet (6)
|
---|
72 | pass out on { $captive_portal_interfaces } proto tcp from <wlportal> to !$wl_net port { 80, 443 } keep state
|
---|
73 |
|
---|
74 | # External interface is permissive (4)
|
---|
75 | block on $ext_if
|
---|
76 |
|
---|
77 | # Expose some local services (4)
|
---|
78 | pass in on $ext_if inet proto tcp from any to $ext_if port $allow_ext_tcp keep state
|
---|
79 | pass in on $ext_if inet proto udp from any to $ext_if port $allow_ext_udp keep state
|
---|
80 | pass in on $ext_if inet proto icmp from any to $ext_if icmp-type { echoreq }
|
---|
81 |
|
---|
82 | # Packets from the management LAN are allowed in (2)
|
---|
83 | pass in on $ext_if from $private to $wl_net keep state
|
---|
84 |
|
---|
85 | # Allow exposing some WL Services to the inet (7)
|
---|
86 | pass in on $ext_if inet proto tcp from any to $ext_if port { 8081 } keep state
|
---|
87 |
|
---|
88 | # Packets going out are the ones to the internet with an certain limit (1)
|
---|
89 | pass out on $ext_if inet proto tcp from $wl_net to any port { $publicnat } keep state \
|
---|
90 | (max-src-conn-rate 100/10, max-src-conn 10)
|
---|
91 |
|
---|
92 | # For proper functioning allow the local machine to initiate requests outside (4)
|
---|
93 | pass out on $ext_if inet proto udp from $ext_if to any port{domain, 1194} keep state
|
---|
94 | pass out on $ext_if inet proto tcp from $ext_if to any port{http, https, 1194} keep state
|
---|
95 | pass out on $ext_if inet proto icmp from $ext_if to any icmp-type { echoreq }
|
---|
96 |
|
---|
97 | # Do not allow connections to the local MGNT LAN to start (3)
|
---|
98 | block out on $ext_if from any to $private
|
---|
99 |
|
---|
100 | # Limited acess PRIVATE network to allow DHCP/DNS to function (3)
|
---|
101 | pass out on $ext_if inet proto {udp, tcp} from $ext_if to $private port {domain} keep state
|
---|
102 |
|
---|
103 | # Uncomment to allow limited access to MGNT interfaces ON the private network (3)
|
---|
104 | #pass out on $ext_if inet proto tcp from $ext_if to $private port {ssh, http, https} keep state
|
---|
105 |
|
---|