source: hybrid/branches/releng-11/nanobsd/files/etc/pf.hybrid.conf@ 14358

Last change on this file since 14358 was 14135, checked in by rick, 7 years ago

Add inbound NAT functionality for MGMT purposes

Removed in r13700, yet re-added since proven to be usefull at some locations (Rustdam, Huub)

File size: 5.7 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.
[14135]8# 2) It supports incoming NAT from the private MGMT network, for maintenance use.
[10446]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
[10579]14# 9) Protect the Wireless Network from junk traffic.
[10580]15#
16# Rick van der Zwet <rick@wirelessleiden.nl>
17#
[10446]18
[13160]19# Standard port allow listings for external services
[13700]20allow_ext_in_tcp="1022"
[10448]21
[14135]22# Standard port allow listings for services at host network (in case of NAT)
23allow_private_in_tcp="domain"
24allow_private_in_udp="domain"
25
[13700]26allow_ext_out_tcp = "domain, http, https"
27allow_ext_out_udp = "domain, ntp"
[13160]28
[10610]29
[10448]30# Default configuration for ALIX2 with vr0 as external interface and wlan0 as
[13233]31# the public accesspoint in iLeiden setup, aliases on external interface OK.
[11543]32ext_if="vr0"
[14068]33ext_if="vr0"
[10448]34captive_portal_interfaces="wlan0"
35publicnat="http,https"
[10520]36masterip="127.0.0.1"
[10589]37# For an traditional proxy setup set (no iLeiden clients!), uncomment:
[10448]38#publicnat=0
39
[10610]40# Global standards. NOT to be edited.
41wl_net="172.16.0.0/12"
[10842]42private="{ 10.0.0.0/8, 192.168.0.0/16 }"
[10610]43ileiden_ports="http,https"
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
[14135]51# NAT MGMT to Wireless Leiden (2)
52nat on ! $ext_if from $private to $wl_net -> $masterip
53
[10446]54# Do NOT allow NAT to the Private Network (3)
[10578]55no nat from $wl_net to $private
[10446]56
[13233]57# Nat the internet for iLeiden functionality allow for alias on vr0 (1)
[14068]58nat on $ext_if inet proto tcp from $wl_net to ! $wl_net port { $publicnat } -> ($ext_if:0)
[10578]59
[10448]60
61# Redirect user to captive portal they have not clicked OK yet (6)
[10610]62no rdr on { $captive_portal_interfaces } proto tcp from <wlportal> to !$wl_net port http
63rdr on { $captive_portal_interfaces } proto tcp from $wl_net to !$wl_net port http -> 172.31.255.1 port 8081
[10448]64
[10704]65# Load autogenerated entries, like the remote mappings (7)
66include "/etc/pf.hybrid.conf.local"
[10694]67
68# Make the device on WL find the proper gateway back (7)
69nat on ! $ext_if inet from any to $wl_net tagged SRV -> $masterip
70
71# Special allow rules for inbound piercing (7)
72pass in quick on $ext_if inet tagged SRV keep state
73
[10446]74# Localhost is considered safe (5)
75pass quick on lo0 all
76
77# By default all interfaces are open (5)
78pass all
79
[10579]80# By default deny all outgoing traffic to avoid systems spamming the network (9)
[13772]81block in on { $captive_portal_interfaces } from any to !$wl_net
[10579]82
[13772]83# Quickly drop out, with nice return value, avoiding endless connections on portal setup (6)
84block return in quick on { $captive_portal_interfaces } proto tcp from !<wlportal> to !$wl_net port { $publicnat }
85
[10579]86# Note: not even HTTPS traffic allowed for those who has not clicked OK yet (6)
[13772]87pass in on { $captive_portal_interfaces } proto tcp from <wlportal> to !$wl_net port { $publicnat } keep state
[10579]88
[10446]89# External interface is permissive (4)
[10997]90block on $ext_if inet from any to !$wl_net
[10446]91
[10842]92# Allow internal WL traffic on alias $ext_if interfaces (5)
93pass in quick on $ext_if from $wl_net to $wl_net
94pass out quick on $ext_if from $wl_net to $wl_net
95
[14135]96# Expose some local services for internal (NATted) network (4)
97pass in on $ext_if inet proto tcp from $private to $ext_if port { $allow_private_in_tcp } keep state
98pass in on $ext_if inet proto udp from $private to $ext_if port { $allow_private_in_udp } keep state
99pass in on $ext_if inet proto icmp from $private to $ext_if icmp-type { echoreq }
100
[13160]101# Expose some local services for the external world (WWW) network (4)
[10610]102pass in on $ext_if inet proto tcp from any to $ext_if port { $allow_ext_in_tcp } keep state
[10446]103pass in on $ext_if inet proto icmp from any to $ext_if icmp-type { echoreq }
104
[14135]105# Packets from the management LAN are allowed in (2)
106pass in on $ext_if from $private to $wl_net keep state
107
[10446]108# Packets going out are the ones to the internet with an certain limit (1)
[14071]109pass on $ext_if inet proto tcp from $wl_net to !$wl_net port { $publicnat } keep state \
[10446]110 (max-src-conn-rate 100/10, max-src-conn 10)
111
112# For proper functioning allow the local machine to initiate requests outside (4)
[10610]113pass out on $ext_if inet proto udp from $ext_if to any port { $allow_ext_out_udp } keep state
114pass out on $ext_if inet proto tcp from $ext_if to any port { $allow_ext_out_tcp } keep state
[11543]115pass out on $ext_if inet proto icmp from $ext_if to any icmp-type { echoreq, trace }
[10446]116
[11543]117# For proper functioning allow the local machine to initiate requests outside + vpn (4)
[14068]118pass out on $ext_if inet proto udp from $ext_if to any port { $allow_ext_out_udp } keep state
119pass out on $ext_if inet proto tcp from $ext_if to any port { $allow_ext_out_tcp } keep state
120pass out on $ext_if inet proto icmp from $ext_if to any icmp-type { echoreq, trace }
[11543]121
122# Uncomment to UDP traceroute from this host to start
123#pass out on $ext_if inet proto udp from $ext_if to any port 33434 >< 33464 keep state
124
[10446]125# Do not allow connections to the local MGNT LAN to start (3)
126block out on $ext_if from any to $private
127
128# Limited acess PRIVATE network to allow DHCP/DNS to function (3)
129pass out on $ext_if inet proto {udp, tcp} from $ext_if to $private port {domain} keep state
130
131# Uncomment to allow limited access to MGNT interfaces ON the private network (3)
132#pass out on $ext_if inet proto tcp from $ext_if to $private port {ssh, http, https} keep state
[14070]133#pass out on $ext_if inet proto icmp from $ext_if to $private icmp-type { echoreq, trace }
Note: See TracBrowser for help on using the repository browser.