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