1 1.5 spz # $NetBSD: soho_gw-npf.conf,v 1.5 2013/09/20 17:51:04 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.4 rmind 9 1.1 spz $ext_if = "wm0" 10 1.3 spz $ext_v4 = inet4(wm0) 11 1.3 spz $ext_addrs = { ifnet(wm0) } 12 1.3 spz 13 1.1 spz $int_if = "wm1" 14 1.1 spz 15 1.2 spz # a table to house e.g. block candidates in 16 1.2 spz table <1> type hash file "/usr/share/examples/npf/hashtablefile" 17 1.2 spz # feed this using "npfctl table 2 add 198.51.100.16/29" f.e. 18 1.1 spz table <2> type tree dynamic 19 1.1 spz 20 1.1 spz $services_tcp = { http, https, smtp, domain, 6000, 9022 } 21 1.1 spz $services_udp = { domain, ntp, 6000 } 22 1.1 spz $localnet = { 198.51.100.0/24 } 23 1.1 spz 24 1.1 spz # NAT outgoing to the address of the external interface 25 1.1 spz # Note: if $ext_if has multiple IP addresses (e.g. IPv6 as well), 26 1.1 spz # then the translation address has to be specified explicitly. 27 1.3 spz map $ext_if dynamic 198.51.100.0/24 -> $ext_v4 28 1.1 spz 29 1.1 spz # NAT traffic arriving on port 9022 of the external interface address 30 1.1 spz # to host 198.51.100.2 port 22 31 1.4 rmind map $ext_if dynamic 198.51.100.2 port 22 <- $ext_v4 port 9022 32 1.1 spz 33 1.1 spz procedure "log" { 34 1.1 spz log: npflog0 35 1.1 spz } 36 1.1 spz 37 1.5 spz group "external" on $ext_if { 38 1.4 rmind pass stateful out final all 39 1.1 spz 40 1.1 spz block in final from <1> 41 1.3 spz pass stateful in final family inet proto tcp to $ext_v4 port ssh \ 42 1.1 spz apply "log" 43 1.3 spz pass stateful in final proto tcp to $ext_addrs port $services_tcp 44 1.3 spz pass stateful in final proto udp to $ext_addrs port $services_udp 45 1.1 spz 46 1.1 spz # Passive FTP 47 1.3 spz pass stateful in final proto tcp to $ext_addrs port 49151-65535 48 1.1 spz # Traceroute 49 1.3 spz pass stateful in final proto udp to $ext_addrs port 33434-33600 50 1.1 spz } 51 1.1 spz 52 1.5 spz group "internal" on $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.5 spz group default { 59 1.1 spz pass final on lo0 all 60 1.1 spz block all 61 1.1 spz } 62