source: hybrid/branches/releng-9.0/nanobsd/files/etc/pf.proxy.conf@ 10694

Last change on this file since 10694 was 10610, checked in by rick, 13 years ago

Makes variables and templates much cleaner allowing easy edits and mutations.
Stop hiding logic at duplicate places.

Related-To: nodefactory#129

File size: 5.1 KB
RevLine 
[10446]1#
[10580]2# Wireless Leiden PF firewall configuration for (iLeiden) Proxy Setup.
[10446]3#
[10580]4# N.B: The features points are shared between all firewall configurations to
5# make comparisions more easy to do
6#
[10446]7# 1) It supports outgoing NAT to specified ports. The so called iLeiden setup.
8# 2) It supports incoming NAT from the private MGMT network, for maintenance use.
9# 3) It protects the private MGMT network from WL requests to it's own services.
10# 4) It portects the $ext_if by only allowing an subset of services.
11# 5) The Wireless Leiden facing interfaces are not firewalled.
[10448]12# 6) WL Captive Portal Support for interfaces who needs it.
13# 7) Optional: Exposure of WL services to the outside
[10578]14# 8) Overrides default route for local orginating traffic to specific ports, needed for
15# for normal proxy setup, which should NOT follow the iLeiden default route.
[10579]16# 9) Protect the Wireless Network from junk traffic.
[10580]17#
18# Rick van der Zwet <rick@wirelessleiden.nl>
19#
[10446]20
[10610]21# Standard port allow listings
22allow_ext_in_tcp="ssh, domain"
23allow_ext_in_udp="domain, snmp"
[10448]24
[10610]25allow_ext_out_tcp = "domain, http, https, 1194"
26allow_ext_out_udp = "domain, ntp, 1194"
27
[10448]28# Default configuration for ALIX2 with vr0 as external interface and wlan0 as
29# the public accesspoint in iLeiden setup.
30ext_if="vr0"
[10523]31ext_if_net="vr0:network"
[10589]32ext_if_gw="127.127.127.127"
[10448]33captive_portal_interfaces="wlan0"
[10610]34#publicnat="http,https"
[10520]35masterip="127.0.0.1"
[10448]36# For an traditional proxy setup set, uncomment:
[10610]37publicnat=0
[10448]38
[10610]39# Global standards. NOT to be edited.
40wl_net="172.16.0.0/12"
41private="{ 10.0.0.0/8, 172.16.0.0/12 192.168.0.0/16 }"
42ileiden_ports="http,https"
43
44
[10446]45# Always be nice, and return the fact we are blocking the packets
46set block-policy return
47
[10448]48# Table used to authorized hosts (6)
49table <wlportal> persist counters
50
[10446]51# NAT MGMT to Wireless Leiden (2)
[10523]52nat on ! $ext_if from $ext_if_net to $wl_net -> $masterip
[10446]53
54# Do NOT allow NAT to the Private Network (3)
[10578]55no nat from $wl_net to $private
[10446]56
[10578]57# Nat the internet for iLeiden functionality (1)
[10610]58nat on $ext_if inet proto tcp from $wl_net to any port { $publicnat } -> ($ext_if)
[10578]59
60# Nat to the internet for packets which are orginating from itself for proxy functionality (8)
[10610]61nat on !$ext_if inet proto tcp from $wl_net to any port { $allow_ext_out_tcp } -> ($ext_if)
62nat on !$ext_if inet proto udp from $wl_net to any port { $allow_ext_out_udp } -> ($ext_if)
[10578]63
[10580]64# Redirect some internal facing services outside, please mind also need allow rules (bottom of file) (7)
[10610]65rdr on $ext_if inet proto tcp from any to $ext_if port 8081 -> 172.16.4.46 port http
[10448]66
67# Redirect user to captive portal they have not clicked OK yet (6)
[10610]68no rdr on { $captive_portal_interfaces } proto tcp from <wlportal> to !$wl_net port http
69rdr on { $captive_portal_interfaces } proto tcp from $wl_net to !$wl_net port http -> 172.31.255.1 port 8081
[10448]70
[10446]71# Localhost is considered safe (5)
72pass quick on lo0 all
73
74# By default all interfaces are open (5)
75pass all
76
[10578]77# This quirck is needed to override the routing table default route (8)
[10610]78pass out on !$ext_if route-to ($ext_if $ext_if_gw) proto tcp from any to !$wl_net port { $allow_ext_out_tcp } user != unknown keep state
79pass out on !$ext_if route-to ($ext_if $ext_if_gw) proto udp from any to !$wl_net port { $allow_ext_out_udp } user != unknown keep state
[10578]80
[10579]81# By default deny all outgoing traffic to avoid systems spamming the network (9)
82block out on { $captive_portal_interfaces } from any to !$wl_net
83
84# Note: not even HTTPS traffic allowed for those who has not clicked OK yet (6)
[10580]85pass out on { $captive_portal_interfaces } proto tcp from <wlportal> to !$wl_net port { $ileiden_ports } keep state
[10579]86
[10446]87# External interface is permissive (4)
88block on $ext_if
89
90# Expose some local services (4)
[10610]91pass in on $ext_if inet proto tcp from any to $ext_if port { $allow_ext_in_tcp } keep state
92pass in on $ext_if inet proto udp from any to $ext_if port { $allow_ext_in_udp } keep state
[10446]93pass in on $ext_if inet proto icmp from any to $ext_if icmp-type { echoreq }
94
95# Packets from the management LAN are allowed in (2)
96pass in on $ext_if from $private to $wl_net keep state
97
[10610]98# Allow exposing some (internal) WL Services to the inet - see rdr on top as well (7)
[10448]99pass in on $ext_if inet proto tcp from any to $ext_if port { 8081 } keep state
100
[10446]101# Packets going out are the ones to the internet with an certain limit (1)
102pass out on $ext_if inet proto tcp from $wl_net to any port { $publicnat } keep state \
103 (max-src-conn-rate 100/10, max-src-conn 10)
104
105# For proper functioning allow the local machine to initiate requests outside (4)
[10610]106pass out on $ext_if inet proto tcp from $ext_if to any port { $allow_ext_out_tcp } keep state
107pass out on $ext_if inet proto udp from $ext_if to any port { $allow_ext_out_udp } keep state
[10446]108pass out on $ext_if inet proto icmp from $ext_if to any icmp-type { echoreq }
109
110# Do not allow connections to the local MGNT LAN to start (3)
111block out on $ext_if from any to $private
112
113# Limited acess PRIVATE network to allow DHCP/DNS to function (3)
114pass out on $ext_if inet proto {udp, tcp} from $ext_if to $private port {domain} keep state
115
116# Uncomment to allow limited access to MGNT interfaces ON the private network (3)
117#pass out on $ext_if inet proto tcp from $ext_if to $private port {ssh, http, https} keep state
118
Note: See TracBrowser for help on using the repository browser.