Debian Codegraph @

doc/howto/Classes.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>ProFTPD: Classes</title>
5 </head>
6
7 <body bgcolor=white>
8
9 <hr>
10 <center><h2><b>ProFTPD: Classes</b></h2></center>
11 <hr>
12
13 <p>
14 <b>What are Classes?</b><br>
15 When configuring <code>proftpd</code>, it is sometimes nice, or even necessary,
16 to tag or label a client as belonging to some group, based on that client's
17 IP address or DNS hostname. A &quot;class&quot; is the name for such
18 connection-based groupings in ProFTPD terms. A class is defined to have
19 a <em>name</em>, and as having certain criteria such as IP addresses, IP
20 subnets/masks, and DNS hostnames. A client that connects to the daemon
21 that has matching characteristics is then labeled as belonging to that class.
22 <b>Note</b> that a connecting client can belong to only <b>one</b> class;
23 see the description below for how the winning class is selected for a session
24 from among multiple possible matches.
25
26 <p>
27 <b>How are Classes Defined?</b><br>
28 To define a class, use a <code>&lt;Class&gt;</code> section in your
29 <code>proftpd.conf</code>:
30 <pre>
31 &lt;Class internal&gt;
32 From 192.168.0.0/16
33 &lt;/Class&gt;
34 </pre>
35 This defines a class named &quot;internal&quot;; any client connecting from
36 192.168.0.0/16 will belong to this class. And if you wanted to define a
37 class for all clients not connecting from 192.168.0.0/16 address space:
38 <pre>
39 &lt;Class external&gt;
40 From !192.168.0.0/16
41 &lt;/Class&gt;
42 </pre>
43 A more complicated class might include matching DNS names as well:
44 <pre>
45 &lt;Class test&gt;
46 From 1.2.3.4
47 From proxy.*.com
48 From my.example.com
49 From 5.6.7.8
50 &lt;/Class&gt;
51 </pre>
52 This &quot;test&quot; class will then be used for a client with any of the
53 defined characteristics.
54
55 <p>
56 Note that if your class rules use only DNS names, and <code>proftpd</code>
57 is unable to resolve the IP address of a client to a DNS name, that
58 class may not be matched as you might expect. This can be seen in
59 the server debugging output, at level 10, as something like:
60 <pre>
61 comparing DNS name '1.2.3.4' to pattern 'proxy.*.com'
62 </pre>
63 Here you see the 1.2.3.4 IP address, where a DNS name should be. In order
64 for DNS name based class rules to function properly, both a) DNS resolution
65 is needed (<i>i.e.</i> <code>UseReverseDNS</code> must be <em>on</em>, which
66 is the default), and b) the IP address of a connecting client must be
67 resolvable to a DNS name.
68
69 <p>
70 What if there are multiple classes defined, and the classes overlap, <i>e.g.</i>
71 two classes both have:
72 <pre>
73 From *.example.com
74 </pre>
75 Which one will be used for the connecting client? This will depend on the
76 order in which classes are defined in the <code>proftpd.conf</code> file.
77 When searching the list of classes for the one that matches the client,
78 <code>proftpd</code> checks each class in the order in which they are defined.
79 The first class definition (in order of appearance in
80 <code>proftpd.conf</code>) that matches is used.
81
82 <p>
83 How do you define a class that includes all clients from a certain
84 domain <b>except</b> one specific host in that domain? To define a class with
85 these sorts of characteristics, use the <code>Satisfy</code> configuration
86 directive:
87 <pre>
88 &lt;Class foo&gt;
89 From *.example.com
90 From !bad.example.com
91 Satisfy all
92 &lt;/Class&gt;
93 </pre>
94
95 <p>
96 <b>Using <code>Satisfy</code></b><br>
97 The <code>Satisfy</code> directive, when used within a
98 <code>&lt;Class&gt;</code> section, indicates whether <i>any</i> of the
99 <code>From</code> rules in the section need to match, or whether <i>all</i> of
100 the <code>From</code> rules in the section need to match. The default
101 <code>Satisfy</code> setting for a <code>&lt;Class&gt;</code> section is
102 "any".
103
104 <p>
105 To illustrate, the following class definition will never match:
106 <pre>
107 &lt;Class impossible&gt;
108 From 127.0.0.1
109 From !127.0.0.1
110 Satisfy all
111 &lt;/Class&gt;
112 </pre>
113 It is impossible to both an address and <b>not</b> match that same address,
114 but that is what is demanded by the "Satisfy all" setting in the above
115 class definition.
116
117 <p>
118 Now, where the use of "Satisfy all" comes in handy is when you have a general
119 rule with exceptions:
120 <pre>
121 &lt;Class customers&gt;
122 From .domain.com
123 From !host1.domain.com !host2.domain.com
124 Satisfy all
125 &lt;/Class&gt;
126 </pre>
127 Specifically, the use of "Satisfy all" is necessary when you have multiple
128 <i>not</i> matches (<i>i.e.</i> using the <code>!</code> prefix), <i>all</i>
129 of which need to be evaluated.
130
131 <p>
132 <b>How are Classes Used?</b><br>
133 By itself, a class does nothing. It is merely a way to define a set of clients
134 and to give that set a name. Once that name is defined, though, it can be
135 use as part of your configuration. There are a limited number of configuration
136 directives that make use of classes directly:
137 <ul>
138 <li><code>AllowClass</code>
139 <li><code>DenyClass</code>
140 <li><code>DisplayGoAway</code>
141 <li><code>MaxClientsPerClass</code>
142 </ul>
143 The <code>AllowClass</code> and <code>DenyClass</code> directives are the
144 main directives to use, for example in <code>&lt;Limit&gt;</code> sections:
145 <pre>
146 &lt;Limit ALL&gt;
147 AllowClass internal
148 DenyAll
149 &lt;/Limit&gt;
150 </pre>
151
152 <p>
153 The <a href="../contrib/mod_ifsession.html"><code>mod_ifsession</code></a>
154 module also makes use of classes with its <code>&lt;IfClass&gt;</code>
155 configuration section. Using classes and <code>mod_ifsession</code>, you can
156 write a <code>proftpd.conf</code> that has specific configurations for specific
157 classes of clients. Here's an example snippet demonstrating use of
158 <code>&lt;IfClass&gt;</code>:
159 <pre>
160 &lt;IfClass internal&gt;
161 MaxClients 100
162 &lt;/IfClass&gt;
163
164 &lt;IfClass !internal&gt;
165 MaxClients 25
166 &lt;/IfClass&gt;
167 </pre>
168 This allows clients from class &quot;internal&quot; to see an effective
169 <code>MaxClients</code> limit of 100 simultaneous clients, and clients
170 <b>not</b> in class &quot;internal&quot; to see an effective limit of only 25.
171
172 <p>
173 <hr>
174 <font size=2><b><i>
175 &copy; Copyright 2017 The ProFTPD Project<br>
176 All Rights Reserved<br>
177 </i></b></font>
178 <hr>
179
180 </body>
181 </html>