Home | History | Annotate | Line # | Download | only in npf
soho_gw-npf.conf revision 1.2
      1  1.2  spz # $NetBSD: soho_gw-npf.conf,v 1.2 2012/08/21 08:25:21 spz Exp $
      2  1.1  spz #
      3  1.1  spz # SOHO border
      4  1.1  spz #
      5  1.1  spz # This is a natting border gateway/webserver/mailserver/nameserver
      6  1.2  spz # IPv4 only
      7  1.1  spz #
      8  1.1  spz $ext_if = "wm0"
      9  1.1  spz $int_if = "wm1"
     10  1.1  spz 
     11  1.2  spz # a table to house e.g. block candidates in
     12  1.2  spz table <1> type hash file "/usr/share/examples/npf/hashtablefile"
     13  1.2  spz # feed this using "npfctl table 2 add 198.51.100.16/29" f.e.
     14  1.1  spz table <2> type tree dynamic
     15  1.1  spz 
     16  1.1  spz $services_tcp = { http, https, smtp, domain, 6000, 9022 }
     17  1.1  spz $services_udp = { domain, ntp, 6000 }
     18  1.1  spz $localnet = { 198.51.100.0/24 }
     19  1.1  spz 
     20  1.1  spz # NAT outgoing to the address of the external interface
     21  1.1  spz # Note: if $ext_if has multiple IP addresses (e.g. IPv6 as well),
     22  1.1  spz # then the translation address has to be specified explicitly.
     23  1.1  spz map $ext_if dynamic 198.51.100.0/24 -> $ext_if
     24  1.1  spz 
     25  1.1  spz # NAT traffic arriving on port 9022 of the external interface address
     26  1.1  spz # to host 198.51.100.2 port 22
     27  1.1  spz map $ext_if dynamic 198.51.100.2 port 22 <- $ext_if 9022
     28  1.1  spz 
     29  1.1  spz procedure "log" {
     30  1.1  spz 	log: npflog0
     31  1.1  spz }
     32  1.1  spz 
     33  1.1  spz procedure "rid" {
     34  1.1  spz 	normalise: "random-id"
     35  1.1  spz }
     36  1.1  spz 
     37  1.1  spz group (name "external", interface $ext_if) {
     38  1.1  spz 	pass stateful out final from $ext_if apply "rid"
     39  1.1  spz 
     40  1.1  spz 	block in final from <1>
     41  1.1  spz 	pass stateful in final family inet proto tcp to $ext_if port ssh \
     42  1.1  spz 		apply "log"
     43  1.1  spz 	pass stateful in final proto tcp to $ext_if port $services_tcp
     44  1.1  spz 	pass stateful in final proto udp to $ext_if port $services_udp
     45  1.1  spz 
     46  1.1  spz 	# Passive FTP
     47  1.1  spz 	pass stateful in final proto tcp to $ext_if port 49151-65535
     48  1.1  spz 	# Traceroute
     49  1.1  spz 	pass stateful in final proto udp to $ext_if port 33434-33600
     50  1.1  spz }
     51  1.1  spz 
     52  1.1  spz group (name "internal", interface $int_if) {
     53  1.1  spz 	block in all
     54  1.1  spz 	pass in final from <2>
     55  1.1  spz 	pass out final all
     56  1.1  spz }
     57  1.1  spz 
     58  1.1  spz group (default) {
     59  1.1  spz 	pass final on lo0 all
     60  1.1  spz 	block all
     61  1.1  spz }
     62  1.1  spz 
     63