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