[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 | # 3) It protects the private MGMT network from WL requests to it's own services.
|
---|
| 9 | # 4) It portects the $ext_if by only allowing an subset of services.
|
---|
| 10 | # 5) The Wireless Leiden facing interfaces are not firewalled.
|
---|
[10448] | 11 | # 6) WL Captive Portal Support for interfaces who needs it.
|
---|
| 12 | # 7) Optional: Exposure of WL services to the outside
|
---|
[10579] | 13 | # 9) Protect the Wireless Network from junk traffic.
|
---|
[10580] | 14 | #
|
---|
| 15 | # Rick van der Zwet <rick@wirelessleiden.nl>
|
---|
| 16 | #
|
---|
[10446] | 17 |
|
---|
[13160] | 18 | # Standard port allow listings for external services
|
---|
[13700] | 19 | allow_ext_in_tcp="1022"
|
---|
| 20 | allow_ext_in_udp=""
|
---|
[10448] | 21 |
|
---|
[13700] | 22 | allow_ext_out_tcp = "domain, http, https"
|
---|
| 23 | allow_ext_out_udp = "domain, ntp"
|
---|
[13160] | 24 |
|
---|
[10610] | 25 |
|
---|
[10448] | 26 | # Default configuration for ALIX2 with vr0 as external interface and wlan0 as
|
---|
[13233] | 27 | # the public accesspoint in iLeiden setup, aliases on external interface OK.
|
---|
[11543] | 28 | ext_if="vr0"
|
---|
| 29 | inet_if="vr0"
|
---|
[10448] | 30 | captive_portal_interfaces="wlan0"
|
---|
| 31 | publicnat="http,https"
|
---|
[10520] | 32 | masterip="127.0.0.1"
|
---|
[10589] | 33 | # For an traditional proxy setup set (no iLeiden clients!), uncomment:
|
---|
[10448] | 34 | #publicnat=0
|
---|
| 35 |
|
---|
[10610] | 36 | # Global standards. NOT to be edited.
|
---|
| 37 | wl_net="172.16.0.0/12"
|
---|
[10842] | 38 | private="{ 10.0.0.0/8, 192.168.0.0/16 }"
|
---|
[10610] | 39 | ileiden_ports="http,https"
|
---|
| 40 |
|
---|
[10446] | 41 | # Always be nice, and return the fact we are blocking the packets
|
---|
| 42 | set block-policy return
|
---|
| 43 |
|
---|
[10448] | 44 | # Table used to authorized hosts (6)
|
---|
| 45 | table <wlportal> persist counters
|
---|
| 46 |
|
---|
[10446] | 47 | # Do NOT allow NAT to the Private Network (3)
|
---|
[10578] | 48 | no nat from $wl_net to $private
|
---|
[10446] | 49 |
|
---|
[13233] | 50 | # Nat the internet for iLeiden functionality allow for alias on vr0 (1)
|
---|
[13694] | 51 | nat on $inet_if inet proto tcp from $wl_net to ! $wl_net port { $publicnat } -> ($inet_if:0)
|
---|
[10578] | 52 |
|
---|
[10448] | 53 |
|
---|
| 54 | # Redirect user to captive portal they have not clicked OK yet (6)
|
---|
[10610] | 55 | no rdr on { $captive_portal_interfaces } proto tcp from <wlportal> to !$wl_net port http
|
---|
| 56 | rdr on { $captive_portal_interfaces } proto tcp from $wl_net to !$wl_net port http -> 172.31.255.1 port 8081
|
---|
[10448] | 57 |
|
---|
[10704] | 58 | # Load autogenerated entries, like the remote mappings (7)
|
---|
| 59 | include "/etc/pf.hybrid.conf.local"
|
---|
[10694] | 60 |
|
---|
| 61 | # Make the device on WL find the proper gateway back (7)
|
---|
| 62 | nat on ! $ext_if inet from any to $wl_net tagged SRV -> $masterip
|
---|
| 63 |
|
---|
| 64 | # Special allow rules for inbound piercing (7)
|
---|
| 65 | pass in quick on $ext_if inet tagged SRV keep state
|
---|
| 66 |
|
---|
[10446] | 67 | # Localhost is considered safe (5)
|
---|
| 68 | pass quick on lo0 all
|
---|
| 69 |
|
---|
| 70 | # By default all interfaces are open (5)
|
---|
| 71 | pass all
|
---|
| 72 |
|
---|
[10579] | 73 | # By default deny all outgoing traffic to avoid systems spamming the network (9)
|
---|
| 74 | block out on { $captive_portal_interfaces } from any to !$wl_net
|
---|
| 75 |
|
---|
| 76 | # Note: not even HTTPS traffic allowed for those who has not clicked OK yet (6)
|
---|
[10610] | 77 | pass out on { $captive_portal_interfaces } proto tcp from <wlportal> to !$wl_net port { $publicnat } keep state
|
---|
[10579] | 78 |
|
---|
[10446] | 79 | # External interface is permissive (4)
|
---|
[10997] | 80 | block on $ext_if inet from any to !$wl_net
|
---|
[11543] | 81 | block on $inet_if inet from any to !$wl_net
|
---|
[10446] | 82 |
|
---|
[10842] | 83 | # Allow internal WL traffic on alias $ext_if interfaces (5)
|
---|
| 84 | pass in quick on $ext_if from $wl_net to $wl_net
|
---|
| 85 | pass out quick on $ext_if from $wl_net to $wl_net
|
---|
| 86 |
|
---|
[13160] | 87 | # Expose some local services for the external world (WWW) network (4)
|
---|
[10610] | 88 | pass in on $ext_if inet proto tcp from any to $ext_if port { $allow_ext_in_tcp } keep state
|
---|
| 89 | pass in on $ext_if inet proto udp from any to $ext_if port { $allow_ext_in_udp } keep state
|
---|
[10446] | 90 | pass in on $ext_if inet proto icmp from any to $ext_if icmp-type { echoreq }
|
---|
| 91 |
|
---|
| 92 | # Packets going out are the ones to the internet with an certain limit (1)
|
---|
[11543] | 93 | pass out on $inet_if inet proto tcp from $wl_net to any port { $publicnat } keep state \
|
---|
[10446] | 94 | (max-src-conn-rate 100/10, max-src-conn 10)
|
---|
| 95 |
|
---|
| 96 | # For proper functioning allow the local machine to initiate requests outside (4)
|
---|
[10610] | 97 | pass out on $ext_if inet proto udp from $ext_if to any port { $allow_ext_out_udp } keep state
|
---|
| 98 | pass out on $ext_if inet proto tcp from $ext_if to any port { $allow_ext_out_tcp } keep state
|
---|
[11543] | 99 | pass out on $ext_if inet proto icmp from $ext_if to any icmp-type { echoreq, trace }
|
---|
[10446] | 100 |
|
---|
[11543] | 101 | # For proper functioning allow the local machine to initiate requests outside + vpn (4)
|
---|
| 102 | pass out on $inet_if inet proto udp from $inet_if to any port { $allow_ext_out_udp } keep state
|
---|
| 103 | pass out on $inet_if inet proto tcp from $inet_if to any port { $allow_ext_out_tcp } keep state
|
---|
| 104 | pass out on $inet_if inet proto icmp from $inet_if to any icmp-type { echoreq, trace }
|
---|
| 105 |
|
---|
| 106 | # Uncomment to UDP traceroute from this host to start
|
---|
| 107 | #pass out on $ext_if inet proto udp from $ext_if to any port 33434 >< 33464 keep state
|
---|
| 108 | #pass out on $inet_if inet proto udp from $inet_if to any port 33434 >< 33464 keep state
|
---|
| 109 |
|
---|
[10446] | 110 | # Do not allow connections to the local MGNT LAN to start (3)
|
---|
| 111 | block out on $ext_if from any to $private
|
---|
| 112 |
|
---|
| 113 | # Limited acess PRIVATE network to allow DHCP/DNS to function (3)
|
---|
| 114 | pass 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 |
|
---|