1 1.1 christos # ex0 - (internal) network interface 2 1.1 christos # 192.168.2.254/24 3 1.1 christos # hme0 - (external) connection to Two Sigma 4 1.1 christos # 74.66.0.142/24 5 1.1 christos 6 1.1 christos $int_if = "sk0" 7 1.1 christos $ext_if = "bge0" 8 1.1 christos 9 1.1 christos alg "icmp" 10 1.1 christos 11 1.1 christos # 12 1.1 christos # NAT for all. 13 1.1 christos # 14 1.1 christos map $ext_if dynamic 192.168.1.0/24 -> inet4($ext_if) 15 1.1 christos 16 1.1 christos #table <1> type tree file "/etc/npf_problem_sites" 17 1.1 christos 18 1.1 christos procedure "log" { 19 1.1 christos log: npflog0 20 1.1 christos } 21 1.1 christos 22 1.2 spz group "external" on $ext_if { 23 1.1 christos # 24 1.1 christos # Allow DHCP requests (even to reserved addresses). 25 1.1 christos # 26 1.1 christos pass out final proto udp from any port bootpc to any port bootps 27 1.1 christos pass in final proto udp from any port bootps to any port bootpc 28 1.1 christos pass in final proto udp from any port bootps to 255.255.255.255 port bootpc 29 1.1 christos # 30 1.1 christos # Allow DNS queries 31 1.1 christos # 32 1.1 christos pass stateful out final proto udp to any port domain 33 1.1 christos 34 1.1 christos # Problem sites. 35 1.1 christos #block in final from <1> apply "log" 36 1.1 christos 37 1.1 christos # 38 1.1 christos # Block IANA-reserved addresses from entering or exiting 39 1.1 christos # 40 1.1 christos block in final from 10.0.0.0/8 apply "log" 41 1.1 christos block in final from 172.16.0.0/12 apply "log" 42 1.1 christos block in final from 192.168.0.0/16 apply "log" 43 1.1 christos # 44 1.1 christos block out final to 10.0.0.0/8 apply "log" 45 1.1 christos block out final to 172.16.0.0/12 apply "log" 46 1.1 christos block out final to 192.168.0.0/16 apply "log" 47 1.1 christos # 48 1.1 christos pass stateful out final proto tcp all 49 1.1 christos pass stateful out final proto udp all 50 1.1 christos pass stateful out final proto icmp all 51 1.1 christos pass stateful out final proto ipv6-icmp all 52 1.1 christos 53 1.1 christos block in final proto tcp to 192.168.2.255 apply "log" 54 1.1 christos 55 1.1 christos # 56 1.1 christos # Prevent IP spoofing attacks on the firewall. 57 1.1 christos # 58 1.1 christos block in final from 127.0.0.1 apply "log" 59 1.1 christos 60 1.1 christos # 61 1.1 christos # L2TP/IPSEC-NAT-T Tunnels. 62 1.1 christos # 63 1.3 christos pass stateful in final from any to inet4($ext_if) port "ipsec-nat-t" 64 1.3 christos pass stateful in final from any to inet4($ext_if) port l2tp 65 1.1 christos 66 1.1 christos # 67 1.1 christos # Pass multicast. 68 1.1 christos # IGMP uses 224.0.0.1. 69 1.1 christos # 70 1.1 christos pass in final proto igmp all 71 1.1 christos pass in final from any to 224.0.0.0/4 72 1.1 christos 73 1.1 christos # 74 1.1 christos # Pass established connections. 75 1.1 christos # 76 1.1 christos pass in final proto tcp flags A/A all 77 1.1 christos pass in final proto tcp flags R/R all 78 1.1 christos # 79 1.1 christos # VNC 80 1.1 christos # 81 1.1 christos pass in final proto tcp from any to any port 5500 82 1.1 christos 83 1.1 christos # 84 1.1 christos # Web servers 85 1.1 christos # 86 1.1 christos #pass in final proto tcp from any to <A>/<M> port http 87 1.1 christos 88 1.1 christos # 89 1.1 christos # Services on localhost. 90 1.1 christos # 91 1.1 christos #pass in final proto udp from any port ntp 92 1.1 christos #pass in final to any port imap 93 1.1 christos #pass in final to any port domain 94 1.1 christos #pass in final proto tcp to any port smtp 95 1.1 christos #pass in final proto tcp to any port auth 96 1.1 christos #pass in final proto tcp to any port ssh 97 1.1 christos #pass in final proto tcp to any port bgp 98 1.1 christos #pass in final proto tcp to any port ftp 99 1.1 christos #pass in final proto tcp to any port "ftp-data" 100 1.1 christos #pass in final proto udp to any port isakmp 101 1.1 christos #pass in final proto udp to any port 8001 102 1.1 christos #pass in final proto tcp to inet4($ext_if) port www 103 1.1 christos 104 1.1 christos # 105 1.1 christos # Handle traceroute gracefully for up-to 30 hops away. 106 1.1 christos # FIXME: port-unr for ICMP is not yet supported. 107 1.1 christos # 108 1.1 christos block return-icmp in final proto udp to any port 33433-33524 apply "log" 109 1.1 christos 110 1.1 christos # 111 1.1 christos # Only allow selected ICMP types. 112 1.1 christos # 113 1.1 christos pass in final proto icmp icmp-type echo all 114 1.1 christos pass in final proto icmp icmp-type timxceed all 115 1.1 christos pass in final proto icmp icmp-type unreach all 116 1.1 christos pass in final proto icmp icmp-type echoreply all 117 1.1 christos pass in final proto icmp icmp-type sourcequench all 118 1.1 christos pass in final proto icmp icmp-type paramprob all 119 1.1 christos pass in final proto ipv6-icmp all 120 1.1 christos 121 1.1 christos # 122 1.1 christos # Send back a reset for new connections on tcp. 123 1.1 christos # 124 1.1 christos block return-rst in final proto tcp flags S/SA all apply "log" 125 1.1 christos } 126 1.1 christos 127 1.2 spz group "internal" on $int_if { 128 1.1 christos # Pass everything to internal networks, 129 1.1 christos # should be ok, because we are nat'ed. 130 1.1 christos pass final all 131 1.1 christos } 132 1.1 christos 133 1.2 spz group default { 134 1.1 christos # Loopback interface should allows packets to traverse it. 135 1.1 christos pass final on lo0 all 136 1.1 christos # For one L2TP tunnel, needs interface pre-created, post-destroyed 137 1.1 christos pass final on ppp0 all 138 1.1 christos 139 1.1 christos # 140 1.1 christos # Block everything by default. 141 1.1 christos # 142 1.1 christos block final all apply "log" 143 1.1 christos } 144