xref: /freebsd/contrib/pf/authpf/authpf.8 (revision 1a720cbec513210fa2e85c3882741ef2f6dc5f35)
111d15d51SMax Laier.\" $FreeBSD$
2e0bfbfceSBjoern A. Zeeb.\" $OpenBSD: authpf.8,v 1.47 2009/01/06 03:11:50 mcbride Exp $
313b9f610SMax Laier.\"
45ee7cd21SMax Laier.\" Copyright (c) 1998-2007 Bob Beck (beck@openbsd.org>.  All rights reserved.
513b9f610SMax Laier.\"
65ee7cd21SMax Laier.\" Permission to use, copy, modify, and distribute this software for any
75ee7cd21SMax Laier.\" purpose with or without fee is hereby granted, provided that the above
85ee7cd21SMax Laier.\" copyright notice and this permission notice appear in all copies.
913b9f610SMax Laier.\"
105ee7cd21SMax Laier.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
115ee7cd21SMax Laier.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
125ee7cd21SMax Laier.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
135ee7cd21SMax Laier.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
145ee7cd21SMax Laier.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
155ee7cd21SMax Laier.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
165ee7cd21SMax Laier.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1713b9f610SMax Laier.\"
18a24f107bSSergey Kandaurov.Dd January 29 2014
1913b9f610SMax Laier.Dt AUTHPF 8
2013b9f610SMax Laier.Os
2113b9f610SMax Laier.Sh NAME
22e0bfbfceSBjoern A. Zeeb.Nm authpf ,
23e0bfbfceSBjoern A. Zeeb.Nm authpf-noip
2413b9f610SMax Laier.Nd authenticating gateway user shell
2513b9f610SMax Laier.Sh SYNOPSIS
2613b9f610SMax Laier.Nm authpf
27e0bfbfceSBjoern A. Zeeb.Nm authpf-noip
2813b9f610SMax Laier.Sh DESCRIPTION
2913b9f610SMax Laier.Nm
3013b9f610SMax Laieris a user shell for authenticating gateways.
3113b9f610SMax LaierIt is used to change
3213b9f610SMax Laier.Xr pf 4
3313b9f610SMax Laierrules when a user authenticates and starts a session with
3413b9f610SMax Laier.Xr sshd 8
3513b9f610SMax Laierand to undo these changes when the user's session exits.
3613b9f610SMax LaierTypical use would be for a gateway that authenticates users before
3713b9f610SMax Laierallowing them Internet use, or a gateway that allows different users into
3813b9f610SMax Laierdifferent places.
39e0bfbfceSBjoern A. ZeebCombined with properly set up filter rules and secure switches,
4013b9f610SMax Laier.Nm
4113b9f610SMax Laiercan be used to ensure users are held accountable for their network traffic.
42e0bfbfceSBjoern A. ZeebIt is meant to be used with users who can connect via
4313b9f610SMax Laier.Xr ssh 1
44e0bfbfceSBjoern A. Zeebonly, and requires the
45e0bfbfceSBjoern A. Zeeb.Xr pf 4
46a24f107bSSergey Kandaurovsubsystem and an
47*1a720cbeSAlexander Ziaee.Xr fdescfs 4
48a24f107bSSergey Kandaurovfile system mounted at
49a24f107bSSergey Kandaurov.Pa /dev/fd
50a24f107bSSergey Kandaurovto be enabled.
51e0bfbfceSBjoern A. Zeeb.Pp
52e0bfbfceSBjoern A. Zeeb.Nm authpf-noip
53e0bfbfceSBjoern A. Zeebis a user shell
54e0bfbfceSBjoern A. Zeebwhich allows multiple connections to take
55e0bfbfceSBjoern A. Zeebplace from the same IP address.
56e0bfbfceSBjoern A. ZeebIt is useful primarily in cases where connections are tunneled via
57e0bfbfceSBjoern A. Zeebthe gateway system, and can be directly associated with the user name.
58e0bfbfceSBjoern A. ZeebIt cannot ensure accountability when
59e0bfbfceSBjoern A. Zeebclassifying connections by IP address;
60e0bfbfceSBjoern A. Zeebin this case the client's IP address
61e0bfbfceSBjoern A. Zeebis not provided to the packet filter via the
62e0bfbfceSBjoern A. Zeeb.Ar client_ip
63e0bfbfceSBjoern A. Zeebmacro or the
64e0bfbfceSBjoern A. Zeeb.Ar authpf_users
65e0bfbfceSBjoern A. Zeebtable.
66e0bfbfceSBjoern A. ZeebAdditionally, states associated with the client IP address
67e0bfbfceSBjoern A. Zeebare not purged when the session is ended.
68e0bfbfceSBjoern A. Zeeb.Pp
69e0bfbfceSBjoern A. ZeebTo use either
70e0bfbfceSBjoern A. Zeeb.Nm
71e0bfbfceSBjoern A. Zeebor
72e0bfbfceSBjoern A. Zeeb.Nm authpf-noip ,
73e0bfbfceSBjoern A. Zeebthe user's shell needs to be set to
74e0bfbfceSBjoern A. Zeeb.Pa /usr/sbin/authpf
75e0bfbfceSBjoern A. Zeebor
76e0bfbfceSBjoern A. Zeeb.Pa /usr/sbin/authpf-noip .
77e0bfbfceSBjoern A. Zeeb.Pp
78e0bfbfceSBjoern A. Zeeb.Nm
79e0bfbfceSBjoern A. Zeebuses the
80e0bfbfceSBjoern A. Zeeb.Xr pf.conf 5
81e0bfbfceSBjoern A. Zeebsyntax to change filter and translation rules for an individual
82e0bfbfceSBjoern A. Zeebuser or client IP address as long as a user maintains an active
83e0bfbfceSBjoern A. Zeeb.Xr ssh 1
84e0bfbfceSBjoern A. Zeebsession, and logs the successful start and end of a session to
85e0bfbfceSBjoern A. Zeeb.Xr syslogd 8 .
8613b9f610SMax Laier.Nm
8713b9f610SMax Laierretrieves the client's connecting IP address via the
8813b9f610SMax Laier.Ev SSH_CLIENT
8913b9f610SMax Laierenvironment variable and, after performing additional access checks,
9013b9f610SMax Laierreads a template file to determine what filter and translation rules
91e0bfbfceSBjoern A. Zeeb(if any) to add, and
92e0bfbfceSBjoern A. Zeebmaintains the list of IP addresses of connected users in the
93e0bfbfceSBjoern A. Zeeb.Ar authpf_users
94e0bfbfceSBjoern A. Zeebtable.
95e0bfbfceSBjoern A. ZeebOn session exit the same rules and table entries that were added at startup
96e0bfbfceSBjoern A. Zeebare removed, and all states associated with the client's IP address are purged.
9713b9f610SMax Laier.Pp
9813b9f610SMax LaierEach
9913b9f610SMax Laier.Nm
10013b9f610SMax Laierprocess stores its rules in a separate ruleset inside a
10113b9f610SMax Laier.Xr pf 4
10213b9f610SMax Laier.Pa anchor
10313b9f610SMax Laiershared by all
10413b9f610SMax Laier.Nm
10513b9f610SMax Laierprocesses.
10613b9f610SMax LaierBy default, the
10713b9f610SMax Laier.Pa anchor
108abff3868SMax Laiername "authpf" is used, and the ruleset names equal the username and PID of the
10913b9f610SMax Laier.Nm
110abff3868SMax Laierprocesses as "username(pid)".
11113b9f610SMax LaierThe following rules need to be added to the main ruleset
11213b9f610SMax Laier.Pa /etc/pf.conf
11313b9f610SMax Laierin order to cause evaluation of any
11413b9f610SMax Laier.Nm
11513b9f610SMax Laierrules:
11613b9f610SMax Laier.Bd -literal -offset indent
11761a1372bSMax Laiernat-anchor "authpf/*"
11861a1372bSMax Laierrdr-anchor "authpf/*"
11961a1372bSMax Laierbinat-anchor "authpf/*"
12061a1372bSMax Laieranchor "authpf/*"
12113b9f610SMax Laier.Ed
12261a1372bSMax Laier.Pp
12361a1372bSMax LaierThe "/*" at the end of the anchor name is required for
12461a1372bSMax Laier.Xr pf 4
12561a1372bSMax Laierto process the rulesets attached to the anchor by
12661a1372bSMax Laier.Nm authpf .
12713b9f610SMax Laier.Sh FILTER AND TRANSLATION RULES
12813b9f610SMax LaierFilter and translation rules for
12913b9f610SMax Laier.Nm
13013b9f610SMax Laieruse the same format described in
13113b9f610SMax Laier.Xr pf.conf 5 .
13213b9f610SMax LaierThe only difference is that these rules may (and probably should) use
13313b9f610SMax Laierthe macro
13413b9f610SMax Laier.Em user_ip ,
13513b9f610SMax Laierwhich is assigned the connecting IP address whenever
13613b9f610SMax Laier.Nm
13713b9f610SMax Laieris run.
13813b9f610SMax LaierAdditionally, the macro
13913b9f610SMax Laier.Em user_id
14013b9f610SMax Laieris assigned the user name.
14113b9f610SMax Laier.Pp
14261a1372bSMax LaierFilter and translation rules are stored in a file called
14361a1372bSMax Laier.Pa authpf.rules .
14461a1372bSMax LaierThis file will first be searched for in
14513b9f610SMax Laier.Pa /etc/authpf/users/$USER/
14613b9f610SMax Laierand then in
14713b9f610SMax Laier.Pa /etc/authpf/ .
14861a1372bSMax LaierOnly one of these files will be used if both are present.
14961a1372bSMax Laier.Pp
15013b9f610SMax LaierPer-user rules from the
15113b9f610SMax Laier.Pa /etc/authpf/users/$USER/
15213b9f610SMax Laierdirectory are intended to be used when non-default rules
15313b9f610SMax Laierare needed on an individual user basis.
15413b9f610SMax LaierIt is important to ensure that a user can not write or change
15513b9f610SMax Laierthese configuration files.
15613b9f610SMax Laier.Pp
15713b9f610SMax LaierThe
15813b9f610SMax Laier.Pa authpf.rules
15913b9f610SMax Laierfile must exist in one of the above locations for
16013b9f610SMax Laier.Nm
16113b9f610SMax Laierto run.
16213b9f610SMax Laier.Sh CONFIGURATION
16313b9f610SMax LaierOptions are controlled by the
16413b9f610SMax Laier.Pa /etc/authpf/authpf.conf
16513b9f610SMax Laierfile.
16613b9f610SMax LaierIf the file is empty, defaults are used for all
16713b9f610SMax Laierconfiguration options.
16813b9f610SMax LaierThe file consists of pairs of the form
16913b9f610SMax Laier.Li name=value ,
17013b9f610SMax Laierone per line.
17113b9f610SMax LaierCurrently, the allowed values are as follows:
17213b9f610SMax Laier.Bl -tag -width Ds
17313b9f610SMax Laier.It anchor=name
17413b9f610SMax LaierUse the specified
17513b9f610SMax Laier.Pa anchor
17613b9f610SMax Laiername instead of "authpf".
17761a1372bSMax Laier.It table=name
17861a1372bSMax LaierUse the specified
17961a1372bSMax Laier.Pa table
18061a1372bSMax Laiername instead of "authpf_users".
18113b9f610SMax Laier.El
18213b9f610SMax Laier.Sh USER MESSAGES
18313b9f610SMax LaierOn successful invocation,
18413b9f610SMax Laier.Nm
18513b9f610SMax Laierdisplays a message telling the user he or she has been authenticated.
18613b9f610SMax LaierIt will additionally display the contents of the file
18713b9f610SMax Laier.Pa /etc/authpf/authpf.message
18813b9f610SMax Laierif the file exists and is readable.
18913b9f610SMax Laier.Pp
19013b9f610SMax LaierThere exist two methods for providing additional granularity to the control
19113b9f610SMax Laieroffered by
19213b9f610SMax Laier.Nm
19313b9f610SMax Laier- it is possible to set the gateway to explicitly allow users who have
19413b9f610SMax Laierauthenticated to
19513b9f610SMax Laier.Xr ssh 1
19613b9f610SMax Laierand deny access to only a few troublesome individuals.
19713b9f610SMax LaierThis is done by creating a file with the banned user's login name as the
19813b9f610SMax Laierfilename in
19913b9f610SMax Laier.Pa /etc/authpf/banned/ .
20013b9f610SMax LaierThe contents of this file will be displayed to a banned user, thus providing
20113b9f610SMax Laiera method for informing the user that they have been banned, and where they can
20213b9f610SMax Laiergo and how to get there if they want to have their service restored.
20313b9f610SMax LaierThis is the default behaviour.
20413b9f610SMax Laier.Pp
20513b9f610SMax LaierIt is also possible to configure
20613b9f610SMax Laier.Nm
20713b9f610SMax Laierto only allow specific users access.
20813b9f610SMax LaierThis is done by listing their login names, one per line, in
20913b9f610SMax Laier.Pa /etc/authpf/authpf.allow .
210e0bfbfceSBjoern A. ZeebA group of users can also be indicated by prepending "%" to the group name,
211e0bfbfceSBjoern A. Zeeband all members of a login class can be indicated by prepending "@" to the
212e0bfbfceSBjoern A. Zeeblogin class name.
21313b9f610SMax LaierIf "*" is found on a line, then all usernames match.
21413b9f610SMax LaierIf
21513b9f610SMax Laier.Nm
21613b9f610SMax Laieris unable to verify the user's permission to use the gateway, it will
21713b9f610SMax Laierprint a brief message and die.
21813b9f610SMax LaierIt should be noted that a ban takes precedence over an allow.
21913b9f610SMax Laier.Pp
22013b9f610SMax LaierOn failure, messages will be logged to
22113b9f610SMax Laier.Xr syslogd 8
22213b9f610SMax Laierfor the system administrator.
22313b9f610SMax LaierThe user does not see these, but will be told the system is unavailable due to
22413b9f610SMax Laiertechnical difficulties.
22513b9f610SMax LaierThe contents of the file
22613b9f610SMax Laier.Pa /etc/authpf/authpf.problem
22713b9f610SMax Laierwill also be displayed if the file exists and is readable.
22813b9f610SMax Laier.Sh CONFIGURATION ISSUES
22913b9f610SMax Laier.Nm
23013b9f610SMax Laiermaintains the changed filter rules as long as the user maintains an
23113b9f610SMax Laieractive session.
23213b9f610SMax LaierIt is important to remember however, that the existence
23313b9f610SMax Laierof this session means the user is authenticated.
23413b9f610SMax LaierBecause of this, it is important to configure
23513b9f610SMax Laier.Xr sshd 8
23613b9f610SMax Laierto ensure the security of the session, and to ensure that the network
23713b9f610SMax Laierthrough which users connect is secure.
23813b9f610SMax Laier.Xr sshd 8
23913b9f610SMax Laiershould be configured to use the
24013b9f610SMax Laier.Ar ClientAliveInterval
24113b9f610SMax Laierand
24213b9f610SMax Laier.Ar ClientAliveCountMax
24313b9f610SMax Laierparameters to ensure that a ssh session is terminated quickly if
24413b9f610SMax Laierit becomes unresponsive, or if arp or address spoofing is used to
24513b9f610SMax Laierhijack the session.
24613b9f610SMax LaierNote that TCP keepalives are not sufficient for
24713b9f610SMax Laierthis, since they are not secure.
2485ee7cd21SMax LaierAlso note that the various SSH tunnelling mechanisms,
2495ee7cd21SMax Laiersuch as
25061a1372bSMax Laier.Ar AllowTcpForwarding
2515ee7cd21SMax Laierand
2525ee7cd21SMax Laier.Ar PermitTunnel ,
25361a1372bSMax Laiershould be disabled for
25461a1372bSMax Laier.Nm
25561a1372bSMax Laierusers to prevent them from circumventing restrictions imposed by the
25661a1372bSMax Laierpacket filter ruleset.
25713b9f610SMax Laier.Pp
25813b9f610SMax Laier.Nm
25913b9f610SMax Laierwill remove state table entries that were created during a user's
26013b9f610SMax Laiersession.
26113b9f610SMax LaierThis ensures that there will be no unauthenticated traffic
26213b9f610SMax Laierallowed to pass after the controlling
26313b9f610SMax Laier.Xr ssh 1
26413b9f610SMax Laiersession has been closed.
26513b9f610SMax Laier.Pp
26613b9f610SMax Laier.Nm
26713b9f610SMax Laieris designed for gateway machines which typically do not have regular
26813b9f610SMax Laier(non-administrative) users using the machine.
26913b9f610SMax LaierAn administrator must remember that
27013b9f610SMax Laier.Nm
27113b9f610SMax Laiercan be used to modify the filter rules through the environment in
27213b9f610SMax Laierwhich it is run, and as such could be used to modify the filter rules
27313b9f610SMax Laier(based on the contents of the configuration files) by regular
27413b9f610SMax Laierusers.
27513b9f610SMax LaierIn the case where a machine has regular users using it, as well
27613b9f610SMax Laieras users with
27713b9f610SMax Laier.Nm
27813b9f610SMax Laieras their shell, the regular users should be prevented from running
27913b9f610SMax Laier.Nm
28013b9f610SMax Laierby using the
28113b9f610SMax Laier.Pa /etc/authpf/authpf.allow
28213b9f610SMax Laieror
28313b9f610SMax Laier.Pa /etc/authpf/banned/
28413b9f610SMax Laierfacilities.
28513b9f610SMax Laier.Pp
28613b9f610SMax Laier.Nm
28713b9f610SMax Laiermodifies the packet filter and address translation rules, and because
28813b9f610SMax Laierof this it needs to be configured carefully.
28913b9f610SMax Laier.Nm
29013b9f610SMax Laierwill not run and will exit silently if the
29113b9f610SMax Laier.Pa /etc/authpf/authpf.conf
29213b9f610SMax Laierfile does not exist.
29313b9f610SMax LaierAfter considering the effect
29413b9f610SMax Laier.Nm
29513b9f610SMax Laiermay have on the main packet filter rules, the system administrator may
29613b9f610SMax Laierenable
29713b9f610SMax Laier.Nm
29813b9f610SMax Laierby creating an appropriate
29913b9f610SMax Laier.Pa /etc/authpf/authpf.conf
30013b9f610SMax Laierfile.
30113b9f610SMax Laier.Sh EXAMPLES
302abff3868SMax Laier.Sy Control Files
303abff3868SMax Laier\- To illustrate the user-specific access control
30413b9f610SMax Laiermechanisms, let us consider a typical user named bob.
30513b9f610SMax LaierNormally, as long as bob can authenticate himself, the
30613b9f610SMax Laier.Nm
30713b9f610SMax Laierprogram will load the appropriate rules.
30813b9f610SMax LaierEnter the
30913b9f610SMax Laier.Pa /etc/authpf/banned/
31013b9f610SMax Laierdirectory.
31113b9f610SMax LaierIf bob has somehow fallen from grace in the eyes of the
31213b9f610SMax Laierpowers-that-be, they can prohibit him from using the gateway by creating
31313b9f610SMax Laierthe file
31413b9f610SMax Laier.Pa /etc/authpf/banned/bob
31513b9f610SMax Laiercontaining a message about why he has been banned from using the network.
31613b9f610SMax LaierOnce bob has done suitable penance, his access may be restored by moving or
31713b9f610SMax Laierremoving the file
31813b9f610SMax Laier.Pa /etc/authpf/banned/bob .
31913b9f610SMax Laier.Pp
32013b9f610SMax LaierNow consider a workgroup containing alice, bob, carol and dave.
32113b9f610SMax LaierThey have a
32213b9f610SMax Laierwireless network which they would like to protect from unauthorized use.
32313b9f610SMax LaierTo accomplish this, they create the file
32413b9f610SMax Laier.Pa /etc/authpf/authpf.allow
325e0bfbfceSBjoern A. Zeebwhich lists their login ids, group prepended with "%", or login class
326e0bfbfceSBjoern A. Zeebprepended with "@", one per line.
32713b9f610SMax LaierAt this point, even if eve could authenticate to
32813b9f610SMax Laier.Xr sshd 8 ,
32913b9f610SMax Laiershe would not be allowed to use the gateway.
33013b9f610SMax LaierAdding and removing users from
33113b9f610SMax Laierthe work group is a simple matter of maintaining a list of allowed userids.
33213b9f610SMax LaierIf bob once again manages to annoy the powers-that-be, they can ban him from
33313b9f610SMax Laierusing the gateway by creating the familiar
33413b9f610SMax Laier.Pa /etc/authpf/banned/bob
33513b9f610SMax Laierfile.
33613b9f610SMax LaierThough bob is listed in the allow file, he is prevented from using
33713b9f610SMax Laierthis gateway due to the existence of a ban file.
33813b9f610SMax Laier.Pp
339abff3868SMax Laier.Sy Distributed Authentication
340abff3868SMax Laier\- It is often desirable to interface with a
34113b9f610SMax Laierdistributed password system rather than forcing the sysadmins to keep a large
34213b9f610SMax Laiernumber of local password files in sync.
34313b9f610SMax LaierThe
34413b9f610SMax Laier.Xr login.conf 5
34513b9f610SMax Laiermechanism in
34613b9f610SMax Laier.Ox
34713b9f610SMax Laiercan be used to fork the right shell.
34813b9f610SMax LaierTo make that happen,
34913b9f610SMax Laier.Xr login.conf 5
35013b9f610SMax Laiershould have entries that look something like this:
35113b9f610SMax Laier.Bd -literal -offset indent
35213b9f610SMax Laiershell-default:shell=/bin/csh
35313b9f610SMax Laier
35413b9f610SMax Laierdefault:\e
35513b9f610SMax Laier	...
35613b9f610SMax Laier	:shell=/usr/sbin/authpf
35713b9f610SMax Laier
35813b9f610SMax Laierdaemon:\e
35913b9f610SMax Laier	...
36013b9f610SMax Laier	:shell=/bin/csh:\e
36113b9f610SMax Laier	:tc=default:
36213b9f610SMax Laier
36313b9f610SMax Laierstaff:\e
36413b9f610SMax Laier	...
36513b9f610SMax Laier	:shell=/bin/csh:\e
36613b9f610SMax Laier	:tc=default:
36713b9f610SMax Laier.Ed
36813b9f610SMax Laier.Pp
36913b9f610SMax LaierUsing a default password file, all users will get
37013b9f610SMax Laier.Nm
37113b9f610SMax Laieras their shell except for root who will get
37213b9f610SMax Laier.Pa /bin/csh .
37313b9f610SMax Laier.Pp
374abff3868SMax Laier.Sy SSH Configuration
375abff3868SMax Laier\- As stated earlier,
37613b9f610SMax Laier.Xr sshd 8
37713b9f610SMax Laiermust be properly configured to detect and defeat network attacks.
37813b9f610SMax LaierTo that end, the following options should be added to
37913b9f610SMax Laier.Xr sshd_config 5 :
38013b9f610SMax Laier.Bd -literal -offset indent
38113b9f610SMax LaierProtocol 2
38213b9f610SMax LaierClientAliveInterval 15
38313b9f610SMax LaierClientAliveCountMax 3
38413b9f610SMax Laier.Ed
38513b9f610SMax Laier.Pp
38613b9f610SMax LaierThis ensures that unresponsive or spoofed sessions are terminated within a
38713b9f610SMax Laierminute, since a hijacker should not be able to spoof ssh keepalive messages.
38813b9f610SMax Laier.Pp
389abff3868SMax Laier.Sy Banners
390abff3868SMax Laier\- Once authenticated, the user is shown the contents of
39113b9f610SMax Laier.Pa /etc/authpf/authpf.message .
39213b9f610SMax LaierThis message may be a screen-full of the appropriate use policy, the contents
39313b9f610SMax Laierof
39413b9f610SMax Laier.Pa /etc/motd
39513b9f610SMax Laieror something as simple as the following:
39613b9f610SMax Laier.Bd -literal -offset indent
39713b9f610SMax LaierThis means you will be held accountable by the powers that be
39813b9f610SMax Laierfor traffic originating from your machine, so please play nice.
39913b9f610SMax Laier.Ed
40013b9f610SMax Laier.Pp
40113b9f610SMax LaierTo tell the user where to go when the system is broken,
40213b9f610SMax Laier.Pa /etc/authpf/authpf.problem
40313b9f610SMax Laiercould contain something like this:
40413b9f610SMax Laier.Bd -literal -offset indent
40513b9f610SMax LaierSorry, there appears to be some system problem. To report this
40613b9f610SMax Laierproblem so we can fix it, please phone 1-900-314-1597 or send
40713b9f610SMax Laieran email to remove@bulkmailerz.net.
40813b9f610SMax Laier.Ed
40913b9f610SMax Laier.Pp
410abff3868SMax Laier.Sy Packet Filter Rules
411abff3868SMax Laier\- In areas where this gateway is used to protect a
41213b9f610SMax Laierwireless network (a hub with several hundred ports), the default rule set as
41313b9f610SMax Laierwell as the per-user rules should probably allow very few things beyond
41413b9f610SMax Laierencrypted protocols like
41513b9f610SMax Laier.Xr ssh 1 ,
41613b9f610SMax Laier.Xr ssl 8 ,
41713b9f610SMax Laieror
41813b9f610SMax Laier.Xr ipsec 4 .
41913b9f610SMax LaierOn a securely switched network, with plug-in jacks for visitors who are
42013b9f610SMax Laiergiven authentication accounts, you might want to allow out everything.
42113b9f610SMax LaierIn this context, a secure switch is one that tries to prevent address table
42213b9f610SMax Laieroverflow attacks.
42313b9f610SMax Laier.Pp
42413b9f610SMax LaierExample
42513b9f610SMax Laier.Pa /etc/pf.conf :
42613b9f610SMax Laier.Bd -literal
42713b9f610SMax Laier# by default we allow internal clients to talk to us using
42813b9f610SMax Laier# ssh and use us as a dns server.
429abff3868SMax Laierinternal_if="fxp1"
430abff3868SMax Laiergateway_addr="10.0.1.1"
43161a1372bSMax Laiernat-anchor "authpf/*"
43261a1372bSMax Laierrdr-anchor "authpf/*"
43361a1372bSMax Laierbinat-anchor "authpf/*"
43413b9f610SMax Laierblock in on $internal_if from any to any
43513b9f610SMax Laierpass in quick on $internal_if proto tcp from any to $gateway_addr \e
43613b9f610SMax Laier      port = ssh
43713b9f610SMax Laierpass in quick on $internal_if proto udp from any to $gateway_addr \e
43813b9f610SMax Laier      port = domain
43961a1372bSMax Laieranchor "authpf/*"
44013b9f610SMax Laier.Ed
44113b9f610SMax Laier.Pp
442abff3868SMax Laier.Sy For a switched, wired net
443abff3868SMax Laier\- This example
444abff3868SMax Laier.Pa /etc/authpf/authpf.rules
445abff3868SMax Laiermakes no real restrictions; it turns the IP address on and off, logging
446abff3868SMax LaierTCP connections.
44713b9f610SMax Laier.Bd -literal
448abff3868SMax Laierexternal_if = "xl0"
449abff3868SMax Laierinternal_if = "fxp0"
45013b9f610SMax Laier
4515ee7cd21SMax Laierpass in log quick on $internal_if proto tcp from $user_ip to any
45213b9f610SMax Laierpass in quick on $internal_if from $user_ip to any
45313b9f610SMax Laier.Ed
45413b9f610SMax Laier.Pp
455abff3868SMax Laier.Sy For a wireless or shared net
456abff3868SMax Laier\- This example
45713b9f610SMax Laier.Pa /etc/authpf/authpf.rules
458abff3868SMax Laiercould be used for an insecure network (such as a public wireless network) where
45913b9f610SMax Laierwe might need to be a bit more restrictive.
46013b9f610SMax Laier.Bd -literal
461abff3868SMax Laierinternal_if="fxp1"
462abff3868SMax Laieripsec_gw="10.2.3.4"
46313b9f610SMax Laier
46413b9f610SMax Laier# rdr ftp for proxying by ftp-proxy(8)
46513b9f610SMax Laierrdr on $internal_if proto tcp from $user_ip to any port 21 \e
4665ee7cd21SMax Laier      -> 127.0.0.1 port 8021
46713b9f610SMax Laier
46813b9f610SMax Laier# allow out ftp, ssh, www and https only, and allow user to negotiate
46913b9f610SMax Laier# ipsec with the ipsec server.
47013b9f610SMax Laierpass in log quick on $internal_if proto tcp from $user_ip to any \e
4715ee7cd21SMax Laier      port { 21, 22, 80, 443 }
47213b9f610SMax Laierpass in quick on $internal_if proto tcp from $user_ip to any \e
47313b9f610SMax Laier      port { 21, 22, 80, 443 }
4745ee7cd21SMax Laierpass in quick proto udp from $user_ip to $ipsec_gw port = isakmp
47513b9f610SMax Laierpass in quick proto esp from $user_ip to $ipsec_gw
47613b9f610SMax Laier.Ed
477abff3868SMax Laier.Pp
478abff3868SMax Laier.Sy Dealing with NAT
479abff3868SMax Laier\- The following
480abff3868SMax Laier.Pa /etc/authpf/authpf.rules
481abff3868SMax Laiershows how to deal with NAT, using tags:
482abff3868SMax Laier.Bd -literal
483abff3868SMax Laierext_if = "fxp1"
484abff3868SMax Laierext_addr = 129.128.11.10
485abff3868SMax Laierint_if = "fxp0"
486abff3868SMax Laier# nat and tag connections...
487abff3868SMax Laiernat on $ext_if from $user_ip to any tag $user_ip -> $ext_addr
488abff3868SMax Laierpass in quick on $int_if from $user_ip to any
4895ee7cd21SMax Laierpass out log quick on $ext_if tagged $user_ip
490abff3868SMax Laier.Ed
491abff3868SMax Laier.Pp
492abff3868SMax LaierWith the above rules added by
493abff3868SMax Laier.Nm ,
494abff3868SMax Laieroutbound connections corresponding to each users NAT'ed connections
495abff3868SMax Laierwill be logged as in the example below, where the user may be identified
496abff3868SMax Laierfrom the ruleset name.
497abff3868SMax Laier.Bd -literal
498abff3868SMax Laier# tcpdump -n -e -ttt -i pflog0
499abff3868SMax LaierOct 31 19:42:30.296553 rule 0.bbeck(20267).1/0(match): pass out on fxp1: \e
500abff3868SMax Laier129.128.11.10.60539 > 198.137.240.92.22: S 2131494121:2131494121(0) win \e
501abff3868SMax Laier16384 <mss 1460,nop,nop,sackOK> (DF)
502abff3868SMax Laier.Ed
50361a1372bSMax Laier.Pp
50461a1372bSMax Laier.Sy Using the authpf_users table
50561a1372bSMax Laier\- Simple
50661a1372bSMax Laier.Nm
50761a1372bSMax Laiersettings can be implemented without an anchor by just using the "authpf_users"
50861a1372bSMax Laier.Pa table .
50961a1372bSMax LaierFor example, the following
51061a1372bSMax Laier.Xr pf.conf 5
51161a1372bSMax Laierlines will give SMTP and IMAP access to logged in users:
51261a1372bSMax Laier.Bd -literal
51361a1372bSMax Laiertable <authpf_users> persist
51461a1372bSMax Laierpass in on $ext_if proto tcp from <authpf_users> \e
5155ee7cd21SMax Laier        to port { smtp imap }
51661a1372bSMax Laier.Ed
51761a1372bSMax Laier.Pp
51861a1372bSMax LaierIt is also possible to use the "authpf_users"
51961a1372bSMax Laier.Pa table
52061a1372bSMax Laierin combination with anchors.
52161a1372bSMax LaierFor example,
52261a1372bSMax Laier.Xr pf 4
52361a1372bSMax Laierprocessing can be sped up by looking up the anchor
52461a1372bSMax Laieronly for packets coming from logged in users:
52561a1372bSMax Laier.Bd -literal
52661a1372bSMax Laiertable <authpf_users> persist
52761a1372bSMax Laieranchor "authpf/*" from <authpf_users>
52861a1372bSMax Laierrdr-anchor "authpf/*" from <authpf_users>
52961a1372bSMax Laier.Ed
530e0bfbfceSBjoern A. Zeeb.Pp
531e0bfbfceSBjoern A. Zeeb.Sy Tunneled users
532e0bfbfceSBjoern A. Zeeb\- normally
533e0bfbfceSBjoern A. Zeeb.Nm
534e0bfbfceSBjoern A. Zeeballows only one session per client IP address.
535e0bfbfceSBjoern A. ZeebHowever in some cases, such as when connections are tunneled via
536e0bfbfceSBjoern A. Zeeb.Xr ssh 1
537e0bfbfceSBjoern A. Zeebor
538e0bfbfceSBjoern A. Zeeb.Xr ipsec 4 ,
539e0bfbfceSBjoern A. Zeebthe connections can be authorized based on the userid of the user instead of
540e0bfbfceSBjoern A. Zeebthe client IP address.
541e0bfbfceSBjoern A. ZeebIn this case it is appropriate to use
542e0bfbfceSBjoern A. Zeeb.Nm authpf-noip
543e0bfbfceSBjoern A. Zeebto allow multiple users behind a NAT gateway to connect.
544e0bfbfceSBjoern A. ZeebIn the
545e0bfbfceSBjoern A. Zeeb.Pa /etc/authpf/authpf.rules
546e0bfbfceSBjoern A. Zeebexample below, the remote user could tunnel a remote desktop session to their
547e0bfbfceSBjoern A. Zeebworkstation:
548e0bfbfceSBjoern A. Zeeb.Bd -literal
549e0bfbfceSBjoern A. Zeebinternal_if="bge0"
550e0bfbfceSBjoern A. Zeebworkstation_ip="10.2.3.4"
551e0bfbfceSBjoern A. Zeeb
552e0bfbfceSBjoern A. Zeebpass out on $internal_if from (self) to $workstation_ip port 3389 \e
553e0bfbfceSBjoern A. Zeeb       user $user_id
554e0bfbfceSBjoern A. Zeeb.Ed
55513b9f610SMax Laier.Sh FILES
55613b9f610SMax Laier.Bl -tag -width "/etc/authpf/authpf.conf" -compact
55713b9f610SMax Laier.It Pa /etc/authpf/authpf.conf
55813b9f610SMax Laier.It Pa /etc/authpf/authpf.allow
55913b9f610SMax Laier.It Pa /etc/authpf/authpf.rules
56013b9f610SMax Laier.It Pa /etc/authpf/authpf.message
56113b9f610SMax Laier.It Pa /etc/authpf/authpf.problem
56213b9f610SMax Laier.El
56313b9f610SMax Laier.Sh SEE ALSO
564*1a720cbeSAlexander Ziaee.Xr fdescfs 4 ,
56513b9f610SMax Laier.Xr pf 4 ,
56613b9f610SMax Laier.Xr pf.conf 5 ,
5675ee7cd21SMax Laier.Xr securelevel 7 ,
56813b9f610SMax Laier.Xr ftp-proxy 8
56913b9f610SMax Laier.Sh HISTORY
57013b9f610SMax LaierThe
57113b9f610SMax Laier.Nm
57213b9f610SMax Laierprogram first appeared in
57313b9f610SMax Laier.Ox 3.1 .
57413b9f610SMax Laier.Sh BUGS
57513b9f610SMax LaierConfiguration issues are tricky.
57613b9f610SMax LaierThe authenticating
57713b9f610SMax Laier.Xr ssh 1
57813b9f610SMax Laierconnection may be secured, but if the network is not secured the user may
57913b9f610SMax Laierexpose insecure protocols to attackers on the same network, or enable other
58013b9f610SMax Laierattackers on the network to pretend to be the user by spoofing their IP
58113b9f610SMax Laieraddress.
58213b9f610SMax Laier.Pp
58313b9f610SMax Laier.Nm
58413b9f610SMax Laieris not designed to prevent users from denying service to other users.
585